<template>
  <div class="disburse-approval">
    <cy-up-down-drag>
      <div slot="top">
        <financing-view-content />
      </div>
      <div slot="bar">
        <div>
          支用审核
        </div>
      </div>
      <div slot="bottom">
        <disburse-approval-content ref="disburseApproval" :details-info="detailsInfo" />
        <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 { reviewQuotaDisburseApprovalDetails, reviewQuotaDisburseApprovalSubmit } from '@/api/financingManage'
export default {
  name: 'DisburseApproval',
  components: {
    DisburseApprovalContent: () => import('./components/DisburseApprovalContent'),
    FinancingViewContent: () => import('./components/FinancingViewContent.vue')
  },
  data() {
    return {
      detailsInfo: {}
    }
  },
  created() {
    this.getDetails()
  },
  methods: {
    getDetails() {
      const { id } = this.$route.params

      reviewQuotaDisburseApprovalDetails({ id }).then(({ data }) => {
        this.detailsInfo = data
      })
    },
    async onSubmit() {
      const { taskId } = this.$route.query
      const data = await this.$refs.disburseApproval.getParams()
      const params = {
        Loading: true,
        ...this.detailsInfo,
        ...data,
        taskId,
        visible: true
      }
      reviewQuotaDisburseApprovalSubmit(params).then(() => {
        this.$message.success('提交成功')
        this.$router.go(-1)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.disburse-approval {
  height: calc(100vh - 250px);
}
</style>
