<!--
  @description: 运维-资审通知书审核页面
  @Modifier: 肖文龙
  @routerPath:projectManagement/confirmQualifiedResultAudit-detail
  @date: 2020/1/13-10:33
-->
<template>
  <div>
    <div class="title p0-16 clearfix">
      <!-- 返回 -->
      <div class="title-back pointer" @click="back">
        <i class="iconfont icon-fanhui mr10" />
        {{ noticeTitle }}审核
      </div>
    </div>
    <!--资审通知书详情组件-->
    <zsNoticePdfCom-detail />
    <!--操作按鈕 auditStatus 00待审核-->
    <div v-if="$route.query.auditStatus === '00'" class="but_footer">
      <div class="p0-16">
        <div class="page-title">
          审核意见
        </div>
        <el-form ref="auditInfoParam" :model="auditInfoParam">
          <el-form-item ref="auditReason" prop="auditReason">
            <el-input
              v-model="auditInfoParam.auditReason"
              :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="verified()">
            审核通过
          </el-button>
          <el-button @click="auditFail()">
            审核不通过
          </el-button>
          <el-button @click="back()">
            返 回
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { auditZsNotice } from '@/api/bidding/bidCalibration'
import zsNoticePdfComDetail from '../confirmQualifiedResult/zsNoticePdfCom-detail'
export default {
  name: 'ConfirmQualifiedResultAudit',
  components: {
    'zsNoticePdfCom-detail': zsNoticePdfComDetail
  },

  data() {
    return {
      noticeType: this.$route.meta.noticeType,
      noticeTitle: '', // 资审合格通知书 资审结果通知书
      // 审核信息参数
      auditInfoParam: {
        auditStatus: '', // 01-审核通过 ||02-审核不通过
        auditReason: '', // 审核意见
        noticeId: this.$route.query.noticeId
      }
    }
  },
  created() {
    this.initBulletinType()
  },
  methods: {
    /* 初始化*/
    initBulletinType() {
      if (this.noticeType === '01') {
        this.noticeTitle = '资审合格通知书'
      } else if (this.noticeType === '00') {
        this.noticeTitle = '资审结果通知书'
      }
    },
    // 返回
    back() {
      if (this.noticeType === '01') {
        this.$router.push({
          path: '/projectManagement/confirmQualifiedAudit'
        })
      } else if (this.noticeType === '00') {
        this.$router.push({
          path: '/projectManagement/confirmQualifiedResultAudit'
        })
      }
    },
    // 操作审核通过不通过调用接口
    handleAuditBulletin(auditStatus) {
      this.auditInfoParam.auditStatus = auditStatus
      auditZsNotice(this.auditInfoParam).then(reponse => {
        this.$message({
          type: 'success',
          message: '审核成功'
        })
        this.back()
      }).catch(() => {

      })
    },
    // 审核通过
    verified() {
      this.$confirm('确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.handleAuditBulletin('01')
      }).catch(() => {
      })
    },
    // 审核不通过
    auditFail() {
      if (this.auditInfoParam.auditReason) {
        this.$confirm('确认提交?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          confirmButtonClass: 'confirmBtn',
          cancelButtonClass: 'cancelBtn',
          type: 'warning'
        }).then(() => {
          this.handleAuditBulletin('02')
        }).catch(() => {
        })
      } else {
        this.$message({
          type: 'warning',
          message: '请输入审核意见'
        })
      }
    }
  }
}
</script>

<style lang="less" scoped>

</style>
