From 40fe55b42abd36beb814a69a1f9292e7a9a7f7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E7=A0=81-=E6=96=B9=E6=99=93=E8=BE=89?= Date: Mon, 2 Feb 2026 17:48:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=B9=B4=E7=BA=A7/?= =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E6=97=B6=E5=B7=B2=E6=B7=BB=E5=8A=A0=E7=9A=84?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E7=A6=81=E7=94=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增年级弹窗:已挂载的年级显示为灰色不可选(已添加) - 新增班级弹窗:已挂载的班级显示为灰色不可选(已添加) - 从树形数据中获取已有年级/班级的ID列表传递给弹窗 --- .../business/school/components/ClassDialog.vue | 15 +++++++++++---- .../business/school/components/GradeDialog.vue | 13 ++++++++++--- .../ruoyi-ui/src/views/business/school/index.vue | 16 ++++++++++++++-- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/frontend/ruoyi-ui/src/views/business/school/components/ClassDialog.vue b/frontend/ruoyi-ui/src/views/business/school/components/ClassDialog.vue index f621ad5..7669542 100644 --- a/frontend/ruoyi-ui/src/views/business/school/components/ClassDialog.vue +++ b/frontend/ruoyi-ui/src/views/business/school/components/ClassDialog.vue @@ -16,8 +16,8 @@ - - {{ item.label }} + + {{ item.label }}{{ item.disabled ? '(已添加)' : '' }} @@ -56,6 +56,9 @@ const form = ref({ classIds: [] }) +// 已有班级ID列表 +const existingClassIds = ref([]) + // 获取班级选项 const fetchClassOptions = async () => { try { @@ -65,7 +68,7 @@ const fetchClassOptions = async () => { classOptions.value = (res.data || []).map(item => ({ value: item.classId, label: item.className, - disabled: false + disabled: existingClassIds.value.includes(item.classId) })) } } catch (error) { @@ -74,15 +77,19 @@ const fetchClassOptions = async () => { } // 打开弹窗 -// schoolData: { schoolId, schoolName, schoolGradeId, gradeName } +// schoolData: { schoolId, schoolName, schoolGradeId, gradeName, existingClassIds } const open = (schoolData) => { dialogVisible.value = true currentSchool.value = schoolData + // 保存已有班级ID列表 + existingClassIds.value = schoolData.existingClassIds || [] form.value = { schoolId: schoolData.schoolId, schoolGradeId: schoolData.schoolGradeId, classIds: [] } + // 重新获取班级选项(更新禁用状态) + fetchClassOptions() } // 提交表单 diff --git a/frontend/ruoyi-ui/src/views/business/school/components/GradeDialog.vue b/frontend/ruoyi-ui/src/views/business/school/components/GradeDialog.vue index 91867f9..01e3220 100644 --- a/frontend/ruoyi-ui/src/views/business/school/components/GradeDialog.vue +++ b/frontend/ruoyi-ui/src/views/business/school/components/GradeDialog.vue @@ -16,8 +16,8 @@ - - {{ item.label }} + + {{ item.label }}{{ item.disabled ? '(已添加)' : '' }} @@ -55,6 +55,9 @@ const form = ref({ gradeIds: [] }) +// 已有年级ID列表 +const existingGradeIds = ref([]) + // 获取年级选项 const fetchGradeOptions = async () => { try { @@ -64,7 +67,7 @@ const fetchGradeOptions = async () => { gradeOptions.value = (res.data || []).map(item => ({ value: item.gradeId, label: item.gradeName, - disabled: false + disabled: existingGradeIds.value.includes(item.gradeId) })) } } catch (error) { @@ -76,10 +79,14 @@ const fetchGradeOptions = async () => { const open = (school) => { dialogVisible.value = true currentSchool.value = school + // 保存已有年级ID列表 + existingGradeIds.value = school.existingGradeIds || [] form.value = { schoolId: school.schoolId, gradeIds: [] } + // 重新获取年级选项(更新禁用状态) + fetchGradeOptions() } // 提交表单 diff --git a/frontend/ruoyi-ui/src/views/business/school/index.vue b/frontend/ruoyi-ui/src/views/business/school/index.vue index 675c195..cd6f492 100644 --- a/frontend/ruoyi-ui/src/views/business/school/index.vue +++ b/frontend/ruoyi-ui/src/views/business/school/index.vue @@ -232,9 +232,15 @@ const handleEdit = (row) => { // 新增年级 - 学校下新增年级,选择对应的年级挂载 const handleAddGrade = (row) => { + // 获取学校已有的年级ID列表 + const existingGradeIds = (row.children || []) + .filter(child => child.type === 'grade') + .map(child => child.gradeId) + const schoolData = { schoolId: row.id, - schoolName: row.name + schoolName: row.name, + existingGradeIds: existingGradeIds } gradeDialogRef.value?.open(schoolData) } @@ -243,11 +249,17 @@ const handleAddGrade = (row) => { const handleAddClass = (row) => { // 从 treeData 中查找学校名称 const school = treeData.value.find(s => s.id === row.schoolId) + // 获取年级已有的班级ID列表 + const existingClassIds = (row.children || []) + .filter(child => child.type === 'class') + .map(child => child.classId) + const schoolData = { schoolId: row.schoolId, schoolName: school ? school.name : '', schoolGradeId: row.id, - gradeName: row.name + gradeName: row.name, + existingClassIds: existingClassIds } classDialogRef.value?.open(schoolData) }