From 897ebcb03d74be1b83c7f4e7f600309e1d59e248 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Tue, 19 Apr 2022 17:08:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=91=98=E5=B7=A5=E7=AD=89?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/station/preview/index.vue | 13 +-- src/pages/student/list/index.vue | 158 +++++++++------------------- src/pages/system/list/staff.vue | 94 +++++++---------- 3 files changed, 92 insertions(+), 173 deletions(-) diff --git a/src/pages/station/preview/index.vue b/src/pages/station/preview/index.vue index 9ce736d..dcb0437 100644 --- a/src/pages/station/preview/index.vue +++ b/src/pages/station/preview/index.vue @@ -296,19 +296,14 @@ export default { let roleId = this.roleId == 4 ? 0 : 1; let userName = window.btoa(encodeURIComponent(this.userName)); if (id == 11) { + // 银行系统 location.href = `${Setting.bankPath}/#/index/list?token=${token}&cid=${this.courseId}&systemId=${this.assessmentList[0].systemId}&projectId=&assessmentId=&classId=&stopTime=&test=true` } else if (id == 21) { window.open(`http://121.37.29.24:80/yyyflogin?userId=${this.userId}&userName=${userName}&userType=${roleId}&reqType=1&reqId=3989a0ad671849b99dcbdcc208782333&caseId=9681f86902314b10bc752909121f9ab9&authorization=87DIVy348Oxzj3ha&classId=1876&courserId=7ff5d4715b114b7398b6f26c20fac460`); } else if (id == 22) { window.open(`https://danbao.czcyedu.com/#/loginFromYyyf?userId=${this.userId}&userName=${userName}&userType=${roleId}&reqType=1&reqId=eb7d8355119d449184c548b07dc01ed9&caseId=1198241070647873538&authorization=87DIVy348Oxzj3ha&classId=1876&courserId=faaedd82adb9444285a5785e4a3dd4f9`); } else { - if(process.env.NODE_ENV === 'development') { - href = 'http://192.168.31.125:8080/#/' - } else { - href = `${location.origin}/pyTrials` // 8个python子系统都跳这个地址,子系统会通过cookie里的systemId识别展示哪套系统 - } - } - if (id != 21 && id != 22 && id != 11) { + // python系统 util.cookies.set("assessmentId", "", -1); util.cookies.set("projectId", "", -1); util.cookies.set("startTime", "", -1); @@ -317,7 +312,9 @@ export default { util.cookies.set("courseId", this.courseId); util.cookies.set("curriculumName", escape(this.curriculumName)); util.cookies.set("systemId", id); - location.href = href; + location.href = process.env.NODE_ENV === 'development' ? + `http://${location.hostname}:8080/#/` : + `${location.origin}/pyTrials` // 8个python子系统都跳这个地址,子系统会通过cookie里的systemId识别展示哪套系统 } } } diff --git a/src/pages/student/list/index.vue b/src/pages/student/list/index.vue index 11fd3c2..2c7d5a4 100644 --- a/src/pages/student/list/index.vue +++ b/src/pages/student/list/index.vue @@ -150,7 +150,7 @@ - + @@ -168,9 +168,6 @@ - @@ -260,27 +257,6 @@ import { mapState } from "vuex"; export default { components: { OrgTree }, data() { - var accountPass = (rule, value, callback) => { - if (value === '') { - callback(new Error('请输入账号')); - } else { - this.accountChange(); - callback(); - } - }; - var workNumberPass = (rule, value, callback) => { - if (value === '') { - callback(new Error('请输入学生学号')); - } else { - var pattern = /^[A-Za-z0-9]*$/; - if(pattern.test(value)){ - this.worknumberChange(); - callback(); - }else{ - callback(new Error('请输入正确学生学号格式')); - } - } - }; let that = this; return { isRemove: false, // 是否可以移除 @@ -331,6 +307,7 @@ export default { treeResolve: [], isDetail: false, keyWord: "", + originForm: {}, form: { userName: "", phone: "", @@ -344,29 +321,18 @@ export default { organizationName: [ { required: true, message: "请输入名称", trigger: "blur" } ], - account: [ - { required: true,validator: accountPass, trigger: 'blur' } - // { required: true, message: "请输入账号", trigger: "blur" }, - // { - // pattern: /^[A-Za-z0-9]*$/, - // message: "请输入正确的账号", - // trigger: "blur" - // } - ], userName: [ { required: true, message: "请输入学生姓名", trigger: "blur" } ], workNumber: [ - { required: true,validator: workNumberPass, trigger: 'blur' } - // { required: true, message: "请输入学生学号", trigger: "blur" }, - // { - // pattern: /^[A-Za-z0-9]*$/, - // message: "请输入正确的学号", - // trigger: "blur" - // } + { required: true, message: "请输入学号", trigger: 'blur' }, + { + pattern: /^[A-Za-z0-9]*$/, + message: "请输入正确的学号", + trigger: "blur" + } ], phone: [ - // { required: true, message: '请输入职工手机号', trigger: 'blur' }, { pattern: /^1[3456789]\d{9}$/, message: "请输入正确的手机号", @@ -374,7 +340,6 @@ export default { } ], email: [ - // { required: true, message: '请输入邮箱', trigger: 'blur' }, { pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/, message: "请输入正确的邮箱", @@ -390,7 +355,6 @@ export default { isAdd: true, studentVisible: false, - accountReapeat: false, workNumberReapeat: false, phoneRepeat: false, emailRepeat: false, @@ -415,9 +379,8 @@ export default { ]) }, mounted() { - console.log(55, this.schoolId) + this.originForm = JSON.parse(JSON.stringify(this.form)) this.getData(); - // this.auth(); }, watch: { keyWord: function(val) { @@ -752,73 +715,41 @@ export default { this.showTree = true; }).catch(res => {}); }, - accountChange() { // 切换账号 - if (this.form.account) { - let url = ""; - if (this.isAdd) { - url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&account=${this.form.account}&workNumber=`; - } else { - url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&accountId=${this.form.accountId}&account=${this.form.account}&workNumber=`; - } - this.$post(url).then(res => { - this.disableds = false - if (this.isAdd && this.form.accountId) { - this.$refs.form.clearValidate(); - this.form = { - account: this.form.account, - userName: "", - phone: "", - uniqueIdentification: "", - workNumber: "", - email: "", - classId: "" - }; - this.$refs.classTree.setCheckedKeys([]); - } else { - this.$refs.form.clearValidate(); - } - this.accountReapeat = false; - }).catch(err => { - - if (this.isAdd) { - this.showTree = false; - } else { - this.accountReapeat = true; - } - }); - } - }, // 组合账号 renderAccount() { const form = this.form // 平台id-端id-schoolId-workNumber组成账号 form.account = `${Setting.platformId}-1-${this.schoolId}-${form.workNumber}` }, - worknumberChange() { - if (this.form.workNumber) { - let url = ""; - if (this.isAdd && !this.form.accountId) { - url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&workNumber=${this.form.workNumber}&account=`; - } else { - url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&accountId=${this.form.accountId}&workNumber=${this.form.workNumber}&account=`; - } - this.$post(url).then(res => { - this.workNumberReapeat = false; + workNumberChange() { + const form = this.form + const { workNumber } = form + // 只有输入了学号并且是新增才需要根据学号查询其他信息 + if (workNumber && this.isAdd && /^[A-Za-z0-9]*$/.test(workNumber)) { + this.$post(`${this.api.getDetailByAccount}?workNumber=${workNumber}&platformId=${Setting.platformId}&type=1`).then(({ data }) => { + if (data) { + this.showTree = true; + const classId = data.classList.map(e => e.id).toString(); + this.form = data + this.form.classId = classId this.renderAccount() - }).catch(err => { - this.$post(`${this.api.getDetailByAccount}?workNumber=${this.form.workNumber}&platformId=${Setting.platformId}&type=1`).then(res => { - const { data } = res - this.showTree = true; - const classId = data.classList.map(e => e.id).toString(); - this.form = data - this.form.classId = classId - this.defaultCheckedKeys = classId.split(",").map(i => Number(i)); - this.accountReapeat = false; - this.$refs.form.clearValidate(); - this.renderAccount() - }).catch(res => {}); - this.workNumberReapeat = true; - }); + // 无指定范围的classId为1,即没有班级,如果没有班级则直接清空班级选择 + if (classId === '1') { + this.$refs.classTree.setCheckedKeys([]) + } else { + this.defaultCheckedKeys = classId.split(",").map(i => Number(i)) + } + this.$refs.form.clearValidate() + } else { + // 如果该学号没有对应的学生,则清空所有信息,除了学号 + this.form = JSON.parse(JSON.stringify(this.originForm)) + this.form.workNumber = workNumber + this.renderAccount() + this.$refs.classTree.setCheckedKeys([]) + } + }).catch(res => {}) + } else { + this.renderAccount() } }, phoneChange() { @@ -837,6 +768,8 @@ export default { }).catch(err => { this.phoneRepeat = true; }); + } else { + this.phoneRepeat = false } }, emailChange() { @@ -855,6 +788,8 @@ export default { }).catch(err => { this.emailRepeat = true; }); + } else { + this.emailRepeat = false } }, filterNode(value, data) { @@ -939,7 +874,6 @@ export default { }, 2000) }) } else { - if (this.accountReapeat) return util.warningMsg("该账号已存在"); if (this.workNumberReapeat) return util.warningMsg("该学生学号已存在"); if (this.phoneRepeat) return util.warningMsg("该手机号已存在"); if (this.emailRepeat) return util.warningMsg("该邮箱已存在"); @@ -971,6 +905,12 @@ export default { } }); }, + // 判重重置 + resetRepeat() { + this.workNumberReapeat = false + this.phoneRepeat = false + this.emailRepeat = false + }, resetStudent() { // 重置新增学生对话框 this.$refs.form.clearValidate(); this.form = { @@ -982,7 +922,8 @@ export default { email: "", classId: "" }; - this.$refs.classTree.setCheckedKeys([]); + this.$refs.classTree.setCheckedKeys([]) + this.resetRepeat() if (this.studentType) { this.getData(); } else { @@ -1004,6 +945,7 @@ export default { this.isDetail = false; this.showTree = false; this.studentVisible = false; + this.resetRepeat() }, batchImport() { // 批量导入 this.importVisible = true; diff --git a/src/pages/system/list/staff.vue b/src/pages/system/list/staff.vue index f6c4ae1..5068e15 100644 --- a/src/pages/system/list/staff.vue +++ b/src/pages/system/list/staff.vue @@ -47,7 +47,7 @@ width="30%" @close="closeTeacher" class="dialog" :close-on-click-modal="false"> - + @@ -81,9 +81,6 @@ - - - 取 消 @@ -124,34 +121,9 @@ import Setting from "@/setting"; import util from "@/libs/util"; import org from "./staffSide" +import { mapState } from "vuex"; export default { 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 = /^[a-zA-Z0-9]*$/; - if(pattern.test(value)){ - this.workNumberChange(); - callback(); - }else{ - callback(new Error('职工工号必须为数字或英文')); - } - } - }; return { exportCode: "", headers: { @@ -165,6 +137,7 @@ export default { casProps: { value: 'id' }, + originForm: {}, form: { accountId: "", account: "", @@ -177,9 +150,6 @@ export default { email: "" }, rules: { - account: [ - { required: true, validator: accountPass, trigger: 'blur' } - ], userName: [ { required: true, message: "请输入用户姓名", trigger: "blur" } ], @@ -187,17 +157,20 @@ export default { { required: true, message: "请选择账号角色", trigger: "change" } ], workNumber: [ - { required: true, validator: workNumberPass , trigger: 'blur' } + { required: true, message: "请输入工号", trigger: 'blur' }, + { + pattern: /^[A-Za-z0-9]*$/, + message: "职工工号必须为数字或英文", + trigger: "blur" + } ], uniqueIdentification: [ // { required: true, message: '请输入唯一标识', trigger: 'blur' }, ], phone: [ - // { required: true, message: '请输入职工手机号', trigger: 'blur' }, { pattern: /^1[3456789]\d{9}$/, message: "请输入正确的手机号", trigger: "blur"} ], email: [ - // { required: true, message: '请输入邮箱', trigger: 'blur' }, { pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/, message: "请输入正确的邮箱", @@ -205,7 +178,6 @@ export default { } ], }, - accountReapeat: false, workNumberReapeat: false, phoneRepeat: false, emailRepeat: false, @@ -229,6 +201,11 @@ export default { components: { org }, + computed: { + ...mapState("user", [ + 'schoolId' + ]) + }, watch: { keyword: function(val) { clearTimeout(this.searchTimer); @@ -238,6 +215,7 @@ export default { } }, mounted() { + this.originForm = JSON.parse(JSON.stringify(this.form)) this.getRoleData() this.getData() }, @@ -344,28 +322,31 @@ export default { this.orgList = this.$refs.org.orgList; this.getStaffDetail(row.accountId); }, - accountChange() { // 切换账号 - if (this.form.account) { - let url = ""; - if (this.isAdd) { - url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&account=${this.form.account}&workNumber=`; - } else { - url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&accountId=${this.form.accountId}&account=${this.form.account}&workNumber=`; - } - this.$post(url).then(res => { - if (res.status === 200) { - this.accountReapeat = false; - } - }).catch( err => { - this.accountReapeat = true; - }); - } + // 组合账号 + renderAccount() { + const form = this.form + // 平台id-端id-schoolId-workNumber组成账号 + form.account = `${Setting.platformId}-0-${this.schoolId}-${form.workNumber}` }, workNumberChange() { // 切换工号 - if (this.form.workNumber) { - this.$post(`${this.api.getDetailByAccount}?workNumber=${this.form.workNumber}&platformId=${Setting.platformId}&type=0`).then(res => { - this.form = res.data + const form = this.form + const { workNumber } = form + // 只有输入了学号并且是新增才需要根据学号查询其他信息 + if (workNumber && this.isAdd && /^[A-Za-z0-9]*$/.test(workNumber)) { + this.$post(`${this.api.getDetailByAccount}?workNumber=${workNumber}&platformId=${Setting.platformId}&type=0`).then(({ data }) => { + if (data) { + this.form = data + this.renderAccount() + this.$refs.form.clearValidate() + } else { + // 如果该学号没有对应的学生,则清空所有信息,除了学号 + this.form = JSON.parse(JSON.stringify(this.originForm)) + this.form.workNumber = workNumber + this.renderAccount() + } }).catch(res => {}) + } else { + this.renderAccount() } }, phoneChange() { // 切换手机号 @@ -440,7 +421,6 @@ export default { this.$refs[form].validate((valid) => { if (valid) { if (this.submiting) return false - if (this.accountReapeat) return util.warningMsg("该账号已存在"); if (this.workNumberReapeat) return util.warningMsg("该员工工号已存在"); if (this.phoneRepeat) return util.warningMsg("该手机号已存在"); if (this.emailRepeat) return util.warningMsg("该邮箱已存在");