From 06715c0767fb7e8aa78ff64ef35230c76ab9fc3d Mon Sep 17 00:00:00 2001 From: yangbin <1796443586@qq.com> Date: Thu, 27 Aug 2026 15:31:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E6=89=8D=E5=9F=B9=E5=85=BB=E6=96=B9?= =?UTF-8?q?=E6=A1=88=20=E6=96=B0=E5=A2=9E=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/subjectMajor/discipline/index.vue | 146 ++++++++++++----- .../src/views/subjectMajor/major/index.vue | 154 ++++++++++++++++-- 2 files changed, 247 insertions(+), 53 deletions(-) diff --git a/frontend/src/views/subjectMajor/discipline/index.vue b/frontend/src/views/subjectMajor/discipline/index.vue index d1b8e208..2be8b5de 100644 --- a/frontend/src/views/subjectMajor/discipline/index.vue +++ b/frontend/src/views/subjectMajor/discipline/index.vue @@ -106,87 +106,103 @@ :close-on-click-modal="false" @update:visible="val => formDialogVisible = val" > - + - + - - - - - - + - + - + - + - + - - + + + + - - + + + + - + - + - - + + + + - + - + @@ -207,7 +223,6 @@
{{ detailForm.gfmc || '-' }} - {{ fmtValue(detailForm.xh) }} {{ detailForm.zydm || '-' }} {{ detailForm.zymc || '-' }} {{ detailForm.zyfx || '-' }} @@ -244,6 +259,11 @@ import { updateDiscipline, disableDiscipline } from '@/api/subjectMajor/discipline' +import { getDicts } from '@/api/system/dict/data' +import { optionselect } from '@/api/system/dict/type' + +const TRAINING_TYPE_DICT_CODE = 'train_type' +const TRAINING_LEVEL_DICT_CODE = 'train_level' export default { name: 'DisciplineIndex', @@ -272,6 +292,24 @@ export default { isAdd: true, formSaving: false, form: this.createEmptyForm(), + formRules: { + gfmc: [{ required: true, message: '请输入规范名称', trigger: 'blur' }], + zydm: [{ required: true, message: '请输入专业代码', trigger: 'blur' }], + zymc: [{ required: true, message: '请输入专业名称', trigger: 'blur' }], + zyfx: [{ required: true, message: '请输入专业方向', trigger: 'blur' }], + xnz: [{ required: true, message: '请输入学年制', trigger: 'blur' }], + xqs: [{ required: true, message: '请输入学期数', trigger: 'change' }], + pxcc: [{ required: true, message: '请选择培训层次', trigger: 'change' }], + pxlx: [{ required: true, message: '请选择培训类型', trigger: 'change' }], + pxlx2: [{ required: true, message: '请输入培训类型2', trigger: 'blur' }], + jxgljgbh: [{ required: true, message: '请输入教学管理机构编号', trigger: 'blur' }], + xylb: [{ required: true, message: '请选择学员类别', trigger: 'change' }], + zdyfl: [{ required: true, message: '请输入自定义分类', trigger: 'blur' }], + zgzy: [{ required: true, message: '请输入主干专业', trigger: 'blur' }] + }, + trainingTypeOptions: [], + trainingLevelOptions: [], + studentCategoryOptions: [], // ==================== 详情 ==================== detailDialogVisible: false, @@ -280,9 +318,38 @@ export default { } }, mounted() { + this.loadDisciplineDictionaries() this.fetchList() }, methods: { + /** 加载学科专业表单字典,业务字段统一提交字典标签。 */ + async loadDisciplineDictionaries() { + const emptyResponse = { data: [] } + const [typeResponse, levelResponse, dictTypeResponse] = await Promise.all([ + getDicts(TRAINING_TYPE_DICT_CODE).catch(() => emptyResponse), + getDicts(TRAINING_LEVEL_DICT_CODE).catch(() => emptyResponse), + optionselect().catch(() => emptyResponse) + ]) + this.trainingTypeOptions = typeResponse.data || [] + this.trainingLevelOptions = levelResponse.data || [] + this.studentCategoryOptions = await this.loadNamedDictionary(dictTypeResponse.data || [], '学员类别') + }, + + async loadNamedDictionary(dictTypes, dictName) { + const dictType = dictTypes.find(item => item.dictName === dictName) || + dictTypes.find(item => String(item.dictName || '').includes(dictName)) + if (!dictType || !dictType.dictType) { + return [] + } + + try { + const response = await getDicts(dictType.dictType) + return response.data || [] + } catch (error) { + return [] + } + }, + /** 序号:按当前页数据索引生成跨页连续的序号 */ fmtXh(index) { return (this.pageNum - 1) * this.pageSize + index + 1 @@ -292,7 +359,6 @@ export default { return { bsh: '', gfmc: '', - xh: undefined, zydm: '', zymc: '', zyfx: '', @@ -383,7 +449,6 @@ export default { this.form = { bsh: data.bsh || '', gfmc: data.gfmc || '', - xh: data.xh !== null && data.xh !== undefined ? data.xh : undefined, zydm: data.zydm || '', zymc: data.zymc || '', zyfx: data.zyfx || '', @@ -421,10 +486,7 @@ export default { jsonzd: f.jsonzd, bz: f.bz } - // 序号、学期数为数值字段,转为数字后再提交 - if (f.xh !== '' && f.xh !== null && f.xh !== undefined) { - payload.xh = Number(f.xh) - } + // 学期数为数值字段,转为数字后再提交。 if (f.xqs !== '' && f.xqs !== null && f.xqs !== undefined) { payload.xqs = Number(f.xqs) } @@ -432,16 +494,22 @@ export default { }, handleFormSubmit() { - this.formSaving = true - const payload = this.buildPayload() - const request = this.isAdd ? addDiscipline(payload) : updateDiscipline(payload) - request.then(() => { - this.$message.success(this.isAdd ? '新增成功' : '修改成功') - this.formDialogVisible = false - this.fetchList() - }).catch(() => { - }).finally(() => { - this.formSaving = false + this.$refs.formRef.validate(valid => { + if (!valid) { + return + } + + this.formSaving = true + const payload = this.buildPayload() + const request = this.isAdd ? addDiscipline(payload) : updateDiscipline(payload) + request.then(() => { + this.$message.success(this.isAdd ? '新增成功' : '修改成功') + this.formDialogVisible = false + this.fetchList() + }).catch(() => { + }).finally(() => { + this.formSaving = false + }) }) }, diff --git a/frontend/src/views/subjectMajor/major/index.vue b/frontend/src/views/subjectMajor/major/index.vue index 57024422..0e3041ba 100644 --- a/frontend/src/views/subjectMajor/major/index.vue +++ b/frontend/src/views/subjectMajor/major/index.vue @@ -124,7 +124,7 @@ width="900px" :close-on-click-modal="false" > - + 基本信息 @@ -169,12 +169,26 @@ - + + + - - + + @@ -193,12 +207,26 @@ - + + + - + + + @@ -208,7 +236,14 @@ - + + + @@ -226,12 +261,26 @@ - + + + - + + + @@ -346,6 +395,15 @@ import { delMajor, downloadMajorTemplate } from "@/api/subjectMajor/major" +import { listDiscipline } from '@/api/subjectMajor/discipline' +import { getDicts } from '@/api/system/dict/data' +import { optionselect } from '@/api/system/dict/type' + +const TRAINING_TYPE_DICT_CODE = 'train_type' +const TRAINING_LEVEL_DICT_CODE = 'train_level' +const SESSION_CATEGORY_DICT_CODE = 'session_category' +const SYSTEM_MODE_DICT_CODE = 'system_mode' +const DISCIPLINE_OPTION_PAGE_SIZE = 10000 export default { name: "Major", @@ -377,6 +435,13 @@ export default { isAdd: true, formSaving: false, form: this.createEmptyForm(), + trainingTypeOptions: [], + trainingLevelOptions: [], + studentCategoryOptions: [], + sessionCategoryOptions: [], + systemModeOptions: [], + disciplineOptions: [], + disciplineOptionsLoading: false, formRules: { zydh: [{ required: true, message: "专业代号不能为空", trigger: "blur" }], zymc: [{ required: true, message: "专业名称不能为空", trigger: "blur" }], @@ -386,14 +451,14 @@ export default { xnz: [{ required: true, message: "学年制不能为空", trigger: "blur" }], xqs: [{ required: true, message: "学期数不能为空", trigger: "change" }], zybsh: [{ required: true, message: "专业标识号不能为空", trigger: "blur" }], - pxcc: [{ required: true, message: "培训层次不能为空", trigger: "blur" }], - pxlx: [{ required: true, message: "培训类型不能为空", trigger: "blur" }], + pxcc: [{ required: true, message: "请选择培训层次", trigger: "change" }], + pxlx: [{ required: true, message: "请选择培训类型", trigger: "change" }], pxlx2: [{ required: true, message: "培训类型2不能为空", trigger: "blur" }], - xylb: [{ required: true, message: "学员类别不能为空", trigger: "blur" }], + xylb: [{ required: true, message: "请选择学员类别", trigger: "change" }], zdyfl: [{ required: true, message: "自定义分类不能为空", trigger: "blur" }], zgzy: [{ required: true, message: "主干专业不能为空", trigger: "change" }], - jclb: [{ required: true, message: "节次类别不能为空", trigger: "blur" }], - xtms: [{ required: true, message: "系统模式不能为空", trigger: "blur" }] + jclb: [{ required: true, message: "请选择节次类别", trigger: "change" }], + xtms: [{ required: true, message: "请选择系统模式", trigger: "change" }] }, // ==================== 详情 ==================== @@ -403,9 +468,70 @@ export default { } }, created() { + this.loadMajorDictionaries() + this.loadDisciplineOptions() this.fetchList() }, methods: { + /** 加载专业表单中已配置的字典项,文本业务字段统一提交字典标签。 */ + async loadMajorDictionaries() { + const emptyResponse = { data: [] } + const [typeResponse, levelResponse, sessionResponse, modeResponse, dictTypeResponse] = await Promise.all([ + getDicts(TRAINING_TYPE_DICT_CODE).catch(() => emptyResponse), + getDicts(TRAINING_LEVEL_DICT_CODE).catch(() => emptyResponse), + getDicts(SESSION_CATEGORY_DICT_CODE).catch(() => emptyResponse), + getDicts(SYSTEM_MODE_DICT_CODE).catch(() => emptyResponse), + optionselect().catch(() => emptyResponse) + ]) + this.trainingTypeOptions = typeResponse.data || [] + this.trainingLevelOptions = levelResponse.data || [] + this.sessionCategoryOptions = sessionResponse.data || [] + this.systemModeOptions = modeResponse.data || [] + + const dictTypes = dictTypeResponse.data || [] + this.studentCategoryOptions = await this.loadNamedDictionary(dictTypes, '学员类别') + }, + + async loadNamedDictionary(dictTypes, dictName) { + const dictType = dictTypes.find(item => item.dictName === dictName) || + dictTypes.find(item => String(item.dictName || '').includes(dictName)) + if (!dictType || !dictType.dictType) { + return [] + } + + try { + const response = await getDicts(dictType.dictType) + return response.data || [] + } catch (error) { + return [] + } + }, + + /** 复用学科专业分页接口加载启用数据,作为全量下拉选项。 */ + async loadDisciplineOptions() { + this.disciplineOptionsLoading = true + try { + const response = await listDiscipline({ + pageNum: 1, + pageSize: DISCIPLINE_OPTION_PAGE_SIZE, + ty: 0 + }) + const data = response.data || {} + this.disciplineOptions = Array.isArray(data.records) ? data.records : [] + } catch (error) { + this.disciplineOptions = [] + } finally { + this.disciplineOptionsLoading = false + } + }, + + formatDisciplineLabel(item) { + const name = item.zymc || item.gfmc || item.zydm || item.bsh + const identifiers = [item.zydm, item.bsh].filter(Boolean).join(' / ') + + return identifiers && identifiers !== name ? `${name}(${identifiers})` : name + }, + /** 表格序号(跨页连续) */ fmtXh(index) { return (this.pageNum - 1) * this.pageSize + index + 1