修改账户和学号判断正则方式

dev_2022-05-11
e 3 years ago
parent e10a8d4f66
commit 10eec71947
  1. 61
      src/pages/student/list/index.vue

@ -150,8 +150,8 @@
<el-form ref="form" :model="form" :rules="rules" :disabled="isDetail" label-width="100px"> <el-form ref="form" :model="form" :rules="rules" :disabled="isDetail" label-width="100px">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item prop="account" label="学生账号"> <el-form-item prop="workNumber" label="学生学号">
<el-input v-model="form.account" placeholder="请输入学生账号" @blur="accountChange"></el-input> <el-input v-model="form.workNumber" placeholder="" @blur="worknumberChange"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="userName" label="学生姓名"> <el-form-item prop="userName" label="学生姓名">
<el-input v-model="form.userName" placeholder="请输入学生姓名"></el-input> <el-input v-model="form.userName" placeholder="请输入学生姓名"></el-input>
@ -159,9 +159,10 @@
<el-form-item prop="roleId" label="账号角色"> <el-form-item prop="roleId" label="账号角色">
学生 学生
</el-form-item> </el-form-item>
<el-form-item prop="workNumber" label="学生学号"> <el-form-item prop="account" label="学生账号">
<el-input v-model="form.workNumber" placeholder="" @blur="worknumberChange"></el-input> <el-input v-model="form.account" placeholder="请输入学生账号"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="phone" label="手机号"> <el-form-item prop="phone" label="手机号">
<el-input v-model="form.phone" placeholder="可用于登录平台,以及找回密码" maxlength="11" @blur="phoneChange"></el-input> <el-input v-model="form.phone" placeholder="可用于登录平台,以及找回密码" maxlength="11" @blur="phoneChange"></el-input>
</el-form-item> </el-form-item>
@ -259,6 +260,30 @@ import OrgTree from "@/components/org-tree/src/tree";
export default { export default {
components: { OrgTree }, components: { OrgTree },
data() { data() {
var accountPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入账号'));
} else {
var pattern = /^[A-Za-z0-9]*$/;
if(pattern.test(value)){
this.accountChange()
}else{
callback(new Error('请输入正确账号格式'));
}
}
};
var workNumberPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入学生学号'));
} else {
var pattern = /^[A-Za-z0-9]*$/;
if(pattern.test(value)){
this.worknumberChange()
}else{
callback(new Error('请输入正确学生学号格式'));
}
}
};
let that = this; let that = this;
return { return {
isRemove: false, // isRemove: false, //
@ -319,23 +344,25 @@ export default {
{ required: true, message: "请输入名称", trigger: "blur" } { required: true, message: "请输入名称", trigger: "blur" }
], ],
account: [ account: [
{ required: true, message: "请输入账号", trigger: "blur" }, { validator: accountPass, trigger: 'blur' }
{ // { required: true, message: "", trigger: "blur" },
pattern: /^[A-Za-z0-9]*$/, // {
message: "请输入正确的账号", // pattern: /^[A-Za-z0-9]*$/,
trigger: "blur" // message: "",
} // trigger: "blur"
// }
], ],
userName: [ userName: [
{ required: true, message: "请输入学生姓名", trigger: "blur" } { required: true, message: "请输入学生姓名", trigger: "blur" }
], ],
workNumber: [ workNumber: [
{ required: true, message: "请输入学生学号", trigger: "blur" }, { validator: workNumberPass, trigger: 'blur' }
{ // { required: true, message: "", trigger: "blur" },
pattern: /^[A-Za-z0-9]*$/, // {
message: "请输入正确的学号", // pattern: /^[A-Za-z0-9]*$/,
trigger: "blur" // message: "",
} // trigger: "blur"
// }
], ],
phone: [ phone: [
// { required: true, message: '', trigger: 'blur' }, // { required: true, message: '', trigger: 'blur' },
@ -731,7 +758,7 @@ export default {
}).catch(err => { }).catch(err => {
if (this.isAdd) { if (this.isAdd) {
this.showTree = false; this.showTree = false;
this.$post(`${this.api.getDetailByAccount}?account=${this.form.account}&platformId=${Setting.platformId}&type=1`).then(res => { this.$post(`${this.api.getDetailByAccount}?workNumber=${this.form.workNumber}&platformId=${Setting.platformId}&type=1`).then(res => {
this.form = res.data; this.form = res.data;
let classId = res.data.classList.map(e => e.id); let classId = res.data.classList.map(e => e.id);
this.form.classId = classId.toString(); this.form.classId = classId.toString();

Loading…
Cancel
Save