<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 == '授信决议' || item.formBusinessName == '授信决议确认'">
          <cy-info-title>基础信息</cy-info-title>
          <basic-info :info="item.obj" />
          <cy-info-title>授信信息</cy-info-title>
          <credit-info :info="item.obj" :isView="true"></credit-info>
          <cy-info-title>放款条件</cy-info-title>
          <pay-condition :info="item.obj" :isView="true" />
          <cy-info-title>授信结论</cy-info-title>
          <resolution-result :info="item.obj" :isView="true" />
        </template>
        <template v-if="item.formBusinessName == '授信决议确认'">
          <cy-info-title>授信决议</cy-info-title>
          <confirm :info="item.obj" :isView="true" />
        </template>
        <template v-if="item.formBusinessName == '复议调整申请'">
          <cy-info-title>复议调整</cy-info-title>
          <update-info :info="item.obj" :isView="true" />
        </template>
        <template v-if="item.formBusinessName == '复议调整审批'">
          <cy-info-title>审批结论</cy-info-title>
          <audit-info :info="item.obj" :isView="true" />
        </template>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import request from '@/utils/request'
import collapseSeeMix from '@/mixins/collapseSeeMix'

export default {
  mixins: [collapseSeeMix],
  data() {
    return {
      stepList: [],
      activeNames: [],
      isLoading: false
    }
  },
  components: {
    BasicInfo: () => import('./components/BasicInfo'),
    CreditInfo: () => import('./components/CreditInfo'),
    PayCondition: () => import('./components/PayCondition'),
    ResolutionResult: () => import('./components/ResolutionResult'),
    Confirm: () => import('./components/Confirm'),
    UpdateInfo: () => import('./components/UpdateInfo'),
    AuditInfo: () => import('./components/AuditInfo')
  },
  mounted() {
    this.getStepList()
  },
  methods: {
    getStepList() {
      this.isLoading = true
      request({
        url: '/businessProcessingTask/doBusinessHistoryView',
        method: 'get',
        params: { businessKey: this.$route.params.infoId, businessType: 'CreditResolution' }
      }).then(({ data }) => {
        data.forEach(item => {
          item.obj.loanConditionsList = item.obj.loanConditionsHistoryList || []
          item.obj.randomId = Math.random()
        })
        this.stepList = data || []
        this.isLoading = false
      })
    }
  }
}
</script>

<style lang="scss">

</style>
