\  <!--
  @description:供应商-代办任务-批量审核
  @Modifier: 肖文龙
  @routerPath:
  @date: 2020-5-28 11:43:35
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialogData.dialog"
    :close-on-click-modal="false"
    title="审核进度"
    width="500px"
    custom-class="el-dialog__body-p0"
    top="calc((100vh - 240px) / 2)"
  >
    <div class="main mb10">
      <el-input
        v-model="auditInfoParam.auditOpinion"
        :rows="6"
        type="textarea"
        placeholder="请填写审核意见"
        maxlength="4000"
        show-word-limit
      />
    </div>
    <!--底部操作按钮-->
    <span slot="footer" class="dialog-footer">
      <el-button :loading="btnLoding" type="primary" @click="verified('dialog')">
        审核通过
      </el-button>
      <el-button :loading="btnLoding" @click="auditFail('dialog')">
        审核不通过
      </el-button>
    </span>
  </el-dialog>
</template>
<script>
/* api */
import { auditDepartInfo } from '@api/supplier/supplierBaseInfo'
export default {
  name: 'SupplierAuditAll',
  props: {
    dialogData: {
      type: Object,
      default: function() {
        return {
          dialog: false, // 弹框展示状态
          departInfoIds: []// 供应商departInfoId
        }
      }
    }
  },
  data() {
    return {
      btnLoding: false, // 按钮Loding
      // 审核信息参数
      auditInfoParam: {
        auditFlag: '', // 01-审核通过 ||02-审核不通过
        auditOpinion: '', // 审核意见
        ids: []// 供应商departInfoId
      }
    }
  },
  methods: {
    // 操作审核通过不通过调用接口
    auditProject(auditStatus) {
      this.btnLoding = true // 按钮Loding
      this.auditInfoParam.auditFlag = auditStatus
      this.auditInfoParam.ids = this.dialogData.departInfoIds// 供应商departInfoId
      auditDepartInfo(this.auditInfoParam).then(reponse => {
        this.$message({
          type: 'success',
          message: '审核成功'
        })
        this.btnLoding = false // 按钮Loding
        this.$emit('wareHousingauditAuditInfo')// 触发回填函数
        this.dialogData.dialog = false// 关闭弹框
        this.dialogData.departInfoIds = []// 清空id
      }).catch(() => {
        this.btnLoding = false // 按钮Loding
      })
    },
    // 审核通过
    verified() {
      this.$confirm('确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.auditProject('01')
      }).catch(() => {
      })
    },
    // 审核不通过
    auditFail() {
      if (this.auditInfoParam.auditOpinion) {
        this.$confirm('确认提交?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          confirmButtonClass: 'confirmBtn',
          cancelButtonClass: 'cancelBtn',
          type: 'warning'
        }).then(() => {
          this.auditProject('02')
        }).catch(() => {
        })
      } else {
        this.$message({
          type: 'warning',
          message: '请输入审核意见'
        })
      }
    }
  }

}
</script>

<style scoped lang="less">
//
</style>
