<template>
  <div class="time-confirm">
    <cy-up-down-drag>
      <div slot="top">
        <supplier-manage-view></supplier-manage-view>
      </div>
      <div slot="bar">
        <div>
          尽调时间确认
        </div>
      </div>
      <div slot="bottom">
        <time-confirm-content ref="timeConfirmContent" :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 { getDueDiligenceConfirm, dueConfirmSubmit } from '@/api/creditManage/supplierManage'
export default {
  name: 'TimeConfirm',
  components: {
    TimeConfirmContent: () => import('./components/TimeConfirmContent'),
    SupplierManageView: () => import('./components/SupplierManageView.vue')
  },
  data() {
    return {
      detailsInfo: {}
    }
  },  
  created() {
    this.getDetails()
  },
  methods: {
    getDetails() {
      const { id } = this.$route.params
      getDueDiligenceConfirm({ supplierId: id }).then(({ data }) => {
        this.detailsInfo = data
      })
    },
    async submitForm() {
      const params = await this.$refs.timeConfirmContent.getParams()
      const { id } = this.$route.params
      const { taskId } = this.$route.query
      dueConfirmSubmit({ Loading: true, cSupplierInfoId: id, taskId, ...params }).then(() => {
        this.$message.success('提交成功')
        this.$router.go(-1)
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
