<template>
  <div>
    <el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Titile">
      <el-row :gutter="15">
        <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
          <el-col :span="12">
            <el-row>
              <el-col :span="24">
                <el-form-item label-width="80px" label="学校名称" prop="field102">
                  <el-input v-model="formData.field102" placeholder="请输入学校名称" clearable
                    :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-row>
              <el-col :span="24">
                <el-form-item label-width="80px" label="姓名" prop="field104">
                  <el-input v-model="formData.field104" placeholder="请输入姓名" clearable
                    :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="24">
            <el-row>
              <el-col :span="24">
                <el-form-item label-width="80px" label="联系方式" prop="field106">
                  <el-input v-model="formData.field106" placeholder="请输入联系方式" clearable
                    :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="24">
            <el-form-item label-width="80px" label="资质上传" prop="field107" required>
              <fileUpload :limit="5" v-model="formData.field107" />
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="handelConfirm">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  inheritAttrs: false,
  components: {},
  props: [],
  data() {
    return {
      formData: {
        field102: undefined,
        field104: undefined,
        field106: undefined,
        field107: null,
      },
      rules: {
        field102: [{
          required: true,
          message: '请输入学校名称',
          trigger: 'blur'
        }],
        field104: [{
          required: true,
          message: '请输入姓名',
          trigger: 'blur'
        }],
        field106: [{
          required: true,
          message: '请输入联系方式',
          trigger: 'blur'
        }, {
          pattern: /^1(3|4|5|7|8|9)\d{9}$/,
          message: '请输入正确的联系方式',
          trigger: 'blur'
        }],
      },
      field107Action: 'https://jsonplaceholder.typicode.com/posts/',
      field107fileList: [],
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    onOpen() {},
    onClose() {
      this.$refs['elForm'].resetFields()
    },
    close() {
      this.$emit('update:visible', false)
    },
    handelConfirm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        this.close()
      })
    },
    field107BeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 2
      if (!isRightSize) {
        this.$message.error('文件大小超过 2MB')
      }
      return isRightSize
    },
  }
}

</script>
<style>
.el-upload__tip {
  line-height: 1.2;
}

</style>
