<template>
  <div class="reg-form-box">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm forms">
      <el-form-item label="学校" prop="region">
        <el-select v-model="ruleForm.region" placeholder="请选择学校" class="width100">
          <el-option label="学校一" value="shanghai"></el-option>
          <el-option label="学校二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="姓名" prop="name">
        <el-input v-model="ruleForm.name" placeholder="请输入您的姓名"></el-input>
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input v-model="ruleForm.phone" placeholder="请输入您的手机号"></el-input>
      </el-form-item>
      <el-form-item label="身份证号" prop="codeId">
        <el-input v-model="ruleForm.codeId" placeholder="请输入您的身份证号"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="pws">
        <el-input v-model="ruleForm.pws" placeholder="请输入您的密码"></el-input>
      </el-form-item>
      <el-form-item label="确认密码" prop="qpws">
        <el-input v-model="ruleForm.qpws" placeholder="请输入您的密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')" class="sub-btn">立即创建</el-button>
        <!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        ruleForm: {
          name: '',
          region: '',
          phone: '',
          codeId: '',
          delivery: false,
          type: [],
          pws: '',
          qpws: ''
        },
        rules: {
          name: [
            { required: true, message: '请输入姓名', trigger: 'blur' }
            // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          region: [
            { required: true, message: '请选择学校', trigger: 'change' }
          ],
          phone: [
            { required: true, message: '请输入手机号', trigger: 'blur' }
          ],
          codeId: [
            { required: true, message: '请输入身份证号', trigger: 'blur' }
          ],
          pws: [
            { required: true, message: '请输入密码', trigger: 'blur' }
          ],
          qpws: [
            { required: true, message: '请输入密码', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>
<style lang="scss" scoped>
.reg-form-box{
  width: 380px;
  margin: 0 auto;
  padding: 24px 0;
  .width100{
    width: 100%;
  }
}
::v-deep{
  .forms{
    i {
      font-size: 20px;
    }
    input{
      border-radius: 4px;
    }
  }
}
.sub-btn{
  width: 270px;
  height: 40px;
  background: linear-gradient(315deg, rgba(225, 47, 116, 0.83) 0%, #C01540 100%);
  border-radius: 4px;
}
</style>
