<template>
  <div class="due-distribution">
    <cy-up-down-drag>
      <div slot="top">
        <supplier-manage-view></supplier-manage-view>
      </div>
      <div slot="bar">
        <div>
          尽调分配
        </div>
      </div>
      <div slot="bottom">
        <due-distribution-content ref="dueDistributionContent" :details-info="detailsInfo" />
        <div class="submit-btn">
          <el-button @click="$router.go(-1)">取消</el-button>
          <el-button type="primary" @click="submitForm">提交</el-button>
        </div>
      </div>
    </cy-up-down-drag>
  </div>
</template>

<script>
import { getDueInfo, dueSubmit } from '@/api/creditManage/supplierManage'
export default {
  name: 'DueDistribution',
  components: {
    DueDistributionContent: () => import('./components/DueDistributionContent'),
    SupplierManageView: () => import('./components/SupplierManageView.vue')
  },
  data() {
    return {
      detailsInfo: {}
    }
  },
  created() {
    this.getDetails()
  },
  methods: {
    getDetails() {
      const { id } = this.$route.params
      getDueInfo({ id }).then(({ data }) => {
        this.detailsInfo = data
      })
    },
    submitForm() {
      this.$refs.dueDistributionContent.validate().then((data) => {
        const { taskId } = this.$route.query
        const params = {
          Loading: true,
          ...data,
          taskId
        }
        dueSubmit(params).then(() => {
          this.$message.success('提交成功')
          this.$router.go(-1)
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.due-distribution {

}
</style>
