<template>
  <div v-loading="isLoading">
    <cy-steps :stepsData="stepList"></cy-steps>
    <el-collapse v-if="stepList.length" v-model="activeNames" @change="handleChange">
      <el-collapse-item v-for="(item, index) in stepList" :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>
        <template v-if="item.formBusinessName == '录入结算单'">
          <add :info="item.obj"></add>
        </template>
        <template v-if="item.formBusinessName == '法务审核' || item.formBusinessName == '单价变更审核'">
          <audit :info="item.obj"></audit>
        </template>
        <template v-if="item.formBusinessName == '签署结算单'">
          <sign :info="item.obj"></sign>
        </template>
        <template v-if="item.formBusinessName == '单价调整'">
          <edit :info="item.obj"></edit>
        </template>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import request from '@/utils/request'
import Add from './components/add'
import audit from './components/audit'
import sign from './components/sign'
import edit from './components/edit'
import collapseMix from '@/mixins/collapseSeeMix'

export default {
  mixins: [collapseMix],
  data() {
    return {
      stepList: [],
      activeNames: [],
      isLoading: false
    }
  },
  components: {
    Add, audit, sign, edit
  },
  mounted() {
    this.getStepList()
  },
  methods: {
    getStepList() {
      this.isLoading = true
      request({
        url: '/businessProcessingTask/doBusinessHistoryView',
        method: 'get',
        params: { businessKey: this.$route.query.infoId, businessType: 'BillBasicInformation' }
      }).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
      })
    }
  }
}
</script>

<style lang="scss">

</style>
