feat(training): 企业培训迭代:推送深链接与签名下载、课程管理修复与收集模板调整
推送域(000155):
- 广播通知支持 link_url:demand_collect 场景自动签发教育训练需求表模板
匿名下载直链(HMAC token,20 天有效,免登录路由),企微消息尾部拼
「下载模板 + 查看更多详情」链接;站内文本保持纯文本不受影响
- 配置中心新增「推送链接基址」(notify_link_base_url,多入口/内外网部署固定
权威地址,留空跟随推送人访问地址)与「年培训计划收集推送文案」
(demand_collect_*,{year} 渲染收集年度);空标题/内容按模板回落渲染
- 迁移 000155:tr_training_notifications 增 link_url/link_token 列
课程管理:
- 修复点【发布/下线】报「不支持的操作」:动作取值兼容字面量路由(FullPath
末段)与 :action 通配两种注册形态
- 列表新增「创建人」列:creator_id 联查 users 带出姓名,导出 Excel 同步;
新增课程「所属部门」默认当前登录用户所在部门
- 导入加固:表头归一化 + 别名模糊匹配(兼容内置模板/旧口径/自定义模板变体);
导入与新增行支持按部门名兜底解析为 id(前端名册未命中时传 owner_dept_name)
年培训计划:
- 需求列表新增「创建人/创建时间」列(submitter_id 联查 users 带出姓名)
- 收集模板调整:下载时动态删除「培训费用(RMB)」列(旧版自定义模板同步归一,
右侧列/合并/下拉随删列平移);备注右侧追加「调研维度/培训策划要求」说明列
(合并至数据区末行,自动换行带边框,已带说明的自定义模板不覆盖)
开发工具:
- air 热重载适配 Windows:构建收敛到 scripts/air_build.sh(规避 air 经
PowerShell 执行不支持 bash 命令替换),产物改 .exe 后缀;CGO_CFLAGS 取
持久化值并集追加,不覆盖 go env -w 的头文件包含路径
This commit is contained in:
1 parent
242dd7e1a6
commit
4e25fce9aa
30 files changed
+1150
-143
No files matched your search
@@ -70,6 +70,8 @@
|
||||
<t-tag v-if="row.file_name" theme="success" variant="light" size="small" class="material-file-tag">附件</t-tag>
|
||||
</template>
|
||||
<template #created_at="{ row }">{{ fmtBeijingTime(row.created_at) || '-' }}</template>
|
||||
<!-- 创建人(联查 users):记录课程由谁录入 -->
|
||||
<template #creator_name="{ row }">{{ row.creator_name || '-' }}</template>
|
||||
<template #publish_status="{ row }">
|
||||
<t-tag
|
||||
:theme="row.publish_status === 'published' ? 'success' : row.publish_status === 'offline' ? 'default' : 'warning'"
|
||||
@@ -452,6 +454,7 @@ import {
|
||||
exportCourseLibrary,
|
||||
fetchCourseCategories,
|
||||
generateLibraryCourseQuestions,
|
||||
getMyProfile,
|
||||
getTrainingKnowledgeBases,
|
||||
importCourseLibrary,
|
||||
importGeneratedQuestionBank,
|
||||
@@ -487,6 +490,8 @@ const members = ref<TrainingMember[]>([])
|
||||
const depts = ref<TrainingDept[]>([])
|
||||
// 课程分类选项 = 配置中心「课程分类」字典(fetchCourseCategories 缺失回退默认)
|
||||
const configCategories = ref<string[]>([])
|
||||
// 本人所在部门 id:新增课程「所属部门」默认当前登录用户所在部门(getMyProfile)
|
||||
const myDeptId = ref('')
|
||||
|
||||
// ---- 查询条件(编号/名称/分类/类型/形式;列表全量加载,本地过滤) ----
|
||||
const filters = ref({ keyword: '', category: '', type: '', mode: '' })
|
||||
@@ -530,6 +535,8 @@ const columns = [
|
||||
// 发布状态(000154):已发布的课程进入培训中心「和信课程」目录
|
||||
{ colKey: 'publish_status', title: '发布状态', width: 90 },
|
||||
{ colKey: 'created_at', title: '创建时间', width: 140 },
|
||||
// 创建人(联查 users):记录课程录入人员
|
||||
{ colKey: 'creator_name', title: '创建人', width: 96 },
|
||||
{ colKey: 'op', title: '操作', width: 280, fixed: 'right' },
|
||||
]
|
||||
|
||||
@@ -539,16 +546,19 @@ const lecturerText = (row: TrainingLibraryCourse) =>
|
||||
const loadAll = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const [lib, m, d, cats] = await Promise.all([
|
||||
const [lib, m, d, cats, me] = await Promise.all([
|
||||
listCourseLibrary({ page_size: 500 }),
|
||||
listMembers({ page_size: 500 }).catch(() => null),
|
||||
listDepts().catch(() => null),
|
||||
fetchCourseCategories(),
|
||||
// 本人档案:新增课程「所属部门」默认当前登录用户所在部门
|
||||
getMyProfile().catch(() => null),
|
||||
])
|
||||
items.value = unwrap(lib)?.items || []
|
||||
members.value = (m && unwrap(m)?.items) || []
|
||||
depts.value = (d && unwrap(d)) || []
|
||||
configCategories.value = cats
|
||||
myDeptId.value = (me && unwrap(me)?.dept_id) || ''
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -670,7 +680,8 @@ const openForm = (row?: TrainingLibraryCourse) => {
|
||||
id: row?.id || '',
|
||||
code: row?.code || '',
|
||||
name: row?.name || '',
|
||||
owner_dept_id: row?.owner_dept_id || '',
|
||||
// 新增默认当前登录用户所在部门;编辑保持原部门
|
||||
owner_dept_id: row?.owner_dept_id || (row ? '' : myDeptId.value),
|
||||
description: row?.description || '',
|
||||
suitable_members: row?.suitable_members || '',
|
||||
category: row?.category || '',
|
||||
@@ -830,6 +841,38 @@ const normMode = (raw: string): 'offline' | 'online' => (/线上/.test(raw) ? 'o
|
||||
// 课件收集列的占位文案(已有课件/暂无课件/无等)是状态标记,不落名称登记
|
||||
const isNoMaterial = (raw: string) => /^(已有课件|暂无课件|暂无|无课件|无)$/.test(raw)
|
||||
|
||||
// 表头键归一:去空白与全/半角括号、冒号等标点并转小写(兼容「课程说明(选填)」
|
||||
// 「时长:(学时)」这类自定义模板变体;配置中心上传的自定义模板表头可能带修饰)
|
||||
const normHeaderKey = (s: string) => String(s).trim().toLowerCase().replace(/[\s::,,、。.·()()[\]【】-]/g, '')
|
||||
|
||||
// 列名别名表(归一后口径):先精确命中,再按「表头包含别名」兜底,
|
||||
// 覆盖内置模板/旧口径/自定义模板的常见列名变体
|
||||
const IMPORT_HEADER_ALIASES: Record<string, string[]> = {
|
||||
name: ['课程名称', '名称'],
|
||||
dept: ['所属部门', '主办单位', '部门'],
|
||||
description: ['课程说明', '说明', '课程简介', '简介'],
|
||||
suitable: ['适合人员', '参加人员', '适合对象', '参训人员'],
|
||||
category: ['课程分类', '分类'],
|
||||
type: ['类型必修课或选修课', '类型'],
|
||||
mode: ['线上或线下', '线上线下', '形式'],
|
||||
lecturer: ['讲师姓名', '授课讲师', '培训讲师', '讲师'],
|
||||
hours: ['时长学时', '时长'],
|
||||
material: ['课件收集', '课件'],
|
||||
}
|
||||
|
||||
// 按别名组从归一化行中取值:别名精确 → 表头包含别名(首个命中),未命中返回 ''
|
||||
const pickImportColumn = (row: Record<string, string>, aliases: string[]) => {
|
||||
for (const a of aliases) {
|
||||
if (row[a]) return row[a]
|
||||
}
|
||||
const keys = Object.keys(row)
|
||||
for (const a of aliases) {
|
||||
const hit = keys.find((k) => k.includes(a))
|
||||
if (hit && row[hit]) return row[hit]
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
const onImportExcel = async (e: Event) => {
|
||||
const input = e.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
@@ -837,13 +880,13 @@ const onImportExcel = async (e: Event) => {
|
||||
if (!file) return
|
||||
try {
|
||||
const wb = XLSX.read(await file.arrayBuffer())
|
||||
// 定位含「课程名称」表头的工作表;表头键做空白归一(兼容内含空格的列名)
|
||||
// 定位含「课程名称」表头的工作表;表头键做归一(空白/全半角标点,见 normHeaderKey)
|
||||
let dataRows: Record<string, string>[] | null = null
|
||||
for (const name of wb.SheetNames) {
|
||||
const sheetRows = XLSX.utils.sheet_to_json<string[]>(wb.Sheets[name], { header: 1, raw: false, defval: '' })
|
||||
const headerIdx = sheetRows.findIndex((r) => r.some((c) => String(c).trim() === '课程名称'))
|
||||
const headerIdx = sheetRows.findIndex((r) => r.some((c) => normHeaderKey(String(c)) === '课程名称'))
|
||||
if (headerIdx < 0) continue
|
||||
const header = (sheetRows[headerIdx] || []).map((c) => String(c).trim().replace(/\s+/g, ''))
|
||||
const header = (sheetRows[headerIdx] || []).map((c) => normHeaderKey(String(c)))
|
||||
dataRows = sheetRows.slice(headerIdx + 1).map((arr) => {
|
||||
const row: Record<string, string> = {}
|
||||
header.forEach((h, i) => {
|
||||
@@ -857,7 +900,8 @@ const onImportExcel = async (e: Event) => {
|
||||
MessagePlugin.error('未找到「课程名称」表头,请使用下载的课程管理导入模板填写')
|
||||
return
|
||||
}
|
||||
// 主办单位(所属部门)按部门名册匹配:名称精确 → 包含(与需求导入同口径),未匹配留空
|
||||
// 主办单位(所属部门)按部门名册匹配:名称精确 → 包含(与需求导入同口径),
|
||||
// 未匹配时仍把部门名传给后端(服务端按组织架构兜底解析为 id)
|
||||
const matchDept = (deptName: string) =>
|
||||
depts.value.find((d) => d.name === deptName) || depts.value.find((d) => deptName.includes(d.name))
|
||||
// 讲师按全部在职员工姓名精确匹配;未命中落外部讲师姓名(与需求导入同口径)
|
||||
@@ -867,13 +911,13 @@ const onImportExcel = async (e: Event) => {
|
||||
let externalLecturers = 0
|
||||
let deptHits = 0
|
||||
for (const row of dataRows) {
|
||||
const name = (row['课程名称'] || '').trim()
|
||||
const name = pickImportColumn(row, IMPORT_HEADER_ALIASES.name)
|
||||
if (!name) {
|
||||
skippedRows += 1
|
||||
continue
|
||||
}
|
||||
let ownerDeptId = ''
|
||||
const deptName = (row['所属部门'] || row['主办单位'] || '').trim()
|
||||
const deptName = pickImportColumn(row, IMPORT_HEADER_ALIASES.dept)
|
||||
if (deptName) {
|
||||
const hit = matchDept(deptName)
|
||||
if (hit) {
|
||||
@@ -883,7 +927,7 @@ const onImportExcel = async (e: Event) => {
|
||||
}
|
||||
let lecturerId = ''
|
||||
let lecturerExternal = ''
|
||||
const lecturerName = (row['讲师'] || '').trim()
|
||||
const lecturerName = pickImportColumn(row, IMPORT_HEADER_ALIASES.lecturer)
|
||||
if (lecturerName) {
|
||||
const hit = members.value.find((m) => (m.user_name || '') === lecturerName)
|
||||
if (hit?.user_id) {
|
||||
@@ -894,17 +938,18 @@ const onImportExcel = async (e: Event) => {
|
||||
externalLecturers += 1
|
||||
}
|
||||
}
|
||||
const hoursRaw = Number.parseFloat((row['时长(学时)'] || row['时长'] || '').replace(/[^\d.]/g, ''))
|
||||
const materialRaw = (row['课件收集'] || row['课件'] || '').trim()
|
||||
const hoursRaw = Number.parseFloat(pickImportColumn(row, IMPORT_HEADER_ALIASES.hours).replace(/[^\d.]/g, ''))
|
||||
const materialRaw = pickImportColumn(row, IMPORT_HEADER_ALIASES.material)
|
||||
// 类型/线上或线下:模板下拉列为全称表头(类型(必修课或选修课)/线上或线下),旧口径短表头同样兼容
|
||||
itemsPayload.push({
|
||||
name,
|
||||
owner_dept_id: ownerDeptId || undefined,
|
||||
description: (row['课程说明'] || row['说明'] || '').trim(),
|
||||
suitable_members: (row['适合人员'] || row['参加人员'] || '').trim(),
|
||||
category: (row['课程分类'] || row['分类'] || '').trim(),
|
||||
type: normType(row['类型(必修课或选修课)'] || row['类型'] || ''),
|
||||
mode: normMode(row['线上或线下'] || row['线上/线下'] || ''),
|
||||
owner_dept_name: deptName || undefined,
|
||||
description: pickImportColumn(row, IMPORT_HEADER_ALIASES.description),
|
||||
suitable_members: pickImportColumn(row, IMPORT_HEADER_ALIASES.suitable),
|
||||
category: pickImportColumn(row, IMPORT_HEADER_ALIASES.category),
|
||||
type: normType(pickImportColumn(row, IMPORT_HEADER_ALIASES.type)),
|
||||
mode: normMode(pickImportColumn(row, IMPORT_HEADER_ALIASES.mode)),
|
||||
lecturer_id: lecturerId || undefined,
|
||||
lecturer_external: lecturerExternal || undefined,
|
||||
hours: Number.isFinite(hoursRaw) && hoursRaw > 0 ? hoursRaw : 0,
|
||||
|
||||
Reference in new issue
Block a user