<template>
  <div class="auditing-tow">
    <cy-up-down-drag>
      <div slot="top">
        <supplier-manage-view></supplier-manage-view>
      </div>
      <div slot="bar">
        <div>
          供应商审核第二步
        </div>
      </div>
      <div slot="bottom">
        <auditing-two-main ref="auditingtwoMain" />
        <div class="submit-btn">
          <el-button @click="$router.go(-1)">关闭</el-button>
          <el-button type="primary" @click="submitForm('temp')">暂存</el-button>
          <el-button type="primary" @click="submitForm('submit')">提交</el-button>
        </div>
      </div>
    </cy-up-down-drag>
  </div>
</template>

<script>
import { secondReviewSubmit } from '@/api/creditManage/supplierManage'
export default {
  name: 'SupplierAuditing',
  components: {
    auditingTwoMain: () => import('./auditingTwoMain.vue'),
    SupplierManageView: () => import('../components/SupplierManageView.vue')
  },
  methods: {
    async submitForm(type) {
      const params = await this.$refs.auditingtwoMain.getSubmit(type)
      if (!params) {
        return
      }
      const { taskId } = this.$route.query

      const paramsObj = {
        Loading: true,
        taskId,
        ...params,
        visible: type === 'submit'
      }
      secondReviewSubmit(paramsObj).then(() => {
        this.$message.success(`${type === 'temp' ? '暂存成功' : '提交成功'}`)
        this.$router.push({
          name: 'SupplierManage'
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
