<template>
  <!-- Form -->
  <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="分区名称" prop="name">
        <el-input v-model="ruleForm.name"></el-input>
      </el-form-item>
      <el-form-item label="分区ID" prop="id">
        <el-input v-model="ruleForm.id"></el-input>
      </el-form-item>
      <el-form-item style="float: right;margin-top: 20px">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitForm('ruleForm')">添 加</el-button>
      </el-form-item>

      <!--    <div slot="footer" class="dialog-footer">-->
      <!--      <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>-->
      <!--    </div>-->
    </el-form>
  </el-dialog>
</template>

<script>
  export default {
    name: "dialogZone",
    data() {
      return {
        dialogFormVisible: false,
        ruleForm: {
          name: '',
          id: ''

        },
        rules: {
          name: [
            {required: true, message: '请输入分区名称', trigger: 'blur'},
            // {min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'}
          ],
          id: [
            {required: true, message: '请输入分区ID', trigger: 'blur'},
          ],
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.dialogFormVisible = false
            this.ruleForm.name = ''
            this.ruleForm.id = ''
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
    }
  }
</script>

<style scoped>

</style>
