<template>
  <div v-loading="loading" class="repayment-play">
    <foundation-info :foundation-info="foundationInfo" :disabled="true" />
    <accounts-receivable v-if="detailsInfo.tradeFactoring" :receivable-info="receivableInfo" :disabled="true" />
    <financing-plan :financing-plan="financingPlan" :disabled="true" />
    <accounts-plan :accounts-plan="accountsPlan" :disabled="true" />
  </div>
</template>

<script>
import { getRepaymentPlan } from '@/api/myFinancing'
export default {
  name: 'RepaymentPlay',
  components: {
    FoundationInfo: () => import('./components/FoundationInfo'),
    AccountsReceivable: () => import('./components/AccountsReceivable'),
    FinancingPlan: () => import('./components/FinancingPlan'),
    AccountsPlan: () => import('./components/AccountsPlan')
  },
  data() {
    return {
      detailsInfo: {},
      foundationInfo: {},
      receivableInfo: {},
      financingPlan: {},
      accountsPlan: {},
      loading: false
    }
  },
  created() {
    this.getPlanData()
  },
  methods: {
    getPlanData() {
      this.loading = true
      const { id } = this.$route.params
      getRepaymentPlan({ id }).then(({ data }) => {
        this.detailsInfo = data
        this.loading = false
        const { businessNo, contractNo, applicantName, applicantSocialCreditCode, quotaDisburseBatch, productType, projectManager, tradePlanReceivableList, planFactoringList, irr, contractIrr, quotaIrr, planReceivableList } = data
        // 基本信息
        this.foundationInfo = {
          businessNo,
          contractNo,
          applicantName,
          applicantSocialCreditCode,
          quotaDisburseBatch,
          projectManager: projectManager.name,
          productType: productType.name
        }
        // 贸理通关联应收账款
        this.receivableInfo = {
          tradePlanReceivableList
        }

        // 收放款计划（保理融资款）
        this.financingPlan = {
          planFactoringList,
          irr,
          contractIrr,
          quotaIrr
        }

        // 收放款计划（应收账款）
        this.accountsPlan = planReceivableList
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.repayment-play {

}
</style>
