| | |
| | | <div style="padding-bottom:20px"> |
| | | <span class="item">{{ this.$route.query.className }}</span> |
| | | <el-button class="item" @click="handlerAddStudent" type="primary" size="small">新增学员</el-button> |
| | | <el-button class="item" @click="open = true" type="primary" size="small">学员调整</el-button> |
| | | <el-button class="item" @click="openManage" type="primary" size="small">学员调整</el-button> |
| | | </div> |
| | | <div> |
| | | <el-form :inline="true" :model="searchForm" class="demo-form-inline"> |
| | |
| | | label="电话" |
| | | > |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="操作" |
| | | align="center" |
| | | width="300px" |
| | | > |
| | | <template slot-scope="scope"> |
| | | <el-button @click="handlerEditStudent(scope.row)" type="warning" size="small">编辑</el-button> |
| | | <el-popconfirm |
| | | style="margin: 0 5px" |
| | | title="确定要删除该成员吗?" |
| | | @confirm="remove(scope.row.id)" |
| | | > |
| | | <el-button slot="reference" type="danger" size="small" v-show="false">删除</el-button> |
| | | </el-popconfirm> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <div |
| | | class="block" |
| | |
| | | :before-close="handleAddClose" |
| | | :close-on-click-modal="false"> |
| | | <el-form :model="studentForm" :rules="studentRules" ref="studentForm" label-width="100px" class="demo-ruleForm"> |
| | | <el-form-item label="真实姓名:" prop="realName" required> |
| | | <el-form-item label="真实姓名:" prop="realName"> |
| | | <el-input v-model="studentForm.realName"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="手机号码:" prop="phone" required> |
| | | <el-form-item label="手机号码:" prop="phone"> |
| | | <el-input v-model="studentForm.phone"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="登录账号:" prop="userName" required> |
| | | <el-form-item label="登录账号:" prop="userName"> |
| | | <el-input v-model="studentForm.userName" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item v-if="!studentForm.id" label="登录密码:" prop="password" required> |
| | | <el-form-item v-if="!studentForm.id" label="登录密码:" prop="password"> |
| | | <el-input v-model="studentForm.password" show-password autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="年龄:"> |
| | |
| | | <el-date-picker v-model="studentForm.birthDay" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"/> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="状态:" required> |
| | | <el-form-item label="状态:"> |
| | | <el-select v-model="studentForm.status" placeholder="状态"> |
| | | <el-option v-for="item in statusEnum" :key="item.key" :value="item.key" :label="item.value"></el-option> |
| | | </el-select> |
| | |
| | | export default { |
| | | components: { Pagination }, |
| | | data () { |
| | | var validatePassword = (rule, value, callback) => { |
| | | if (value === '') { |
| | | callback(new Error('请输入登录密码')) |
| | | } else if (!/[A-Z]/.test(value)) { |
| | | callback(new Error('密码必须包含至少一个大写字母')) |
| | | } else if (!/[a-z]/.test(value)) { |
| | | callback(new Error('密码必须包含至少一个小写字母')) |
| | | } else if (!/[0-9]/.test(value)) { |
| | | callback(new Error('密码必须包含至少一个数字')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | var validatePhone = (rule, value, callback) => { |
| | | // 手机号和座机号验证逻辑 |
| | | const phoneRegex = /^1[3-9]\d{9}$/; // 手机号格式 |
| | | const landlineRegex = /^\d{3,4}-?\d{7,8}$/; // 座机号格式,可以包含区号和可选的连字符 |
| | | |
| | | if (!value) { |
| | | callback(new Error('请输入手机号或座机号')); |
| | | } else if (!phoneRegex.test(value)) { |
| | | if (!landlineRegex.test(value)){ |
| | | callback(new Error('手机号或座机号格式不正确')); |
| | | } |
| | | } else { |
| | | callback(); |
| | | } |
| | | } |
| | | return { |
| | | studentForm: { |
| | | id: null, |
| | |
| | | password: '' |
| | | }, |
| | | studentRules: { |
| | | realName: [ |
| | | { required: true, message: '请填写学员姓名', trigger: 'blur' } |
| | | userName: [ |
| | | { required: true, message: '请输入登录账号', trigger: 'blur' } |
| | | ], |
| | | sex: [ |
| | | { required: true, message: '请选择学员性别', trigger: 'change' } |
| | | realName: [ |
| | | { required: true, message: '请输入真实姓名', trigger: 'blur' } |
| | | ], |
| | | password: [ |
| | | { validator: validatePassword, trigger: 'blur' } |
| | | ], |
| | | phone: [ |
| | | { required: true, message: '请填写学员电话', trigger: 'blur' } |
| | | ], |
| | | userName: [ |
| | | { required: true, message: '请填写学员登录账号', trigger: 'blur' } |
| | | { validator: validatePhone, trigger: 'blur' } |
| | | ] |
| | | }, |
| | | studentTitle: '新增学员', |
| | |
| | | this.getStudentList() |
| | | }, |
| | | methods: { |
| | | openManage () { |
| | | this.getClassesCurrentUserList(this.classes.id) |
| | | this.open = true |
| | | }, |
| | | handlerEditStudent (row) { |
| | | this.studentForm = row |
| | | this.studentTitle = '编辑学员' |
| | |
| | | console.log(this.studentForm) |
| | | if (valid) { |
| | | this.studentForm.classesId = this.classes.id |
| | | if (this.studentForm.id) { |
| | | editClassesUser(this.studentForm).then(res => { |
| | | this.addOpen = false |
| | | this.$message.success(res.data.message) |
| | | this.submitForm() |
| | | this.page() |
| | | this.resetStudentForm() |
| | | }) |
| | | window.location.reload() |
| | | } else { |
| | | addClassesUser(this.studentForm).then(res => { |
| | | this.addOpen = false |
| | | this.$message.success(res.data.message) |
| | | this.page() |
| | | this.resetStudentForm() |
| | | }) |
| | | window.location.reload() |
| | | } |
| | | addClassesUser(this.studentForm).then(res => { |
| | | this.addOpen = false |
| | | this.$message.success(res.data.message) |
| | | this.page() |
| | | this.resetStudentForm() |
| | | }) |
| | | } |
| | | }) |
| | | }, |