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
@@ -126,15 +126,24 @@
|
||||
:label="`${c.name}${c.category ? `(${c.category})` : ''}`"
|
||||
/>
|
||||
</t-select>
|
||||
<!-- 000158:提交时按名称精准匹配课程管理,未命中自动新增待核验课程 -->
|
||||
<div class="form-hint">提交时按名称精准匹配课程管理;未匹配到将自动新增该课程(待审核),经课长/经理签核后方可发布</div>
|
||||
</t-form-item>
|
||||
<t-form-item label="分类" name="category">
|
||||
<t-input :value="demandForm.category" disabled placeholder="随所选课程自动带出" />
|
||||
</t-form-item>
|
||||
<t-form-item label="所属部门" name="dept_id">
|
||||
<t-input :value="deptDisplay" disabled placeholder="提交时按提报人所在部门自动获取" />
|
||||
<!-- 000158:所属部门必须为填报人本人部门,服务端强制按提报人部门落库 -->
|
||||
<t-input :value="deptDisplay" disabled placeholder="自动带出提报人所在部门(不可修改)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="适合人员" name="post_scope">
|
||||
<t-input v-model="demandForm.post_scope" placeholder="可填写多个适合人员,用、或,分隔(选填)" />
|
||||
<!-- 000159 部门多选口径:归属部门(可多选)或「全部」(互斥),自动建档随需求带入课程 -->
|
||||
<t-select
|
||||
v-model="demandSuitableList" clearable filterable multiple
|
||||
placeholder="选择部门(可多选),或选「全部」(选填)" style="width: 100%"
|
||||
>
|
||||
<t-option v-for="opt in demandSuitableOptions" :key="opt" :value="opt" :label="opt" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="计划培训月份" name="planned_month">
|
||||
<t-select
|
||||
@@ -197,7 +206,7 @@
|
||||
:autosize="{ minRows: 6 }"
|
||||
placeholder="或粘贴需求行:课程名称[,计划培训月份如 3] (支持中英文逗号)"
|
||||
/>
|
||||
<div class="form-hint">模板列对应:编号/部门/课程名称/适合人员/地点/内/外培训(下拉选择内部或外部)/计划培训月份(1~12,下拉选择)/讲师/备注;费用列已移除;备注右侧为「调研维度与培训策划要求」说明列,无需填写;适合人员可填多人(、/,分隔),讲师可填系统员工(按姓名自动匹配并带出部门)或外部讲师姓名;导入后统一为「待核验」,由部门经理核验确认。</div>
|
||||
<div class="form-hint">模板列对应:编号/部门/课程名称/适合人员/地点/内/外培训(下拉选择内部或外部)/计划培训月份(1~12,下拉选择)/讲师/备注;费用列已移除;备注右侧为「调研维度与培训策划要求」说明列,无需填写;适合人员可填多人(、/,分隔),讲师可填系统员工(按姓名自动匹配)或外部讲师姓名;部门列必须为导入人本人部门,留空默认本人部门,其余部门整批拒绝导入;课程按名称精准匹配课程管理,未匹配到自动新增该课程(待审核);导入后统一为「待核验」,由部门经理核验确认。</div>
|
||||
<template #footer>
|
||||
<t-button theme="primary" :loading="saving" @click="onImportDemands">导入粘贴内容</t-button>
|
||||
</template>
|
||||
@@ -235,7 +244,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import * as XLSX from 'xlsx'
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
@@ -332,13 +341,35 @@ const demandForm = ref({
|
||||
remark: '',
|
||||
})
|
||||
|
||||
// 适合人员多选值(000159 部门多选口径):form.post_scope 存「、」join 后的串,
|
||||
// 选项交互走本数组;「全部」与具体部门互斥。
|
||||
const demandSuitableList = ref<string[]>([])
|
||||
const splitSuitable = (v: string) =>
|
||||
(v || '').split(/[、,,;;]/).map((s) => s.trim()).filter(Boolean)
|
||||
watch(demandSuitableList, (list, prev) => {
|
||||
if (list.includes('全部') && list.length > 1) {
|
||||
demandSuitableList.value = (prev || []).includes('全部') ? list.filter((v) => v !== '全部') : ['全部']
|
||||
}
|
||||
})
|
||||
// 适合人员选项:全部 + 各部门名(存量自由文本值保留可选)
|
||||
const demandSuitableOptions = computed(() => {
|
||||
const opts = ['全部', ...depts.value.map((d) => d.name)]
|
||||
for (const v of splitSuitable(demandForm.value.post_scope)) {
|
||||
if (!opts.includes(v)) opts.push(v)
|
||||
}
|
||||
return opts
|
||||
})
|
||||
|
||||
// 选定课程自动带出(000156):分类/适合人员/讲师随课程回填,均可再改;
|
||||
// 改选讲师保存后由后端同步回写课程管理(课程管理讲师随需求追加为所选人员)
|
||||
const onDemandCourseChange = (name: unknown) => {
|
||||
const course = libraryCourses.value.find((c) => c.name === name)
|
||||
if (!course) return
|
||||
demandForm.value.category = course.category || ''
|
||||
if (course.suitable_members) demandForm.value.post_scope = course.suitable_members
|
||||
if (course.suitable_members) {
|
||||
demandForm.value.post_scope = course.suitable_members
|
||||
demandSuitableList.value = splitSuitable(course.suitable_members)
|
||||
}
|
||||
const lecturerValue = course.lecturer_id || course.lecturer_external || ''
|
||||
if (lecturerValue) {
|
||||
if (!lecturers.value.some((l) => l.id === lecturerValue)) {
|
||||
@@ -552,6 +583,7 @@ const onOpenDemandForm = () => {
|
||||
lecturer: '',
|
||||
remark: '',
|
||||
}
|
||||
demandSuitableList.value = []
|
||||
demandFormVisible.value = true
|
||||
}
|
||||
|
||||
@@ -588,6 +620,8 @@ const onEditDemand = (row: TrainingDemand) => {
|
||||
lecturer: lecturerValue,
|
||||
remark: row.remark || '',
|
||||
}
|
||||
// 适合人员多选回显(000159):落库串「、」join → 数组
|
||||
demandSuitableList.value = splitSuitable(demandForm.value.post_scope)
|
||||
demandFormVisible.value = true
|
||||
}
|
||||
|
||||
@@ -599,10 +633,14 @@ const onSaveDemand = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
// 计划培训月份与收集年度合成「YYYY-M」入库,并回填期望月份;
|
||||
// 编辑旧数据且未选月份时保留原计划培训值;讲师解析为 id 或外部姓名
|
||||
// 编辑旧数据且未选月份时保留原计划培训值;讲师解析为 id 或外部姓名;
|
||||
// 适合人员多选 → 「、」join 落库(000159)
|
||||
const { lecturer, planned_month, ...rest } = demandForm.value
|
||||
rest.post_scope = demandSuitableList.value.join('、')
|
||||
const month = Number(planned_month) || 0
|
||||
const isEdit = Boolean(demandForm.value.id)
|
||||
// 课程管理中是否已有同名课程(000158:无则提交时自动新增待核验课程)
|
||||
const courseExisted = libraryCourses.value.some((c) => c.name === demandForm.value.course_name)
|
||||
await saveDemand({
|
||||
...rest,
|
||||
...resolveLecturer(lecturer),
|
||||
@@ -612,7 +650,13 @@ const onSaveDemand = async () => {
|
||||
expect_month: month || (isEdit ? editOriginalPlanned.value.expect_month : 0) || undefined,
|
||||
year: selectedYear.value,
|
||||
})
|
||||
MessagePlugin.success(demandForm.value.id ? '需求已更新' : '需求已提交,待核验')
|
||||
MessagePlugin.success(
|
||||
demandForm.value.id
|
||||
? '需求已更新'
|
||||
: courseExisted
|
||||
? '需求已提交,待核验'
|
||||
: `需求已提交,待核验;课程《${demandForm.value.course_name}》已自动新增到课程管理(待审核)`,
|
||||
)
|
||||
demandFormVisible.value = false
|
||||
loadAll()
|
||||
} catch (e: any) {
|
||||
@@ -668,8 +712,9 @@ const onImportDemands = async () => {
|
||||
importDemandsVisible.value = false
|
||||
importDemandsText.value = ''
|
||||
loadAll()
|
||||
} catch {
|
||||
MessagePlugin.error('导入失败,请检查格式')
|
||||
} catch (e: any) {
|
||||
// 透出后端校验详情(000158:部门归属/课程自动匹配等口径错误)
|
||||
MessagePlugin.error(apiErrorMessage(e, '导入失败,请检查格式'))
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
@@ -747,7 +792,8 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
let skippedRows = 0
|
||||
let lecturerHits = 0
|
||||
let externalLecturers = 0
|
||||
let deptFromLecturer = 0
|
||||
// 部门口径(000158):Excel 全部行必须为导入人本人部门,前端预检不过不提交
|
||||
const deptViolations: string[] = []
|
||||
// 讲师按**全部在职员工**姓名匹配(不限于讲师名册;名单即 openCollect 的员工档案),
|
||||
// 匹配不到的姓名作为外部讲师落 lecturer_external,列表讲师列照常显示
|
||||
const ensureMembers = async () => {
|
||||
@@ -763,24 +809,23 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
}
|
||||
}
|
||||
await ensureMembers()
|
||||
dataRows.forEach((row) => {
|
||||
dataRows.forEach((row, idx) => {
|
||||
const courseName = (row['课程名称'] || '').trim()
|
||||
if (!courseName) {
|
||||
skippedRows += 1
|
||||
return
|
||||
}
|
||||
// 部门单位(收集模板)/主办单位(旧版)/部门(需求表模板)按部门名册匹配;未匹配留空
|
||||
// 部门单位(收集模板)/主办单位(旧版)/部门(需求表模板)按部门名册匹配;
|
||||
// 000158:行部门必须为导入人本人部门——非空但未匹配到、或与本人部门
|
||||
// 不一致即记违规,整批拒绝;部门列留空的行由后端默认导入人部门。
|
||||
let deptId = ''
|
||||
let deptMatched = false
|
||||
const deptName = (row['部门单位'] || row['主办单位'] || row['部门'] || '').trim()
|
||||
if (deptName) {
|
||||
const hit = depts.value.find((d) => d.name === deptName) || depts.value.find((d) => deptName.includes(d.name))
|
||||
if (hit) {
|
||||
deptId = hit.id
|
||||
deptMatched = true
|
||||
}
|
||||
if (hit) deptId = hit.id
|
||||
if (!deptId || deptId !== myDeptId.value) deptViolations.push(`第${idx + 1}行(${deptName})`)
|
||||
}
|
||||
// 讲师:员工档案姓名精确匹配→关联并在列表带出姓名,行内部门未匹配时带出讲师部门;
|
||||
// 讲师:员工档案姓名精确匹配→关联并在列表带出姓名;
|
||||
// 非系统员工→落外部讲师姓名,讲师列照常显示
|
||||
let lecturerId = ''
|
||||
let lecturerExternal = ''
|
||||
@@ -790,10 +835,6 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
if (hit && hit.user_id) {
|
||||
lecturerId = hit.user_id
|
||||
lecturerHits += 1
|
||||
if (!deptMatched && hit.dept_id) {
|
||||
deptId = hit.dept_id
|
||||
deptFromLecturer += 1
|
||||
}
|
||||
} else {
|
||||
lecturerExternal = lecturerName
|
||||
externalLecturers += 1
|
||||
@@ -813,6 +854,7 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
lecturer_id: lecturerId,
|
||||
lecturer_external: lecturerExternal || undefined,
|
||||
dept_id: deptId,
|
||||
dept_name: deptName || undefined,
|
||||
planned_time: plannedMonth.planned || undefined,
|
||||
expect_month: plannedMonth.month || undefined,
|
||||
remark: (row['备注'] || '').trim(),
|
||||
@@ -822,24 +864,36 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
MessagePlugin.warning('模板中没有可导入的课程行,请先填写课程名称')
|
||||
return
|
||||
}
|
||||
// 000158:存在非本人部门的行时整批拒绝(后端同口径兜底校验)
|
||||
if (deptViolations.length) {
|
||||
MessagePlugin.error(
|
||||
`导入失败:${deptViolations.join('、')}部门与您所在部门(${myDeptName.value || '未知'})不一致,仅可导入本人部门的需求表`,
|
||||
)
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const imported = unwrap(await importDemands(items)) as { imported: number; notified?: number } | null
|
||||
const imported = unwrap(await importDemands(items)) as {
|
||||
imported: number
|
||||
notified?: number
|
||||
courses_created?: number
|
||||
} | null
|
||||
MessagePlugin.success(
|
||||
`已从模板导入 ${items.length} 条需求(${titleYear}年度)` +
|
||||
(lecturerHits || externalLecturers
|
||||
? `,讲师匹配 ${lecturerHits} 人${externalLecturers ? `,外部讲师 ${externalLecturers} 人` : ''}`
|
||||
: '') +
|
||||
(deptFromLecturer ? `(其中 ${deptFromLecturer} 条部门按讲师带出)` : '') +
|
||||
(skippedRows ? `,另有 ${skippedRows} 行未填课程名称已跳过` : '') +
|
||||
(imported?.courses_created ? `,自动新增待审核课程 ${imported.courses_created} 门` : '') +
|
||||
(imported?.notified ? `,已推送 ${imported.notified} 位部门经理核验` : ''),
|
||||
)
|
||||
importDemandsVisible.value = false
|
||||
// 导入年份与当前查看年份不同(模板为下一年度)时切到导入年份展示
|
||||
if (titleYear !== selectedYear.value) selectedYear.value = titleYear
|
||||
loadAll()
|
||||
} catch {
|
||||
MessagePlugin.error('导入失败,请稍后重试')
|
||||
} catch (e: any) {
|
||||
// 透出后端校验详情(000158:部门归属/课程自动匹配等口径错误)
|
||||
MessagePlugin.error(apiErrorMessage(e, '导入失败,请稍后重试'))
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user