<template>
  <div class="prequalification" v-loading="isLoading">
    <cy-up-down-drag>
      <div slot="top">
        <cy-steps :stepsData="stepList"></cy-steps>
        <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 }">
              </cy-view-bar>
            </template>
            <template v-if="item.formBusinessName == '采购合同录入'">
              <step-1 :info="item.obj"></step-1>
            </template>
            <template v-if="item.formBusinessName == '采购合同审核'">
              <purchase-contract-review-content :info="item.obj" :isView="true" />
            </template>
            <template v-if="item.formBusinessName.includes('采购合同签署') || item.formBusinessName.includes('采购合同变更签署')">
              <step-2 :info="item.obj"></step-2>
            </template>
            <template v-if="item.formBusinessName == '采购合同变更终审' || item.formBusinessName == '采购合同终审'">
              <sign-review-content :info="item.obj" :isView="true" />
            </template>
            <template v-if="item.formBusinessName == '采购合同变更录入'">
              <step-3 :info="item.obj"></step-3>
            </template>
            <template v-if="item.formBusinessName == '采购合同变更审核'">
              <change-contract-review-content :info="item.obj" :isView="true" />
            </template>
          </el-collapse-item>
        </el-collapse>
      </div>
      <div slot="bar">
        <div>
          模板审核
        </div>
      </div>
      <div slot="bottom">
        <div class="tempalte-content" style="min-height: auto; padding: 0px 20px ">
          <prequalification-content />
          <div class="submit-btn">
            <el-button style="width: 150px;" @click="() => { $router.go(-1) }">取消</el-button>
            <el-button type="primary" style="width: 150px;" @click="onSubmit">确定</el-button>
          </div>
        </div>
      </div>
    </cy-up-down-drag>
  </div>
</template>

<script>
import PrequalificationContent from './components/PrequalificationContent.vue'
import ChangeContractReviewContent from './components/ChangeContractReviewContent.vue'
import PurchaseContractReviewContent from './components/PurchaseContractReviewContent.vue'
import SignReviewContent from './components/SignReviewContent.vue'
import Step1 from './stepComponents/Step1.vue'
import Step2 from './stepComponents/Step2.vue'
import Step3 from './stepComponents/Step3.vue'
export default {
  name: 'BiddingManagementTemplateReview',
  components: {
    PrequalificationContent, SignReviewContent, Step1, PurchaseContractReviewContent, Step2, Step3, ChangeContractReviewContent
  },
  data() {
    return {
      stepList: [],

    }
  },
  mounted() {
    this.getStepList()
  },
  methods: {
    getStepList() {
      this.isLoading = true
      request({
        url: '/businessProcessingTask/doBusinessHistoryView',
        method: 'get',
        params: { businessKey: this.$route.query.infoId, businessType: 'PurchContract', Loading: true }
      }).then(({ data }) => {
        data.forEach(item => {
          if(item.obj) {
            item.obj.mathId = Math.random()
          } else {
            item.obj = { mathId: Math.random() }
          }
        })
        this.stepList = data || []
        this.isLoading = false
      })
    },
    onSubmit() {
      // this.$refs.templateExamineContent.getSubmit().then(data => {
      //   const { taskId, businessKey } = this.$route.query
      //   const params = {
      //     Loading: true,
      //     ...data,
      //     taskId,
      //     businessBasicInfoId: businessKey
      //   }
      //   this.$api.businessManage.businessTemplateExamineSubmit(params).then(() => {
      //     this.$message.success('模板审核成功')
      //     this.$router.push({ path: '/businessManage' })
      //   })
      // })
    }
  }
}
</script>

<style lang="scss" scoped>
  /* .template-examine .submit-btn {
    position: absolute;
    bottom: 40px;
    right: 40px;
  } */
</style>

