<template>
  <div class="sales-contract-management-view">
    <div v-loading="isLoading">
      <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 }">
            </cy-view-bar>
          </template>
          <template v-if="item.formBusinessName == '录入结算单'">
            <add :info="item.obj"></add>
          </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>
  </div>
</template>

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

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

<style lang="scss">

</style>
