<template>
  <div class="acceptance-management-view">
    <div v-if="advanceViewList.length" class="view-steps-box">
      <cy-steps :steps-data="advanceViewList"></cy-steps>
    </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">
          <template slot="title">
            <cy-view-bar
              :view-bar-data="{ ...item.businessProcessingLogVo, formBusinessName: item.formBusinessName, index: index + 1 }"
            >
            </cy-view-bar>
          </template>
          <add v-if="item.formBusinessName === '录入验收单'" :details-info="item.obj"></add>
          <sign-confirm v-if="item.formBusinessName === '签署确认'" :details-info="item.obj"></sign-confirm>
          <legal-review v-if="item.formBusinessName === '法务审核'" :details-info="item.obj"></legal-review>
          <price-adjust v-if="item.formBusinessName.includes('单价调整')" :details-info="item.obj"></price-adjust>
          <adjust-review v-if="item.formBusinessName === '单价变更审核'" :details-info="item.obj"></adjust-review>
          <acceptance-conclusion v-if="item.formBusinessName === '业务审核'" :deatails-info="item.obj" type="businessReview"></acceptance-conclusion>
        </el-collapse-item>
      </el-collapse>
      <!-- <el-empty v-else style="height: calc(100vh - 0.85rem - 90px)"></el-empty> -->
    </div>
  </div>
</template>

<script>
import { doBusinessHistoryView } from '@/api/dictionary'
import collapseSeeMix from '@/mixins/collapseSeeMix'
import Add from './historyViewContent/add'
import SignConfirm from './historyViewContent/signConfirm'
import LegalReview from './historyViewContent/legalReview'
import PriceAdjust from './historyViewContent/priceAdjust'
import AdjustReview from './historyViewContent/adjustReview'
import AcceptanceConclusion from './AcceptanceConclusion.vue'

export default {
  components: {
    Add,
    SignConfirm,
    LegalReview,
    PriceAdjust,
    AdjustReview,
    AcceptanceConclusion
  },
  mixins: [collapseSeeMix],
  data() {
    return {
      activeNames: [],
      advanceViewList: [],
      loading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.loading = true
      const { id } = this.$route.query
      doBusinessHistoryView({ businessKey: id, businessType: 'AcceptanceSheet' }).then(({ data }) => {
        this.loading = false
        this.advanceViewList = data
      }).catch(res => {
        this.loading = false
      })
    }
  }
}
</script>

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