From 80246c9dec2958b5e03d535e50f534724512c9fd Mon Sep 17 00:00:00 2001 From: zhonghua Date: Mon, 23 Mar 2026 14:09:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=A1=E5=9B=AD=E7=AB=AF=E6=8E=92?= =?UTF-8?q?=E8=AF=BE=E3=80=81=E6=95=99=E5=B8=88=E7=AB=AF=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E6=8E=92=E8=AF=BE=E6=B7=BB=E5=8A=A0=E5=A5=97=E9=A4=90=E9=80=89?= =?UTF-8?q?=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 多套餐时步骤1展示套餐选择器,支持切换套餐后加载对应课程包 - 单套餐时保持原行为,自动选中并展示课程包 - 管理端数据模型已支持一租户多套餐、一套餐多课程 Made-with: Cursor --- .../components/CreateScheduleModal.scss | 20 ++++++ .../components/CreateScheduleModal.vue | 52 ++++++++++++++ .../components/TeacherCreateScheduleModal.vue | 72 +++++++++++++++++++ 3 files changed, 144 insertions(+) diff --git a/reading-platform-frontend/src/views/school/schedule/components/CreateScheduleModal.scss b/reading-platform-frontend/src/views/school/schedule/components/CreateScheduleModal.scss index 2b218f9..bb63e4c 100644 --- a/reading-platform-frontend/src/views/school/schedule/components/CreateScheduleModal.scss +++ b/reading-platform-frontend/src/views/school/schedule/components/CreateScheduleModal.scss @@ -25,6 +25,26 @@ } } +.collection-selector { + margin-bottom: 20px; + padding: 16px; + background: #FAFAFA; + border-radius: 8px; + + .selector-label { + font-size: 14px; + font-weight: 500; + color: #333; + margin-bottom: 12px; + } + + .collection-radio-group { + display: flex; + flex-wrap: wrap; + gap: 8px; + } +} + .collection-option { .collection-name { font-weight: 500; diff --git a/reading-platform-frontend/src/views/school/schedule/components/CreateScheduleModal.vue b/reading-platform-frontend/src/views/school/schedule/components/CreateScheduleModal.vue index 401a885..abe5638 100644 --- a/reading-platform-frontend/src/views/school/schedule/components/CreateScheduleModal.vue +++ b/reading-platform-frontend/src/views/school/schedule/components/CreateScheduleModal.vue @@ -50,8 +50,22 @@

选择课程包

+ +
+
选择课程套餐
+ + + {{ col.name }} + + +
+
选择课程包
{ classTeacherMap.value = {}; }; +<<<<<<< HEAD // 加载课程套餐列表(租户可拥有多个套餐) +======= +// 加载课程套餐列表;多套餐时展示选择器,单套餐时自动选中并加载课程包 +>>>>>>> d300fa4 (feat: 校园端排课、教师端预约排课添加套餐选择) const loadCollections = async () => { loadingPackages.value = true; try { collections.value = await getCourseCollections(); +<<<<<<< HEAD // 若仅有一个套餐,自动选中并加载其课程包,提升体验 if (collections.value.length === 1) { await selectCollection(collections.value[0]); +======= + if (collections.value.length > 0) { + const first = collections.value[0]; + formData.collectionId = first.id as number; + await loadPackagesForCollection(first.id); + if (!first.packages || first.packages.length === 0) { + message.warning(collections.value.length > 1 ? '该套餐暂无课程包' : '暂无课程包'); + } +>>>>>>> d300fa4 (feat: 校园端排课、教师端预约排课添加套餐选择) } } catch (error) { console.error('❌ 加载课程套餐失败:', error); @@ -445,13 +473,27 @@ const loadCollections = async () => { } }; +<<<<<<< HEAD // 选择套餐,并加载该套餐下的课程包 const selectCollection = async (coll: CourseCollection) => { formData.collectionId = coll.id as number; +======= +// 加载指定套餐下的课程包 +const loadPackagesForCollection = async (collectionId: number | string) => { + const col = collections.value.find(c => c.id === collectionId); + if (!col) return; + const packages = await getCourseCollectionPackages(collectionId); + (col as any).packages = packages; +}; + +// 切换套餐时重新加载课程包并清空已选课程包 +const onCollectionChange = async () => { +>>>>>>> d300fa4 (feat: 校园端排课、教师端预约排课添加套餐选择) formData.packageId = undefined; formData.courseId = undefined; scheduleRefData.value = []; lessonTypes.value = []; +<<<<<<< HEAD if (!coll.id) return; loadingPackages.value = true; @@ -466,6 +508,16 @@ const selectCollection = async (coll: CourseCollection) => { message.error('加载课程包失败'); } finally { loadingPackages.value = false; +======= + const colId = formData.collectionId; + if (colId) { + loadingPackages.value = true; + try { + await loadPackagesForCollection(colId); + } finally { + loadingPackages.value = false; + } +>>>>>>> d300fa4 (feat: 校园端排课、教师端预约排课添加套餐选择) } }; diff --git a/reading-platform-frontend/src/views/teacher/schedule/components/TeacherCreateScheduleModal.vue b/reading-platform-frontend/src/views/teacher/schedule/components/TeacherCreateScheduleModal.vue index 830788b..8525fb4 100644 --- a/reading-platform-frontend/src/views/teacher/schedule/components/TeacherCreateScheduleModal.vue +++ b/reading-platform-frontend/src/views/teacher/schedule/components/TeacherCreateScheduleModal.vue @@ -50,8 +50,22 @@

选择课程包

+ +
+
选择课程套餐
+ + + {{ col.name }} + + +
+
选择课程包
{ lessonTypes.value = []; }; +<<<<<<< HEAD // 加载课程套餐列表(租户可拥有多个套餐) +======= +// 加载课程套餐列表;多套餐时展示选择器,单套餐时自动选中并加载课程包 +>>>>>>> d300fa4 (feat: 校园端排课、教师端预约排课添加套餐选择) const loadCollections = async () => { loadingPackages.value = true; try { collections.value = await getCourseCollections(); +<<<<<<< HEAD // 若仅有一个套餐,自动选中并加载其课程包,提升体验 if (collections.value.length === 1) { await selectCollection(collections.value[0]); +======= + if (collections.value.length > 0) { + const first = collections.value[0]; + formData.collectionId = first.id as number; + await loadPackagesForCollection(first.id); + if (!first.packages || first.packages.length === 0) { + message.warning(collections.value.length > 1 ? '该套餐暂无课程包' : '暂无课程包'); + } +>>>>>>> d300fa4 (feat: 校园端排课、教师端预约排课添加套餐选择) } } catch (error) { console.error('加载课程套餐失败:', error); @@ -400,13 +428,27 @@ const loadCollections = async () => { } }; +<<<<<<< HEAD // 选择套餐,并加载该套餐下的课程包 const selectCollection = async (coll: CourseCollection) => { formData.collectionId = coll.id as number; +======= +// 加载指定套餐下的课程包 +const loadPackagesForCollection = async (collectionId: number | string) => { + const col = collections.value.find(c => c.id === collectionId); + if (!col) return; + const packages = await getCourseCollectionPackages(collectionId); + (col as any).packages = packages; +}; + +// 切换套餐时重新加载课程包并清空已选课程包 +const onCollectionChange = async () => { +>>>>>>> d300fa4 (feat: 校园端排课、教师端预约排课添加套餐选择) formData.packageId = undefined; formData.courseId = undefined; scheduleRefData.value = []; lessonTypes.value = []; +<<<<<<< HEAD if (!coll.id) return; loadingPackages.value = true; @@ -421,6 +463,16 @@ const selectCollection = async (coll: CourseCollection) => { message.error('加载课程包失败'); } finally { loadingPackages.value = false; +======= + const colId = formData.collectionId; + if (colId) { + loadingPackages.value = true; + try { + await loadPackagesForCollection(colId); + } finally { + loadingPackages.value = false; + } +>>>>>>> d300fa4 (feat: 校园端排课、教师端预约排课添加套餐选择) } }; @@ -642,6 +694,26 @@ defineExpose({ open, openWithPreset }); } } +.collection-selector { + margin-bottom: 20px; + padding: 16px; + background: #FAFAFA; + border-radius: 8px; + + .selector-label { + font-size: 14px; + font-weight: 500; + color: #333; + margin-bottom: 12px; + } + + .collection-radio-group { + display: flex; + flex-wrap: wrap; + gap: 8px; + } +} + .collection-option { .collection-name { font-weight: 500; } .collection-info { font-size: 12px; color: #999; }