<template>
  <div class="payment-approve">
    <cy-up-down-drag>
      <div slot="top">
        <financing-view-content></financing-view-content>
      </div>
      <div slot="bar">
        <div>
          付款审核
        </div>
      </div>
      <div slot="bottom">
        <payment-approve-content ref="paymentApprove" :details-info="detailsInfo"></payment-approve-content>
        <div class="submit-btn">
          <el-button @click="() => { $router.go(-1) }">取消</el-button>
          <el-button type="primary" @click="onSubmit">提交</el-button>
        </div>
      </div>
    </cy-up-down-drag>
  </div>
</template>  

<script>
import { getPaymentReviewDetails, paymentReviewSubmit } from '@/api/financingManage'
export default {
  components: {
    PaymentApproveContent: () => import('./components/PaymentApproveContent'),
    financingViewContent: () => import('./components/FinancingViewContent.vue')
  },
  data() {
    return {
      detailsInfo: {}
    }
  },
  created() {
    this.getDetails()
  },
  methods: {
    getDetails() {
      const { id } = this.$route.params
      getPaymentReviewDetails({ id }).then(({ data }) => {
        this.detailsInfo = data
      })
    },
    async onSubmit() {
      const { taskId } = this.$route.query
      const { paymentApplyId } = this.detailsInfo
      const oneData = await this.$refs.paymentApprove.getParams()
      const twoData = await this.$refs.paymentApprove.getRuleFormFileParams()
      const params = {
        Loading: true,
        visible: true,
        taskId,
        ...oneData,
        receivablesRegisterInfo: twoData,
        paymentApplyId
      }
      if (!twoData) {
        params.receivablesRegisterInfo
      }
      paymentReviewSubmit(params).then(() => {
        this.$message.success('提交成功')
        this.$router.go(-1)
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
