<template>
  <div class="guarantee-enterprise">
    <cy-info-title>担保企业信息</cy-info-title>
    <enterprise-inspection ref="enterpriseInspection" />
    <div class="submit-btn">
      <el-button @click="() => { $router.replace({ name: 'MyBusiness' }) }">取消</el-button>
      <el-button type="primary" @click="nextSubmitClick">下一步</el-button>
    </div>
  </div>
</template>

<script>
import { addGuarantee } from '@/api/myBusiness/supplierEnterprise'
export default {
  components: {
    EnterpriseInspection: () => import('../components/EnterpriseInspection.vue')
  },
  methods: {
    nextSubmitClick() {
      this.$refs.enterpriseInspection.validate().then((data) => {
        const params = {
          Loading: true,
          id: this.$route.query.id,
          guaranteeEnterprise: {
            ...data
          }
        }
        addGuarantee(params).then(({ data: { id }}) => {
          this.$router.push({
            name: 'MyBusinessSupplementaryInfo',
            params: { id: 'child' },
            query: {
              id
            }
          })
        })
      })
    }
  }
}

</script>

<style lang="scss" scoped>
.guarantee-enterprise {

}
</style>
