<template>
  <el-dialog title="OA发送" width="50%" :visible.sync="visible" v-dialogDrag :close-on-click-modal="false"
    :before-close="cancel">
    <div class="dia-box">
      <el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px">
        <el-form-item label="门类类型" prop="classType">
            <el-input v-model="form.classType" clearable placeholder="请输入门类类型"></el-input>
        </el-form-item>
        <el-form-item label="表名" prop="fileName">
            <el-input v-model="form.fileName" clearable placeholder="请输入表名"></el-input>
        </el-form-item>
        <el-form-item label="文件路径" prop="receiveFileString">
            <el-input v-model="form.receiveFileString" clearable placeholder="请输入文件路径"></el-input>
        </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>
    </div>
  </el-dialog>
</template>
<script>

  export default {
    props: {
      visible: {
        type: Boolean,
        default: () => false
      },
    },
    data() {
      return {
         loading: false,
         form:{
            classType: '',
            fileName: '',
            receiveFileString: '',
         },
         rules: {
            classType: [
                { required: true, message: '请输入门类类型', trigger: 'blur' },
            ],
            fileName: [
                { required: true, message: '请输入表名', trigger: 'blur' },
            ],
            receiveFileString: [
                { required: true, message: '请输入文件路径', trigger: 'blur' },
            ],
         }
      };
    },
    methods: {
      cancel() {
        this.$emit("cancel");
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$emit('onSubmit', this.form)
          } else {
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  };

</script>
