diff --git a/frontend/src/views/training/components/CoursePanel.vue b/frontend/src/views/training/components/CoursePanel.vue index f5e9173..21e7c64 100644 --- a/frontend/src/views/training/components/CoursePanel.vue +++ b/frontend/src/views/training/components/CoursePanel.vue @@ -281,7 +281,7 @@
发布后将自动生成计划与学员名单(线下计划含签到码),并推送讲师与学员通知;课程信息随所选课程带出,课件/试题可在本弹窗上传/更换(自动同步课程管理,变更后该课程回「待核验」,需课长/经理重新签核后方可发布)。
@@ -1279,10 +1279,12 @@ const filteredCourses = computed(() => { if (kw && !(row.name || '').toLowerCase().includes(kw)) return false if (filters.value.lecturerId && row.lecturer_id !== filters.value.lecturerId) return false if (filters.value.status && row.status !== filters.value.status) return false - // 000163 月份筛选:计划培训时间/授课时间任一命中所选月份即可;清空 = 全部数据 + // 000163 月份筛选:计划培训时间/授课时间任一命中所选月份即可;清空 = 全部数据。 + // 未填计划/授课时间的计划(如暂存草稿)无月份可命中,始终展示, + // 避免默认当月视图下刚暂存的草稿“看不见” if (months.length) { const keys = courseMonthKeys(row) - if (!months.some((m) => keys.includes(m))) return false + if (keys.length && !months.some((m) => keys.includes(m))) return false } return true }) @@ -1396,6 +1398,28 @@ const openCreate = (mode: 'offline' | 'online') => { formVisible.value = true } +// 创建计划保存载荷(000163 抽取复用):「保存并发布」与「暂存草稿」共用; +// 参加人员随载荷落 post_scope,发布后由场次名单同步 +const buildSavePayload = () => ({ + name: form.value.name, + mode: form.value.mode, + type: form.value.type, + hours: form.value.hours, + credits: form.value.credits, + dept_ids: form.value.dept_ids, + lecturer_id: form.value.lecturer_id || undefined, + teach_time: teachTimeOf(form.value), + // 000163 根因修复:授课地点须随课程落库(此前只写到场次,发布校验读 + // course.location 恒为空,导致「已填授课地点仍提示需先设置授课地点」) + location: form.value.mode === 'offline' ? form.value.location.trim() : '', + // 000163:计划培训时间默认取授课时间所在月份(YYYY-MM) + planned_time: form.value.start_at ? form.value.start_at.slice(0, 7) : '', + post_scope: resolvedFormMembers.value.map((m) => m.user_name || m.employee_no).join('、'), + // 课程管理关联(服务端据此带出并锁定课程信息,自动生成计划编号) + library_course_id: form.value.library_course_id, + description: form.value.description, +}) + const onSave = async () => { if (!form.value.library_course_id || !form.value.name) { MessagePlugin.warning('请从课程管理选择课程(课程名称必选)') @@ -1441,26 +1465,7 @@ const onSave = async () => { } saving.value = true try { - const postScope = selectedMembers.map((m) => m.user_name || m.employee_no).join('、') - const res = await saveCourse({ - name: form.value.name, - mode: form.value.mode, - type: form.value.type, - hours: form.value.hours, - credits: form.value.credits, - dept_ids: form.value.dept_ids, - lecturer_id: form.value.lecturer_id || undefined, - teach_time: teachTimeOf(form.value), - // 000163 根因修复:授课地点须随课程落库(此前只写到场次,发布校验读 - // course.location 恒为空,导致「已填授课地点仍提示需先设置授课地点」) - location: form.value.mode === 'offline' ? form.value.location.trim() : '', - // 000163:计划培训时间默认取授课时间所在月份(YYYY-MM) - planned_time: form.value.start_at ? form.value.start_at.slice(0, 7) : '', - post_scope: postScope, - // 课程管理关联(服务端据此带出并锁定课程信息,自动生成计划编号) - library_course_id: form.value.library_course_id, - description: form.value.description, - }) + const res = await saveCourse(buildSavePayload()) const course = unwrap(res) if (!course) throw new Error('save failed') @@ -1522,6 +1527,34 @@ const onSave = async () => { } } +// 暂存草稿(000163):此前按钮只关闭弹窗未落库,填写内容全部丢失;现按草稿 +// 状态保存计划(不建场次/名单、不发布),可稍后在列表「调整」完善后「发布」。 +// 草稿只要求选到课程,其余授课安排可留空待补。 +const onSaveDraft = async () => { + if (!form.value.library_course_id || !form.value.name) { + MessagePlugin.warning('请从课程管理选择课程(课程名称必选)') + return + } + saving.value = true + try { + const res = await saveCourse(buildSavePayload()) + const course = unwrap(res) + if (!course) throw new Error('save failed') + MessagePlugin.success( + course.plan_code + ? `计划 ${course.plan_code} 已暂存为草稿,可在列表「调整」完善后点击「发布」` + : '计划已暂存为草稿,可在列表「调整」完善后点击「发布」', + ) + formVisible.value = false + resetFormParticipants() + loadAll() + } catch (e: any) { + MessagePlugin.error(apiErrorMessage(e, '暂存失败,请稍后重试')) + } finally { + saving.value = false + } +} + const onPublish = async (row: TrainingCourse) => { // 与后端同口径的前置校验(000161):线上必须有课件;线下须有讲师(外部姓名 // 亦可)/授课时间/授课地点;两者均须已设置参加人员且关联课程已签核 @@ -1859,6 +1892,11 @@ watch(() => route?.query?.courseId, openDetailFromRoute) .training-panel-box(); } +// 表单项内提示文案(bank-hint/form-hint)统一另起一行展示在控件下方 +.course-panel { + .training-form-hints-below(); +} + .form-hint { margin-top: 8px; color: var(--td-text-color-placeholder); diff --git a/frontend/src/views/training/components/PlanPanel.vue b/frontend/src/views/training/components/PlanPanel.vue index 1d2fc58..d96fe26 100644 --- a/frontend/src/views/training/components/PlanPanel.vue +++ b/frontend/src/views/training/components/PlanPanel.vue @@ -1036,6 +1036,11 @@ onMounted(() => { } } +// 表单项内提示文案(form-hint)统一另起一行展示在控件下方 +.plan-panel { + .training-form-hints-below(); +} + // 已确认行不做整行置灰:t-table 行选择列 disabled 命中时会加 __row--disabled // 类(整行 text-color-disabled),业务上已确认行仅禁止勾选,文字保持正常色 :deep(.t-table__row--disabled) { diff --git a/frontend/src/views/training/training.less b/frontend/src/views/training/training.less index 8f47058..d5bb107 100644 --- a/frontend/src/views/training/training.less +++ b/frontend/src/views/training/training.less @@ -171,6 +171,20 @@ margin-bottom: 16px; } +// 表单项内提示文案统一另起一行(000163):t-form__controls-content 为 flex 行排布, +// 控件后的提示块(bank-hint/form-hint)会被排到控件右侧,此处强制换行占满整行, +// 统一展示在控件下方 +.training-form-hints-below() { + :deep(.t-form__controls-content) { + flex-wrap: wrap; + } + + :deep(.t-form__controls-content .bank-hint), + :deep(.t-form__controls-content .form-hint) { + flex-basis: 100%; + } +} + .training-stat-card() { background: var(--td-bg-color-secondarycontainer); border-radius: var(--app-radius-md);