<!--
  @description: 评标委员会-请假弹框
  @Modifier：yf
  @routerPath:
  @date：  2020-08-12 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">
      <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.reasonInstructions"
                :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="submitReason">确认</el-button>
      <el-button @click="close">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
// api
import { leaveProcurementExpertdrawOffForChange } from '@api/procurement/procurementEvaluation'
export default {
  name: 'LeaveDialog',
  mixins: [],
  props: {
    dialogData: {
      type: Object,
      default: function() {
        return {
          dialog: false, // false 关闭弹框  true 打开弹框
          id: ''
        }
      }
    }
  },
  data() {
    return {
      formData: {
        reasonInstructions: '' // 原因说明
      },
      rules: {
        reasonInstructions: [
          { required: true, message: '请输入', trigger: 'blur' }
        ] // 原因说明
      }
    }
  },
  created() {
  },
  methods: {
    // 编辑/查看
    getEditOrView() {
      // 根据id查询原因，存在查看
    },
    // 组装数据
    assestData() {
      const data =
       {
         leaveReason: '', // 请假原因
         id: this.dialogData.id
       }
      return data
    },
    // 确认请假
    submitReason() {
      this.$refs.form.validate(valid => {
        if (valid) {
          const data = this.assestData()
          leaveProcurementExpertdrawOffForChange(data).then(res => {
            this.$message({ message: '操作成功', type: 'success' })
            this.$emit('reload')
          })
          this.dialogData.dialog = false // 关闭弹框
        }
      })
    },
    // 关闭弹框
    close() {
      this.dialogData.dialog = false
    }
  }
}
</script>

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