<template>
  <div class="prequalification">
    <cy-up-down-drag>
      <div slot="top">
        <sales-contract-management-view></sales-contract-management-view>
      </div>
      <div slot="bar">
        <div>
          模板审核
        </div>
      </div>
      <div slot="bottom">
        <div class="tempalte-content" style="min-height: auto; padding: 0px 20px ">
          <prequalification-content ref="prequalificationContent" />
          <div class="submit-btn">
            <el-button type="primary" style="width: 150px;" @click="onSubmit">确定</el-button>
            <el-button style="width: 150px;" @click="() => { $router.go(-1) }">取消</el-button>
          </div>
        </div>
      </div>
    </cy-up-down-drag>
  </div>
</template>

<script setup>
import { firstTemplateApprovalDoAdd, againTemplateApprovalDoAdd, salesContractChangeFirstTemplateDoApproval, salesContractChangeTemplateApproval } from '@/api/salesContractManagement/salesContractManagement'
import PrequalificationContent from './components/PrequalificationContent.vue'
import salesContractManagementView from './components/salesContractManagementView.vue'
export default {
  name: 'BiddingManagementTemplateReview',
  components: {
    PrequalificationContent,
    salesContractManagementView
  },
  data() {
    return {

    }
  },
  methods: {
    onSubmit() {
      this.$refs.prequalificationContent.getParams().then(data => {
        const params = {
          Loading: true,
          ...data
        }
        const { taskName, id } = this.$route.query
        if (taskName === '模板初审') {
          firstTemplateApprovalDoAdd(params).then(() => {
            this.$message.success('模板初审成功')
            this.$router.push({ name: 'SalesContractManagement' })
          })
        }
        if (taskName === '变更初审') {
          params.businessKey = id
          salesContractChangeFirstTemplateDoApproval(params).then(() => {
            this.$message.success('变更初审成功')
            this.$router.push({ name: 'SalesContractManagement' })
          })
        }
        if (taskName === '模板复审') {
          delete params.approvalConditions
          againTemplateApprovalDoAdd(params).then(() => {
            this.$message.success('模板复审成功')
            this.$router.push({ name: 'SalesContractManagement' })
          })
        }
        if (taskName === '变更复审') {
          delete params.approvalConditions
          params.cSalesContractManagementId = id
          salesContractChangeTemplateApproval(params).then(() => {
            this.$message.success('变更复审成功')
            this.$router.push({ name: 'SalesContractManagement' })
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  /* .template-examine .submit-btn {
    position: absolute;
    bottom: 40px;
    right: 40px;
  } */
</style>

