<template>
  <div>
    <BaseInfo
      ref="baseInfoRef"
      :details-info="baseInfo"
      :disabled="$route.query.type === 'see'"
    ></BaseInfo>
    <PayInfo
      ref="payInfoRef"
      :details-info="payInfo"
      :disabled="$route.query.type === 'see'"
    ></PayInfo>

    <div class="submit-btn">
      <el-button
        @click="
          () => {
            $router.go(-1)
          }
        "
      >取消</el-button>
    </div>
  </div>
</template>

<script>
import { getAdvancePaymentDetails } from '@/api/capitalFinancialManage'

export default {
  components: {
    BaseInfo: () => import('./components/BaseInfo.vue'),
    PayInfo: () => import('./components/PayInfo.vue')
  },
  data() {
    return {
      baseInfo: {},
      payInfo: {}
    }
  },
  watch: {
    $route: {
      handler(val) {
        if (val && val.query && val.query.id) {
          this.queryDetail(val.query.id)
        }
      },
      immediate: true
    }
  },
  methods: {
    async queryDetail(id) {
      const res = await getAdvancePaymentDetails({ id })

      if (res.success) {
        const {
          customerType,
          cEnterpriseId,
          supplierName,
          socialCreditCode,
          financingManagementId,
          institutionName,
          openId,
          hxAmt,
          contractNo,
          quotaDisburseBatch,
          dueBillNo,
          repayNo,
          repayDate,
          payoutDate,
          repayStatus,
          hxCapi,
          hxFinte,
          hxInte,
          hxCint,
          failMsg
        } = res.data

        this.baseInfo = {
          customerType,
          cEnterpriseId,
          supplierName,
          socialCreditCode,
          financingManagementId,
          institutionName,
          openId,
          hxAmt,
          contractNo,
          quotaDisburseBatch
        }

        this.payInfo = {
          dueBillNo,
          repayNo,
          repayDate,
          payoutDate,
          repayStatus,
          hxCapi,
          hxFinte,
          hxInte,
          hxCint,
          failMsg
        }
      }
    }
  }
}
</script>

<style lang="sass" scoped></style>
