<template>
  <div class="payment-application">
    <cy-up-down-drag>
      <div slot="top">
        <financing-view-content></financing-view-content>
      </div>
      <div slot="bar">
        <div>
          付款申请
        </div>
      </div>
      <div slot="bottom">
        <payment-content ref="paymentContent" :details-info="detailsInfo"></payment-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 { paymentApplyDetails, paymentApplySubmit } from '@/api/financingManage'
export default {
  components: {
    PaymentContent: () => import('./components/Content.vue'),
    FinancingViewContent: () => import('../components/FinancingViewContent.vue')
  },
  data() {
    return {
      detailsInfo: {}
    }
  },
  created() {
    this.getDetails()
  },
  methods: {
    getDetails() {
      const { id } = this.$route.params
      paymentApplyDetails({ id }).then(({ data }) => {
        this.detailsInfo = data
      })
    },
    async onSubmit() {
      const data = await this.$refs.paymentContent.getParams()
      const { taskId } = this.$route.query
      paymentApplySubmit({ Loading: true, ...data, taskId }).then(() => {
        this.$message.success('提交成功')
        this.$router.go(-1)
      })
    }

  }
}
</script>

<style lang="scss" scoped>

</style>
