feat(training): 需求联动课程管理、适合人员多选、跨空间参与与计划讲师回写(000158-000161)
000158 需求单联动课程管理: - tr_demands 新增 library_course_id:填报/导入按课程名称在课程管理精准匹配, 命中自动关联,未命中自动新增待核验课程(000157 流转,发布前须签核完成); 匹配/建档失败整批回滚并透出原因,不静默跳过 - 需求所属部门强制为填报人本人部门:新建按提报人档案落库(忽略请求值防绕过, 无部门档案阻断),编辑保留原部门;批量导入按 Excel「部门」列做归属校验 - 编辑时课程名未变保留原课程关联,全量更新不误清 000159 适合人员部门多选: - tr_course_library.suitable_members 拓宽至 VARCHAR(512):存「、」分隔多部门名 或「全部」,存量单值/自由文本兼容(分隔符匹配时归一) - 课程管理/需求表单改多选交互,「全部」与具体部门互斥 000160 企业培训跨空间参与: - 培训域数据空间按员工档案归属解析(当前空间有培训档案优先,否则回落最早 在职档案所在空间),路由组 TrainingTenantResolution 中间件统一注入 - 中间件同步回落请求上下文执行租户:课件文件流(GetKnowledgeFile)、培训 知识库 ensure 等 ctx 租户链路落在档案空间;caller 身份保持当前工作区, 授权口径不变(修复跨空间学员课件预览 403「Permission denied」与文件流 404) - 课程学习详情页课件预览统一走培训域文件流(/training/materials/:id/file), 不再请求知识库守卫路由(/knowledge/:id/preview);附空间解析中间件单元测试 - 培训中心「和信课程」目录(scope=catalog):已发布 + 适合人员覆盖即可见; 卡片点开即学(课件在线预览抽屉 + 下载);计划无材料行时以课程管理条目 合成课件回退取流 - /training/members/me 联查返回部门名,支撑适合人员匹配与表单默认值 000161 计划讲师回写与发布校验: - 月培训计划讲师计划侧可改,改动回写课程管理主数据并重置待核验(发布前须 重新签核),同步补讲师 lecturer 角色绑定 - 发布必填校验:关联课程管理且已签核、参加人员;线下计划另需授课时间/地点/ 讲师(线上计划豁免);跨场次名单去重成员数校验
This commit is contained in:
1 parent
3c8b595064
commit
0819f8c4d1
24 files changed
+1084
-202
No files matched your search
@@ -71,7 +71,7 @@
|
||||
variant="text" theme="primary" size="small" :disabled="saving"
|
||||
@click="onPublish(row)"
|
||||
>发布</t-button>
|
||||
<t-button variant="text" size="small" @click="openDetail(row)">详情</t-button>
|
||||
<t-button variant="text" size="small" @click="openDetail(row)">调整</t-button>
|
||||
<t-button variant="text" size="small" @click="openChangeLogs(row)">记录</t-button>
|
||||
<t-button v-if="canManage" variant="text" theme="danger" size="small" @click="onDelete(row)">删除</t-button>
|
||||
</template>
|
||||
@@ -195,16 +195,16 @@
|
||||
</template>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 计划详情:计划编号展示 + 课程名称(课程管理选择,信息锁定) + 六项授课安排维护 -->
|
||||
<t-dialog v-model:visible="sessionsVisible" :header="`计划详情 · ${activeCourse?.name || ''}`" width="760" :footer="false">
|
||||
<!-- 计划调整:计划编号展示 + 课程名称/讲师(000161 可调整,讲师改动回写课程管理并重置待核验) + 六项授课安排维护 -->
|
||||
<t-dialog v-model:visible="sessionsVisible" :header="`计划调整 · ${activeCourse?.name || ''}`" width="760" :footer="false">
|
||||
<t-form label-width="90" class="detail-form">
|
||||
<t-form-item label="计划编号">
|
||||
<t-input :value="activeCourse?.plan_code || '-'" disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="课程名称">
|
||||
<!-- 未关联课程管理的计划可选定课程(选定后信息锁定);已关联直接锁定展示 -->
|
||||
<!-- 000161 可切换关联课程:改选即换 library_course_id,类型/形式随新课程带出;
|
||||
讲师改动保存后回写课程管理并重置待核验,发布前须重新签核 -->
|
||||
<t-select
|
||||
v-if="!activeCourse?.library_course_id"
|
||||
v-model="editForm.library_course_id"
|
||||
:disabled="!canManage"
|
||||
clearable
|
||||
@@ -215,13 +215,23 @@
|
||||
>
|
||||
<t-option v-for="c in libraryCourses" :key="c.id" :value="c.id" :label="`${c.name}${c.category ? `(${c.category})` : ''}`" />
|
||||
</t-select>
|
||||
<t-input v-else :value="editForm.name" disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="类型">
|
||||
<t-input :value="formTypeDisplay" disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="讲师">
|
||||
<t-input :value="lecturerDisplay(editForm.lecturer_id)" disabled placeholder="随课程带出" />
|
||||
<!-- 000161 计划侧可改讲师:名册选择或直接输入外部讲师姓名 -->
|
||||
<t-select
|
||||
v-model="editForm.lecturer_id"
|
||||
:disabled="!canManage"
|
||||
clearable
|
||||
filterable
|
||||
creatable
|
||||
placeholder="从讲师名册选择或直接输入外部讲师姓名"
|
||||
style="width: 100%"
|
||||
>
|
||||
<t-option v-for="l in lecturers" :key="l.id" :label="l.name" :value="l.id" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="所属部门">
|
||||
<t-input :value="deptNamesOf(editForm.dept_ids)" disabled placeholder="随课程带出" />
|
||||
@@ -1159,19 +1169,40 @@ const onSave = async () => {
|
||||
}
|
||||
|
||||
const onPublish = async (row: TrainingCourse) => {
|
||||
// 与后端同口径的前置校验:线上必须有课件,线下必须有讲师
|
||||
// 与后端同口径的前置校验(000161):线上必须有课件;线下须有讲师(外部姓名
|
||||
// 亦可)/授课时间/授课地点;两者均须已设置参加人员且关联课程已签核
|
||||
if (row.mode === 'online') {
|
||||
try {
|
||||
const res = await listMaterials(row.id)
|
||||
if (!(unwrap(res) || []).length) {
|
||||
MessagePlugin.warning(`「${row.name}」是线上计划,发布前需先登记课件资料`)
|
||||
return
|
||||
// 计划未自带课件时回退课程管理课件(名称登记/文件/知识库文档,
|
||||
// 000156 随所选课程带出,详情弹窗「更换」也回写主数据)与后端同口径
|
||||
const lc = libraryCourses.value.find((c) => c.id === (row.library_course_id || ''))
|
||||
const hasLibCourseware = !!(lc?.material_name || lc?.file_name || lc?.knowledge_id)
|
||||
if (!hasLibCourseware) {
|
||||
MessagePlugin.warning(`「${row.name}」是线上计划,发布前需先登记课件资料`)
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
/* 查询失败时交由后端校验兜底 */
|
||||
}
|
||||
} else if (!row.lecturer_id) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「详情」中指定讲师`)
|
||||
} else {
|
||||
if (!row.lecturer_id && !row.lecturer_external) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中指定讲师`)
|
||||
return
|
||||
}
|
||||
if (!row.teach_time) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中设置授课时间`)
|
||||
return
|
||||
}
|
||||
if (!row.location) {
|
||||
MessagePlugin.warning(`「${row.name}」是线下计划,发布前需先在「调整」中设置授课地点`)
|
||||
return
|
||||
}
|
||||
}
|
||||
if (!row.post_scope) {
|
||||
MessagePlugin.warning(`「${row.name}」发布前需先在「调整」中设置参加人员`)
|
||||
return
|
||||
}
|
||||
try {
|
||||
@@ -1339,42 +1370,55 @@ const ensureCourseSession = async (
|
||||
// 学员名单以「参加人员」为准同步(适用部门选择时已自动带入,可增删)。
|
||||
// 详情保存载荷(000158 抽取复用):UpdateCourse 为全量列更新,未编辑字段必须
|
||||
// 回填原值,否则 tags/material_ids 会写 NULL,status/exam_enabled 会被零值覆盖。
|
||||
const detailSavePayload = (row: TrainingCourse) => ({
|
||||
id: row.id,
|
||||
code: row.code,
|
||||
name: editForm.value.name,
|
||||
mode: editForm.value.mode,
|
||||
type: editForm.value.type,
|
||||
hours: editForm.value.hours,
|
||||
credits: editForm.value.credits,
|
||||
exam_enabled: row.exam_enabled,
|
||||
dept_ids: editForm.value.dept_ids,
|
||||
lecturer_id: editForm.value.lecturer_id || undefined,
|
||||
// 参加人员:详情表单可编辑,保存随课程信息落库并同步场次学员名单
|
||||
post_scope: resolvedParticipantMembers.value.map((m) => m.user_name || m.employee_no).join('、'),
|
||||
description: row.description,
|
||||
material_ids: row.material_ids,
|
||||
tags: row.tags,
|
||||
status: row.status,
|
||||
teach_time: teachTimeOf(editForm.value),
|
||||
planned_time: row.planned_time || '',
|
||||
// 其余需求确认同步字段原样透传(详情表单不编辑,防止保存时被零值覆盖丢失)
|
||||
train_type: row.train_type || '',
|
||||
plant: row.plant || '',
|
||||
location: row.location || '',
|
||||
session_count: row.session_count || 0,
|
||||
lecturer_external: row.lecturer_external || '',
|
||||
remark: row.remark || '',
|
||||
// 课程管理关联(未关联的存量计划可在此选定课程;关联后服务端锁定带出字段)
|
||||
library_course_id: editForm.value.library_course_id || row.library_course_id || '',
|
||||
})
|
||||
// 000161 讲师解析:名册 id 直接用;非名册值(creatable 直接输入)按外部讲师姓名落库
|
||||
const resolveDetailLecturer = (row: TrainingCourse) => {
|
||||
const v = (editForm.value.lecturer_id || '').trim()
|
||||
if (!v) return { lecturerId: '', external: row.lecturer_external || '' }
|
||||
if (lecturers.value.some((l) => l.id === v)) return { lecturerId: v, external: '' }
|
||||
return { lecturerId: '', external: v }
|
||||
}
|
||||
|
||||
const detailSavePayload = (row: TrainingCourse) => {
|
||||
const lecturer = resolveDetailLecturer(row)
|
||||
return ({
|
||||
id: row.id,
|
||||
code: row.code,
|
||||
name: editForm.value.name,
|
||||
mode: editForm.value.mode,
|
||||
type: editForm.value.type,
|
||||
hours: editForm.value.hours,
|
||||
credits: editForm.value.credits,
|
||||
exam_enabled: row.exam_enabled,
|
||||
dept_ids: editForm.value.dept_ids,
|
||||
lecturer_id: lecturer.lecturerId || undefined,
|
||||
// 参加人员:详情表单可编辑,保存随课程信息落库并同步场次学员名单
|
||||
post_scope: resolvedParticipantMembers.value.map((m) => m.user_name || m.employee_no).join('、'),
|
||||
description: row.description,
|
||||
material_ids: row.material_ids,
|
||||
tags: row.tags,
|
||||
status: row.status,
|
||||
teach_time: teachTimeOf(editForm.value),
|
||||
planned_time: row.planned_time || '',
|
||||
// 其余需求确认同步字段原样透传(详情表单不编辑,防止保存时被零值覆盖丢失)
|
||||
train_type: row.train_type || '',
|
||||
plant: row.plant || '',
|
||||
location: row.location || '',
|
||||
session_count: row.session_count || 0,
|
||||
// 000161 讲师计划侧可改:名册 id 或外部讲师姓名
|
||||
lecturer_external: lecturer.external,
|
||||
remark: row.remark || '',
|
||||
// 课程管理关联(000161 可切换;切换后类型/形式随新课程带出)
|
||||
library_course_id: editForm.value.library_course_id || row.library_course_id || '',
|
||||
})
|
||||
}
|
||||
|
||||
const onSaveDetail = async () => {
|
||||
const row = activeCourse.value
|
||||
if (!row) return
|
||||
// 讲师随课程管理锁定:缺失时提示去课程管理维护(发布时后端也会强制校验)
|
||||
if (row.mode === 'offline' && !editForm.value.lecturer_id) {
|
||||
MessagePlugin.warning('当前课程未指定讲师,请先前往「课程管理」维护讲师')
|
||||
// 线下计划须指定讲师(名册 id 或外部姓名;发布时后端也会强制校验)
|
||||
const lecturer = resolveDetailLecturer(row)
|
||||
if (editForm.value.mode === 'offline' && !lecturer.lecturerId && !lecturer.external) {
|
||||
MessagePlugin.warning('线下计划需先指定讲师(从名册选择或输入外部讲师姓名)')
|
||||
return
|
||||
}
|
||||
detailSaving.value = true
|
||||
@@ -1388,7 +1432,7 @@ const onSaveDetail = async () => {
|
||||
await saveCourse(detailSavePayload(row))
|
||||
const sessionOpts = {
|
||||
mode: editForm.value.mode,
|
||||
lecturerId: editForm.value.lecturer_id || undefined,
|
||||
lecturerId: lecturer.lecturerId || undefined,
|
||||
startAt: editForm.value.start_at,
|
||||
location: editForm.value.location,
|
||||
hours: editForm.value.hours,
|
||||
@@ -1402,7 +1446,7 @@ const onSaveDetail = async () => {
|
||||
end_at: editForm.value.start_at ? new Date(new Date(editForm.value.start_at).getTime() + editForm.value.hours * 3600 * 1000).toISOString() : '',
|
||||
location: editForm.value.location,
|
||||
capacity: existing?.capacity ?? 0,
|
||||
lecturer_id: editForm.value.lecturer_id || undefined,
|
||||
lecturer_id: lecturer.lecturerId || undefined,
|
||||
// [2026-11 推学员] 编辑排课时同步通知方式
|
||||
notify_mode: editForm.value.notify_mode,
|
||||
})
|
||||
@@ -1426,8 +1470,8 @@ const onSaveDetail = async () => {
|
||||
)
|
||||
sessionsVisible.value = false
|
||||
loadAll()
|
||||
} catch {
|
||||
MessagePlugin.error('保存失败,请稍后重试')
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '保存失败,请稍后重试'))
|
||||
} finally {
|
||||
detailSaving.value = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user