<template>
  <div class="sales-contract-management-view">
    <div v-loading="loading">
      <div v-if="stepList.length" class="view-steps-box">
        <cy-steps :steps-data="stepList" />
      </div>
      <el-collapse v-if="stepList.length" v-model="activeNames">
        <el-collapse-item v-for="(item, index) in stepList" :key="index" :name="index">
          <template slot="title">
            <cy-view-bar
              :view-bar-data="{ ...item.businessProcessingLogVo, formBusinessName: item.formBusinessName, index: index + 1 }"
            />
          </template>
          <template v-if="item.formBusinessName == '采购合同录入'">
            <step-1 :info="item.obj"></step-1>
          </template>
          <template v-if="item.formBusinessName.includes('采购合同签署') || item.formBusinessName.includes('采购合同变更签署')">
            <step-2 :info="item.obj"></step-2>
          </template>
          <template v-if="item.formBusinessName == '采购合同变更录入'">
            <step-3 :info="item.obj"></step-3>
          </template>
        </el-collapse-item>
      </el-collapse>
    </div>
  </div>
</template>

<script>
import { getDetail } from '@/api/myTrade/purchaseContractManagement/purchaseContractManagement'
import collapseSeeMix from '@/mixins/collapseSeeMix'

export default {
  components: {
    Step1: () => import('./detailComponents/Step1'),
    Step2: () => import('./detailComponents/Step2'),
    Step3: () => import('./detailComponents/Step3')
  },
  mixins: [collapseSeeMix],
  data() {
    return {
      activeNames: [],
      loading: false,
      stepList: []
    }
  },
  mounted() {
    this.loading = true
    getDetail({ businessKey: this.$route.query.infoId, businessType: 'PurchContract' }).then(({ data }) => {
      data.forEach(item => {
        if(item.obj) {
          item.obj.mathId = Math.random()
        } else {
          item.obj = { mathId: Math.random() }
        }
      })
      this.loading = false
      this.stepList = [ ...data ]
    })
  },
  methods: {
    handleChange() {}
  }
}
</script>

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