<!--
  @description:审批-批量审批弹框
  @Modifier：张慢慢
  @date：  2020-11-17- 15:30
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialogData.auditVisible"
    :lock-scroll="false"
    title="批量审核"
    width="500px"
    class="el-dialog__body-p0"
  >
    <div class="main" style="margin-bottom:10px;">
      <el-form ref="formDialog" :model="formData" :inline-message="true">
        <table class="from_table">
          <tr>
            <!--审核意见-->
            <td>
              <el-form-item
                ref="auditNotPassReason"
                label="审核意见"
                prop="auditNotPassReason"
              />
            </td>
            <td>
              <el-input
                v-model="formData.auditNotPassReason"
                :rows="4"
                type="textarea"
                placeholder="请填写审核意见"
                maxlength="200"
                show-word-limit
              />
            </td>
          </tr>
        </table>
      </el-form>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button :loading="confirmLoading" type="primary" @click="verified('01')">审核通过</el-button>
      <el-button :loading="confirmLoading" @click="auditFail('02')">审核不通过</el-button>
    </span>
  </el-dialog>
</template>

<script>
/* 接口*/
import { auditSignupInfo } from '@/api/bidding/biddocfee'
export default {
  name: 'TenderApplyBatchAuditDialog',
  data() {
    return {
      confirmLoading: false,
      // 弹框
      dialogData: {
        auditVisible: false
      },
      // 表单
      formData: {
        auditNotPassReason: '' // 审核意见
      },
      selectData: [] // 需要审核的列表数据
    }
  },
  methods: {
    // 打开弹框
    open(data) {
      this.selectData = data
      this.formData.auditNotPassReason = ''
      this.dialogData.auditVisible = true
    },
    // 操作审核通过不通过调用接口
    handleAuditBulletin(auditStatus) {
      const ids = []
      this.selectData.forEach((v) => {
        ids.push(v.signupId)
      })
      this.formData.auditStatus = auditStatus
      this.formData.signupIds = ids.join(',')
      this.confirmLoading = true// btnLoding
      auditSignupInfo(this.formData).then(reponse => {
        this.$message({
          type: 'success',
          message: '审核成功'
        })
        this.confirmLoading = false// btnLoding
        this.dialogData.auditVisible = false
        this.$emit('batchAuditInfo', true)
      }).catch(() => {
        this.confirmLoading = false// btnLoding
      })
    },
    // 审核通过
    verified() {
      this.handleAuditBulletin('01')
    },
    // 审核不通过
    auditFail() {
      if (this.formData.auditNotPassReason) {
        this.handleAuditBulletin('02')
      } else {
        this.$message({
          type: 'warning',
          message: '请输入审核意见'
        })
      }
    }
  }
}
</script>
