系统设置修改正则方式

dev_2022-05-11
e 3 years ago
parent 4a0fc3801a
commit da1557e34f
  1. 14
      src/pages/student/list/index.vue
  2. 40
      src/pages/system/list/staff.vue

@ -151,7 +151,7 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item prop="workNumber" label="学生学号"> <el-form-item prop="workNumber" label="学生学号">
<el-input v-model="form.workNumber" placeholder="" @blur="worknumberChange"></el-input> <el-input v-model="form.workNumber" placeholder="学生学号"></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>
@ -266,7 +266,8 @@ export default {
} else { } else {
var pattern = /^[A-Za-z0-9]*$/; var pattern = /^[A-Za-z0-9]*$/;
if(pattern.test(value)){ if(pattern.test(value)){
this.accountChange() this.accountChange();
callback();
}else{ }else{
callback(new Error('请输入正确账号格式')); callback(new Error('请输入正确账号格式'));
} }
@ -278,7 +279,8 @@ export default {
} else { } else {
var pattern = /^[A-Za-z0-9]*$/; var pattern = /^[A-Za-z0-9]*$/;
if(pattern.test(value)){ if(pattern.test(value)){
this.worknumberChange() this.worknumberChange();
callback();
}else{ }else{
callback(new Error('请输入正确学生学号格式')); callback(new Error('请输入正确学生学号格式'));
} }
@ -759,11 +761,11 @@ export default {
if (this.isAdd) { if (this.isAdd) {
this.showTree = false; this.showTree = false;
this.$post(`${this.api.getDetailByAccount}?workNumber=${this.form.workNumber}&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.showTree = true;
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();
delete this.form.classList; delete this.form.classList;
this.showTree = true; // this.showTree = true;
this.accountReapeat = false; this.accountReapeat = false;
this.$refs.form.clearValidate(); this.$refs.form.clearValidate();
}).catch(res => {}); }).catch(res => {});
@ -774,6 +776,7 @@ export default {
} }
}, },
worknumberChange() { worknumberChange() {
console.log(this.form)
if (this.form.workNumber) { if (this.form.workNumber) {
let url = ""; let url = "";
if (this.isAdd && !this.form.accountId) { if (this.isAdd && !this.form.accountId) {
@ -782,6 +785,7 @@ export default {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&accountId=${this.form.accountId}&workNumber=${this.form.workNumber}&account=`; url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&accountId=${this.form.accountId}&workNumber=${this.form.workNumber}&account=`;
} }
this.$post(url).then(res => { this.$post(url).then(res => {
console.log(res)
if (res.status === 200) { if (res.status === 200) {
this.workNumberReapeat = false; this.workNumberReapeat = false;
} }

@ -47,7 +47,7 @@
width="30%" @close="closeTeacher" class="dialog" :close-on-click-modal="false"> width="30%" @close="closeTeacher" class="dialog" :close-on-click-modal="false">
<el-form ref="teacherForm" :model="teacherForm" :rules="rules" label-width="140px" :disabled="isDetail"> <el-form ref="teacherForm" :model="teacherForm" :rules="rules" label-width="140px" :disabled="isDetail">
<el-form-item prop="account" label="账号"> <el-form-item prop="account" label="账号">
<el-input v-model.trim="teacherForm.account" placeholder="请输入职工账号" @blur="accountChange"></el-input> <el-input v-model.trim="teacherForm.account" placeholder="请输入职工账号"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="userName" label="用户姓名"> <el-form-item prop="userName" label="用户姓名">
<el-input v-model.trim="teacherForm.userName" placeholder="请输入员工姓名"></el-input> <el-input v-model.trim="teacherForm.userName" placeholder="请输入员工姓名"></el-input>
@ -66,7 +66,7 @@
<el-input disabled v-model.trim="teacherForm.uniqueIdentification" placeholder="请输入职工工号获取唯一标识"></el-input> <el-input disabled v-model.trim="teacherForm.uniqueIdentification" placeholder="请输入职工工号获取唯一标识"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="workNumber" label="工号"> <el-form-item prop="workNumber" label="工号">
<el-input v-model.trim="teacherForm.workNumber" placeholder="请输入职工工号" @blur="workNumberChange"></el-input> <el-input v-model.trim="teacherForm.workNumber" placeholder="请输入职工工号"></el-input>
</el-form-item> </el-form-item>
<template v-for="item in teacherForm.roleAndDeptList"> <template v-for="item in teacherForm.roleAndDeptList">
<el-form-item :label="`${item.roleName}所属部门`"> <el-form-item :label="`${item.roleName}所属部门`">
@ -127,6 +127,32 @@ import TeacherSide from "./staffSide";
export default { export default {
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();
callback();
}else{
callback(new Error('请输入正确账号格式'));
}
}
};
var workNumberPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入职工工号'));
} else {
var pattern = /^[0-9]*$/;
if(pattern.test(value)){
this.workNumberChange();
callback();
}else{
callback(new Error('职工工号必须为数字'));
}
}
};
return { return {
exportCode: "", exportCode: "",
headers: { headers: {
@ -150,12 +176,7 @@ export default {
}, },
rules: { rules: {
account: [ account: [
{ required: true, message: "请输入职工账号", trigger: "blur" }, { validator: accountPass, trigger: 'blur' }
{
pattern: /^[A-Za-z0-9]*$/,
message: "请输入正确的账号",
trigger: "blur"
}
], ],
userName: [ userName: [
{ required: true, message: "请输入用户姓名", trigger: "blur" } { required: true, message: "请输入用户姓名", trigger: "blur" }
@ -164,8 +185,7 @@ export default {
{ required: true, message: "请选择账号角色", trigger: "change" } { required: true, message: "请选择账号角色", trigger: "change" }
], ],
workNumber: [ workNumber: [
{ required: true, message: "请输入职工工号", trigger: "blur" }, { validator: workNumberPass , trigger: 'blur' }
// { pattern: /^[0-9]*$/, message: "", trigger: "blur"}
], ],
uniqueIdentification: [ uniqueIdentification: [
// { required: true, message: '', trigger: 'blur' }, // { required: true, message: '', trigger: 'blur' },

Loading…
Cancel
Save