<template>
  <div class="offline-due-diligence">
    <cy-info-title>尽调预约</cy-info-title>
    <due-diligence ref="dueDiligence" type="offine" :due-info="dueInfo" />
    <div class="submit-btn">
      <el-button @click="$router.go(-1)">关闭</el-button>
      <el-button type="primary" @click="submitClick">提交</el-button>
    </div>
  </div>
</template>

<script>
import { getOfflineDueInfo, submitOfflineDueInfo } from '@/api/myBusiness/dueDiligence'
export default {
  name: 'MyBusinessOfflineDueDiligence',
  components: {
    DueDiligence: () => import('../components/DueDiligence')
  },
  data() {
    return {
      dueInfo: {}
    }
  },
  created() {
    this.getOffline()
  },
  methods: {
    getOffline() {
      const { id } = this.$route.query
      getOfflineDueInfo({ id }).then(({ data }) => {
        this.dueInfo = data
      })
    },
    submitClick() {
      this.$refs.dueDiligence.validate().then((data) => {
        const { id } = this.$route.query
        const params = {
          Loading: true,
          supplierInfoId: id,
          ...data
        }
        submitOfflineDueInfo(params).then(() => {
          this.$router.go(-1)
        })
      })
    }
  }
}
</script>

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

}
</style>
