<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      width="50%"
    >
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="160px" class="demo-ruleForm">
        <el-form-item label="理由" prop="removeOpinion">
          <el-input v-model="ruleForm.removeOpinion" type="textarea" placeholder="请输入理由" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')">确定</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { expelledAuditSave } from '@/api/除名公告.js'
export default {
  data() {
    return {
      noticeBizId: '',
      title: '',
      id: '',
      dialogVisible: false,
      ruleForm: {
        removeOpinion: ''
      },
      entList: [],
      rules: {
        removeOpinion: [
          { required: true, message: '请输入理由', trigger: 'blur' }
        ]
      }
    }
  },
  created() {

  },
  mounted() {},
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const submitForm = {
            ...this.ruleForm,
            id: this.id,
            isRemove: this.title === '同意除名' ? '1' : '0'
          }
          expelledAuditSave(submitForm).then(res => {
            if (res.code === 0) {
              this.dialogVisible = false
              this.$message({
                message: this.title + '成功！',
                type: 'success'
              })
              this.$emit('refreshList')
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    },
    openDialog(data) {
      this.dialogVisible = true
      this.title = data.title
      this.id = data.id
    }
  }
}
</script>

<style scoped lang="scss">

</style>
