<template>
  <div class="sales-contract-management-view">
    <div v-if="advanceViewList.length" class="view-steps-box">
      <cy-steps :steps-data="advanceViewList" />
    </div>
    <div v-loading="loading">
      <el-collapse v-if="advanceViewList.length" v-model="activeNames" @change="handleChange">
        <el-collapse-item v-for="(item, index) in advanceViewList" :id="index" :key="index" :name="index" :title="item.formBusinessName">
          <template slot="title">
            <cy-view-bar
              :view-bar-data="{ ...item.businessProcessingLogVo, formBusinessName: item.formBusinessName, index: index + 1 }"
            />
          </template>
          <create-sales-contract-content v-if="item.formBusinessName === '销售合同创建'" :sales-contract="item.obj" :disabled="true" />
          <sales-contract-add-content v-if="item.formBusinessName === '销售合同录入'" :deatils-info="item.obj" :disabled="true" />
          <change-create-sales-contract-content v-if="item.formBusinessName === '变更合同创建'" :change-create="item.obj" :disabled="true" />
          <change-sales-contract-add-content v-if="item.formBusinessName === '变更信息录入'" :deatils-info="item.obj" :disabled="true" />
          <sign-confirmation-content v-if="item.formBusinessName === '签署确认' || item.formBusinessName === '变更签署确认'" :deatils-info="item.obj" :disabled="true" />
        </el-collapse-item>
      </el-collapse>
      <!-- <el-empty v-else style="height: calc(100vh - 0.85rem - 90px)"></el-empty> -->
    </div>
  </div>
</template>

<script>
import { salesContractManagementGetView } from '@/api/myTrade/salesContractManagement/salesContractManagement'
import collapseSeeMix from '@/mixins/collapseSeeMix'

export default {
  components: {
    CreateSalesContractContent: () => import('./CreateSalesContractContent'),
    SalesContractAddContent: () => import('./SalesContractAddContent.vue'),
    ChangeCreateSalesContractContent: () => import('./ChangeCreateSalesContractContent.vue'),
    ChangeSalesContractAddContent: () => import('./ChangeSalesContractAddContent.vue'),
    SignConfirmationContent: () => import('./SignConfirmationContent.vue')
    // MarginRefundConfirmContent: () => import('./MarginRefundConfirmContent')
  },
  mixins: [collapseSeeMix],
  data() {
    return {
      activeNames: [],
      advanceViewList: {
        contractBasicVo: {}
      },
      loading: true
    }
  },
  created() {
    this.featchDat()
  },
  methods: {
    featchDat() {
      this.loading = true
      const { id } = this.$route.query
      salesContractManagementGetView({ businessKey: id, businessType: 'SalesContract' }).then(({ data }) => {
        this.loading = false
        this.advanceViewList = data
      })
    }
  }
}
</script>

<style scoped>
.sales-contract-management-view .tempalte-content {
  min-height: calc(100vh - 0.85rem - 120px);
}
</style>
