<!--
  @description: 审核变更招标公告
  @Modifier: haoFx
  @routerPath:/projectManagement/auditChangeBulletinContent
  @date: 2020/3/12-15:41
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="iconfont icon-fanhui" @click="back" />
      变更采购方式审核
    </div>
    <!--变更采购方式详情组件-->
    <div class="p0-16 mt10">
      <changePurchaseComp :exception-id="auditInfoParam.exceptionId" />
    </div>
    <!--操作按鈕 auditStatus 00待审核-->
    <div v-if="$route.params.auditStatus === '00'" class="but_footer">
      <div class="p0-16">
        <div class="page-title">
          审核意见
        </div>
        <el-form ref="auditInfoParam" :model="auditInfoParam">
          <el-form-item ref="auditNotPassReason" prop="auditNotPassReason">
            <el-input
              v-model="auditInfoParam.auditNotPassReason"
              :rows="4"
              type="textarea"
              placeholder="请填写审核意见"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-form>
      </div>
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button type="primary" @click="audit('01')">
            审核通过
          </el-button>
          <el-button @click="audit('02')">
            审核不通过
          </el-button>
          <el-button @click="back()">
            返 回
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* api */
import { exceptionAudit } from '@/api/bidding/changePurchase'
/* 组件*/
import changePurchaseComp from '../tenderChangePurchase/changePurchaseComp-detail.vue'

export default {
  name: 'AuditBulletinOpinion',
  components: {
    changePurchaseComp
  },
  data() {
    return {
      // 审核信息参数
      auditInfoParam: {
        auditStatus: '', // 是否审核通过 02否 01是
        auditNotPassReason: '', // 审核意见
        exceptionId: this.$route.params.exceptionId
      }
    }
  },
  methods: {
    // 返回
    back() {
      this.$router.push({
        path: '/projectManagement/changePurchaseAudit-list'
      })
    },
    /*
     * 审核
     * auditStatus 02 不通过  01 通过
    */
    audit(auditStatus) {
      if ((auditStatus === '02' && this.auditInfoParam.auditNotPassReason) || auditStatus === '01') {
        this.$confirm('确认提交?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          confirmButtonClass: 'confirmBtn',
          cancelButtonClass: 'cancelBtn',
          type: 'warning'
        }).then(() => {
          this.auditInfoParam.auditStatus = auditStatus
          exceptionAudit(this.auditInfoParam).then(reponse => {
            this.$message({
              type: 'success',
              message: '审核成功'
            })
            this.back()// 返回
          }).catch(() => {

          })
        })
      } else {
        this.$message({
          type: 'warning',
          message: '请输入审核意见'
        })
      }
    }
  }
}
</script>

<style lang="less" scoped>

</style>
