diff --git a/frontend/src/views/teachBusiness/semester/index.vue b/frontend/src/views/teachBusiness/semester/index.vue index c36a3dff..27f79207 100644 --- a/frontend/src/views/teachBusiness/semester/index.vue +++ b/frontend/src/views/teachBusiness/semester/index.vue @@ -84,26 +84,30 @@ + - - + - + @@ -305,6 +309,17 @@ export default { const s = String(nd) return { xn: s.slice(0, 4), xq: s.slice(4) } }, + /** 新增时校验学期名称(年份+学期类型拼接)是否已存在于表格 */ + isSemesterNameDuplicated() { + if (!this.isAdd) return false + const nd = this.buildNd(this.form.xn, this.form.xq) + if (!nd) return false + return this.semesterList.some(item => String(item.nd) === String(nd)) + }, + /** 年份/学期类型切换时实时刷新顶部重复提示 */ + checkSemesterNameUnique() { + this.$forceUpdate() + }, /** 课时系数方案编号 -> 名称 */ getCoefficientLabel(value) { if (!value && value !== 0) return '-' @@ -430,6 +445,10 @@ export default { }, /** 提交表单 */ submitForm() { + if (this.isSemesterNameDuplicated()) { + this.$modal.msgWarning("该学期已存在,不能重复添加") + return + } this.$refs["form"].validate(valid => { if (valid) { const payload = this.buildPayload(this.form) @@ -507,6 +526,11 @@ export default { display: block; } + /* 顶部学期重复提示与表单间距 */ + .semester-dup-alert { + margin-bottom: 16px; + } + .semester-form-col { padding-right: 4px; }