<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"></el-input>
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input v-model="ruleForm.phone"></el-input>
      </el-form-item>
      <el-form-item label="身份证号" prop="codeId">
        <el-input v-model="ruleForm.codeId"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="pws">
        <el-input v-model="ruleForm.pws"></el-input>
      </el-form-item>
      <el-form-item label="确认密码" prop="qpws">
        <el-input v-model="ruleForm.qpws"></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>
