<!--
  @description: 评标大厅-专家回避-弹框
  @Modifier：yf/wxy
  @routerPath:
  @date：  2020-08-4 10:00:28
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialogData.dialog"
    :close-on-click-modal="false"
    :lock-scroll="false"
    :before-close="close"
    title="专家回避"
    width="600px"
    custom-class="el-dialog__body-p8 el-dialog_table"
  >
    <div class="main mb10">
      <div style="width:100%;height:30px">
        <el-tag type="warning">
          <img style="width:15px;height:15px;margin-right:10px;" src="@assets/img/procurement/procurementEvaluation/Prompt.png" alt="提示：">
          确认回避，默认您自动放弃评标！
        </el-tag>
      </div>
      <el-form
        ref="form"
        :model="formData"
        :rules="rules"
        :inline-message="true"
      >
        <table class="from_table">
          <tr>
            <td>
              <el-form-item label="回避说明" prop="avoidanceInstructions" />
            </td>
            <td>
              <el-input
                v-model.trim="formData.avoidanceInstructions"
                :autosize="{ minRows: 4, maxRows: 4 }"
                type="textarea"
                maxlength="1000"
                show-word-limit
                style="width: 90%"
              />
            </td>
          </tr>
        </table>
      </el-form>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitAvoidance">确认</el-button>
      <el-button @click="close">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
// 公共校验方法
import { characters1_auto } from '@/assets/js/validate'// 校验输入内容
// api
import { saveProtProjectProcurementEvalExpertSignIn } from '@api/procurement/procurementEvaluation'
export default {
  name: 'AvoidanceDialog',
  mixins: [],
  props: {
    dialogData: {
      type: Object,
      default: function() {
        return {
          avoidanceLoading: false,
          dialog: false // false 关闭弹框  true 打开弹框
        }
      }
    },
    getTenderBase: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  data() {
    return {
      formData: {
        avoidanceInstructions: '' // 回避说明
      },
      rules: {
        avoidanceInstructions: [
          { required: true, validator: characters1_auto, trigger: 'blur' }
        ] // 回避说明
      }
    }
  },
  created() {
  },
  methods: {
    // 组装数据
    assestData() {
      const data =
       {
         avoidReason: '', // 回避原因
         isEvaded: '', // 是否回避 00 同意  01 回避
         ...this.getTenderBase // getTenderBase参数
       }
      return data
    },
    // 确认回避
    submitAvoidance() {
      this.$refs.form.validate(valid => {
        if (valid) {
          const data = this.assestData()
          data.avoidReason = this.formData.avoidanceInstructions
          data.isEvaded = '01' // 01 回避  00 不回避
          saveProtProjectProcurementEvalExpertSignIn(data).then(res => {
            this.$message({ message: '操作成功', type: 'success' })
            this.$emit('avoidanceStatus')
            this.dialogData.dialog = false // 关闭弹框
            this.dialogData.avoidanceLoading = false
          })
        }
      })
    },
    // 关闭弹框
    close() {
      this.dialogData.dialog = false
      this.dialogData.avoidanceLoading = false
    }
  }
}
</script>

<style scoped lang="less">
/deep/.el-tag.el-tag--warning{
  width: 100%;
}
</style>
