<template>
  <el-dialog v-dialogDrag ref="diaFrom" title="文件名批量挂接" :close-on-click-modal="false" :visible.sync="visible"
    width="45%"  :before-close="cancel">
    <div class="diaBox">
      <el-form ref="form" size="mini" :model="form" :rules="rules" label-suffix="：" label-width="100px">
          <el-form-item label="档案门类" prop="mode">
            <el-select v-model="form.mode" clearable placeholder="请选择档案门类">
              <el-option v-for="item in modeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="处理方式" prop="type">
            <el-radio-group v-model="form.type" size="mini">
              <el-radio border :label="1">覆盖</el-radio>
              <el-radio border :label="2">追加</el-radio>
            </el-radio-group>
          </el-form-item> -->
          <el-form-item label="原文路径" prop="localPath">
            <el-input v-model.trim="form.localPath" placeholder="D:\demo"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="mini" @click="submit('form')">
              开始挂接
            </el-button>
          </el-form-item>
        </el-form>
    </div>
  </el-dialog>
</template>
<script>
  import { message } from "@/utils/common";
  export default {
    props: {
      visible: {
        type: Boolean,
        default: () => false,
      },
    },
    data() {
      return {
        modeList: [
          { label:'文书档案', value: 1 },
          { label:'声像档案', value: 2 },
          { label:'会计档案', value: 3 },
          { label:'实物档案', value: 4 },
          { label:'科技档案', value: 5 },
          { label:'电子档案', value: 6 },
          { label:'专业档案', value: 7 },
        ],
        form: {
          mode: '',
          // type: 1,
          localPath: ''
        },
        rules: {
          mode: [
            { required: true, message: '请选择档案门类', trigger: 'change' }
          ],
          /* type: [
            { required: true, message: '请输入处理方式', trigger: 'blur' },
          ], */
          localPath: [
            { required: true, message: '请输入文件夹全路径', trigger: 'change' }
          ],
        }
      }
    },
    methods: {
      cancel() {
        this.$refs.form.resetFields()
        this.$emit("cancel")
      },
      submit(formName){
        this.$refs[formName].validate(valid => {
          if (valid) {
            this.$emit("submit", this.form);
          } else {
            return false;
          }
        });
      }
    },
  }

</script>
<style lang="scss" scoped>

</style>
