<template>
  <el-dialog title="选择Excel字段" :visible.sync="visible" width="30%" v-dialogDrag :close-on-click-modal="false"
    :modal="false" :before-close="cancel">
    <div class="dia-box">
      <el-form :model="form" :rules="rules" ref="ruleForm" label-width="110px">
        <el-form-item label="源表字段" prop="columnChnName">
          <el-input v-model="form.columnChnName" :disabled="true" style="width:200px"></el-input>
        </el-form-item>
        <el-form-item label="Excel表字段" prop="columnExcel">
          <el-select v-model="form.columnExcel" clearable placeholder="请选择">
            <el-option v-for="(item,key) in excelData" :label="item" :value="item" :key="key"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="mini" @click="submitForm('ruleForm')">
            保存
          </el-button>
          <el-button size="mini" @click="revoke">撤销</el-button>
        </el-form-item>
      </el-form>
    </div>
  </el-dialog>
</template>

<script>
import { dateFormat } from "@/utils/common";
export default {
  name: "DiaApply",
  props: {
    visible: {
      type: Boolean,
      default: () => false,
    },
    excelData: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      form: {
        applyUserName: "",
        applyTime: "",
        rec_nums: 0,
        originalTextNums: 0,
        applyReason: "",
      },
      rules: {
        columnExcel: [
          {
            required: true,
            message: "请选择Excel表字段",
            trigger: "change",
          },
        ],
      },
    };
  },
  methods: {
    cancel() {
      this.$refs.ruleForm.resetFields();
      this.$emit("cancel");
    },
    revoke() {
      // this.cancel();
      this.$emit("revoke", this.form);
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit("submit", this.form);
        } else {
          return false;
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .v-modal {
  z-index: 0 !important;
}
</style>