feat(training): 企业培训迭代:核验权限收窄、课程发布状态与培训中心改版
需求域: - 需求导入修复内/外培训与外部讲师落库;按模板标题年入库(年-月一致) - 核验确认收窄为「需求归属部门+经理职称角色」,越权提示联系部门经理 - 确认转月计划后自动推送讲师/课长维护;导入后自动推送部门经理核验(站内+企微) 课程域: - 课程管理发布状态字段(迁移000154)+发布/下线;培训中心「和信课程」目录 - 需求讲师改选后回写课程管理;确认同步带出适合人员/课件/试题 - 月计划详情课件/试题更换(上传/知识库选择/题库换绑)回写课程管理, 无关联条目的存量计划自动创建课程条目 模板与表单: - 教育训练需求表:适合人员/内-外培训口径;部门联动课程下拉; 适合人员/讲师按所选课程自动带出;在线提报课程下拉(本部门)自动带出分类/讲师/适合人员 页面与权限: - 培训中心页签重组(和信课程/我的培训/我的考试),移除线上/线下页签 - 数据驾驶舱迁侧栏(职称角色之下);职称角色迁至更多工具配置中心之后 - 配置中心/职称角色对经理开放;页签「职称角色」更名「角色权限」 - 修复年度下拉空白(TDesign options 需对象数组)、月计划列表地点兜底 其他: 培训预览端口修正与 dev:training 脚本;tmp-extract-duckdb 加入 gitignore
This commit is contained in:
1 parent
aae041a0b4
commit
242dd7e1a6
47 files changed
+5882
-1134
No files matched your search
@@ -15,47 +15,51 @@ export const TRAINING_MOCK = {
|
||||
{ id: 'dept-a', tenant_id: 1, parent_id: '', name: '冲压车间', code: 'CY', sort: 1 },
|
||||
{ id: 'dept-b', tenant_id: 1, parent_id: '', name: '技术部', code: 'JS', sort: 2 },
|
||||
],
|
||||
demands: [
|
||||
{ id: 'd1', code: `AP-${NOW.getFullYear()}-0001`, year: NOW.getFullYear(), dept_id: 'dept-a', dept_name: '冲压车间', submitter_id: 'm1', course_name: '叉车年度复训', post_scope: '叉车操作员', lecturer_name: '', planned_time: `${NOW.getFullYear() + 1}-3`, train_type: '内部', location: '一楼展厅', remark: '', check_status: 'pending', check_msg: '', status: 'submitted' },
|
||||
{ id: 'd2', code: `AP-${NOW.getFullYear()}-0002`, year: NOW.getFullYear(), dept_id: 'dept-b', dept_name: '技术部', submitter_id: 'm3', course_name: '品质工具(APQP)专题', post_scope: '品质岗', lecturer_name: '', planned_time: `${NOW.getFullYear() + 1}-5`, train_type: '外部', location: '技术部实训区', remark: '', check_status: 'passed', check_msg: '', status: 'confirmed' },
|
||||
],
|
||||
courses: [
|
||||
{
|
||||
id: 'c1', code: 'TR-001', name: '冲压B车间安全生产教育培训', mode: 'online', type: 'required',
|
||||
lecturer_id: 'm1', hours: 0.75, credits: 1, exam_enabled: true, dept_ids: ['dept-a'],
|
||||
id: 'c1', code: 'CRS-0001', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0001`, name: '冲压B车间安全生产教育培训', mode: 'online', type: 'required',
|
||||
lecturer_id: 'u-m1', hours: 0.75, credits: 1, exam_enabled: true, dept_ids: ['dept-a'],
|
||||
post_scope: '全员必修', description: '', material_ids: ['mt1'], tags: ['安全'], status: 'published',
|
||||
creator_id: '', created_at: month(0, 2), updated_at: month(0, 2),
|
||||
},
|
||||
{
|
||||
id: 'c2', code: 'TR-002', name: '六轴机械手调试培训', mode: 'offline', type: 'required',
|
||||
lecturer_id: 'm2', hours: 4, credits: 2, exam_enabled: false, dept_ids: ['dept-b'],
|
||||
id: 'c2', code: 'CRS-0002', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0002`, name: '六轴机械手调试培训', mode: 'offline', type: 'required',
|
||||
lecturer_id: 'u-m2', hours: 4, credits: 2, exam_enabled: false, dept_ids: ['dept-b'],
|
||||
post_scope: '技术级以上', description: '', material_ids: [], tags: ['技能'], status: 'published',
|
||||
creator_id: '', created_at: month(-1, 20), updated_at: month(-1, 20),
|
||||
},
|
||||
{
|
||||
id: 'c3', code: 'TR-003', name: 'TOPGP系统培训', mode: 'online', type: 'elective',
|
||||
lecturer_id: 'm1', hours: 0.5, credits: 1, exam_enabled: false, dept_ids: [],
|
||||
id: 'c3', code: 'CRS-0003', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0003`, name: 'TOPGP系统培训', mode: 'online', type: 'elective',
|
||||
lecturer_id: 'u-m1', hours: 0.5, credits: 1, exam_enabled: false, dept_ids: [],
|
||||
post_scope: '', description: '', material_ids: [], tags: ['系统'], status: 'published',
|
||||
creator_id: '', created_at: month(-2, 11), updated_at: month(-2, 11),
|
||||
},
|
||||
{
|
||||
id: 'c4', code: 'TR-004', name: '产品品质培训(冲压)', mode: 'online', type: 'required',
|
||||
lecturer_id: 'm1', hours: 0.67, credits: 1, exam_enabled: true, dept_ids: ['dept-a'],
|
||||
id: 'c4', code: 'CRS-0004', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0004`, name: '产品品质培训(冲压)', mode: 'online', type: 'required',
|
||||
lecturer_id: 'u-m1', hours: 0.67, credits: 1, exam_enabled: true, dept_ids: ['dept-a'],
|
||||
post_scope: '品质岗', description: '', material_ids: ['mt2', 'mt3'], tags: ['品质'], status: 'published',
|
||||
creator_id: '', created_at: month(0, 28), updated_at: month(0, 28),
|
||||
},
|
||||
{
|
||||
id: 'c5', code: 'TR-005', name: '组装安全生产教育训练', mode: 'offline', type: 'required',
|
||||
lecturer_id: 'm3', hours: 2, credits: 1, exam_enabled: false, dept_ids: ['dept-a'],
|
||||
id: 'c5', code: 'CRS-0005', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0005`, name: '组装安全生产教育训练', mode: 'offline', type: 'required',
|
||||
lecturer_id: 'u-m3', hours: 2, credits: 1, exam_enabled: false, dept_ids: ['dept-a'],
|
||||
post_scope: '全员必修', description: '', material_ids: [], tags: ['安全'], status: 'published',
|
||||
creator_id: '', created_at: month(0, 5), updated_at: month(0, 5),
|
||||
},
|
||||
{
|
||||
id: 'c6', code: 'TR-006', name: '新员工入职引导', mode: 'online', type: 'required',
|
||||
lecturer_id: 'm3', hours: 1, credits: 1, exam_enabled: false, dept_ids: [],
|
||||
id: 'c6', code: 'CRS-0006', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0006`, name: '新员工入职引导', mode: 'online', type: 'required',
|
||||
lecturer_id: 'u-m3', hours: 1, credits: 1, exam_enabled: false, dept_ids: [],
|
||||
post_scope: '全员必修', description: '', material_ids: ['mt4'], tags: ['入职'], status: 'published',
|
||||
creator_id: '', created_at: month(0, 30), updated_at: month(0, 30),
|
||||
},
|
||||
// 草稿课程:目录页仅展示已发布课程,此条应被前端过滤
|
||||
{
|
||||
id: 'c7', code: 'TR-007', name: '模具保养必修课(草稿)', mode: 'offline', type: 'required',
|
||||
lecturer_id: 'm2', hours: 2, credits: 1, exam_enabled: false, dept_ids: [],
|
||||
id: 'c7', code: 'CRS-0007', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0007`, name: '模具保养必修课(草稿)', mode: 'offline', type: 'required',
|
||||
lecturer_id: 'u-m2', hours: 2, credits: 1, exam_enabled: false, dept_ids: [],
|
||||
post_scope: '', description: '', material_ids: [], tags: [], status: 'draft',
|
||||
creator_id: '', created_at: month(0, 1), updated_at: month(0, 1),
|
||||
},
|
||||
@@ -138,9 +142,9 @@ export const TRAINING_MOCK = {
|
||||
generated_at: '',
|
||||
},
|
||||
sessions: [
|
||||
{ id: 's1', course_id: 'c2', month_plan_id: '', year: NOW.getFullYear(), month: NOW.getMonth() + 1, start_at: month(1, 12), end_at: month(1, 12), location: '3号厂房 · 二楼培训室', online_url: '', capacity: 0, lecturer_id: 'm2', status: 'scheduled' },
|
||||
{ id: 's2', course_id: 'c2', month_plan_id: '', year: NOW.getFullYear() - 1, month: 12, start_at: month(-2, 8), end_at: month(-2, 8), location: '技术部实训区', online_url: '', capacity: 0, lecturer_id: 'm2', status: 'finished' },
|
||||
{ id: 's3', course_id: 'c5', month_plan_id: '', year: NOW.getFullYear() - 1, month: 10, start_at: month(-1, 15), end_at: month(-1, 15), location: '一楼展厅', online_url: '', capacity: 0, lecturer_id: 'm3', status: 'finished' },
|
||||
{ id: 's1', course_id: 'c2', month_plan_id: '', year: NOW.getFullYear(), month: NOW.getMonth() + 1, start_at: month(1, 12), end_at: month(1, 12), location: '3号厂房 · 二楼培训室', online_url: '', capacity: 0, lecturer_id: 'u-m2', status: 'scheduled' },
|
||||
{ id: 's2', course_id: 'c2', month_plan_id: '', year: NOW.getFullYear() - 1, month: 12, start_at: month(-2, 8), end_at: month(-2, 8), location: '技术部实训区', online_url: '', capacity: 0, lecturer_id: 'u-m2', status: 'finished' },
|
||||
{ id: 's3', course_id: 'c5', month_plan_id: '', year: NOW.getFullYear() - 1, month: 10, start_at: month(-1, 15), end_at: month(-1, 15), location: '一楼展厅', online_url: '', capacity: 0, lecturer_id: 'u-m3', status: 'finished' },
|
||||
],
|
||||
hrDashboard: {
|
||||
demand_progress: [
|
||||
@@ -159,6 +163,52 @@ export const TRAINING_MOCK = {
|
||||
},
|
||||
}
|
||||
|
||||
// 课程管理(课程资产主数据):预览 harness 演示数据(编号 CRS-#### 与后端一致)
|
||||
const COURSE_LIBRARY_MOCK = [
|
||||
{ id: 'lib-1', code: 'CRS-0001', name: '新员工入职通识培训', owner_dept_id: 'dept-b', owner_dept_name: '技术部', description: '公司制度、企业文化与办公系统入门', suitable_members: '新入职员工', category: '企业文化与制度类', type: 'required', mode: 'online', lecturer_id: 'u-m1', hours: 2, material_name: '入职通识手册.pptx', file_name: '', file_size: 0, lecturer_name: '', created_at: month(-3, 1), updated_at: month(0, 2) },
|
||||
{ id: 'lib-2', code: 'CRS-0002', name: '冲压设备安全操作实操', owner_dept_id: 'dept-a', owner_dept_name: '冲压车间', description: '冲压机安全操作与应急处置实操训练', suitable_members: '冲压操作员', category: '安全与健康类', type: 'required', mode: 'offline', lecturer_id: 'u-m2', hours: 4, material_name: '安全操作规程.docx、实操考核表.xlsx', file_name: '', file_size: 0, lecturer_name: '', created_at: month(-2, 5), updated_at: month(-1, 8) },
|
||||
{ id: 'lib-3', code: 'CRS-0003', name: 'TS16949 质量体系知识', owner_dept_id: '', owner_dept_name: '', description: 'IATF 16949 体系条款与内审要点', suitable_members: '品质岗', category: '专业技能类', type: 'elective', mode: 'online', lecturer_id: '', lecturer_external: '王顾问', hours: 3, material_name: '', file_name: '', file_size: 0, lecturer_name: '', created_at: month(-1, 12), updated_at: month(-1, 12) },
|
||||
]
|
||||
|
||||
// 课程管理 · 试题管理(000153):题库与题目演示数据(编号 QB-####)
|
||||
const QUESTION_BANKS_MOCK = [
|
||||
{ id: 'b1', code: 'QB-0001', name: '新员工入职通识题库', dept_id: '', course_id: '', library_course_id: 'lib-1', knowledge_id: '', question_count: 2, created_at: month(0, 3), updated_at: month(0, 3) },
|
||||
{ id: 'b2', code: 'QB-0002', name: '冲压安全操作题库', dept_id: '', course_id: '', library_course_id: 'lib-2', knowledge_id: '', question_count: 1, created_at: month(0, 6), updated_at: month(0, 6) },
|
||||
]
|
||||
const QUESTIONS_MOCK: Record<string, unknown[]> = {
|
||||
b1: [
|
||||
{ id: 'q1', bank_id: 'b1', seq_no: 1, type: 'single', stem: '公司带薪年休假的天数由什么确定?', options: ['A. 入职年限', 'B. 累计工作年限', 'C. 岗位等级', 'D. 部门规定'], answer: 'B', score: 5, difficulty: 2, knowledge_point: '考勤休假', analysis: '' },
|
||||
{ id: 'q2', bank_id: 'b1', seq_no: 2, type: 'multiple', stem: '入职引导包含哪些内容?', options: ['A. 企业文化', 'B. 安全规范', 'C. 办公系统', 'D. 薪酬谈判'], answer: 'ABC', score: 5, difficulty: 3, knowledge_point: '入职引导', analysis: '' },
|
||||
],
|
||||
b2: [
|
||||
{ id: 'q3', bank_id: 'b2', seq_no: 1, type: 'judge', stem: '冲压机双手启动按钮可以短接使用。', options: ['A. 对', 'B. 错'], answer: 'B', score: 5, difficulty: 1, knowledge_point: '安全操作规范', analysis: '严禁短接安全装置。' },
|
||||
],
|
||||
}
|
||||
|
||||
// 规则配置(配置中心):预览 harness 回课程分类字典与职称角色字典,
|
||||
// 其余键缺省由前端 DEFAULT_RULE_VALUES 打底
|
||||
const RULE_CONFIGS_MOCK = [
|
||||
{
|
||||
rule_key: 'course_category_dict',
|
||||
rule_value: { categories: ['专业技能类', '企业文化与制度类', '通用技能类', '安全与健康类', '管理领导类', '行业与产品知识类'] },
|
||||
updated_by: '',
|
||||
updated_at: month(0, 1),
|
||||
},
|
||||
{
|
||||
rule_key: 'role_dict',
|
||||
rule_value: {
|
||||
roles: [
|
||||
{ key: 'hr', label: '人事', short: '人事', system: true },
|
||||
{ key: 'supervisor', label: '课长', short: '课长', system: true },
|
||||
{ key: 'lecturer', label: '讲师', short: '讲师', system: true },
|
||||
{ key: 'exec', label: '经理', short: '经理', system: true, inherits: ['supervisor'] },
|
||||
],
|
||||
},
|
||||
updated_by: '',
|
||||
updated_at: month(0, 1),
|
||||
},
|
||||
]
|
||||
|
||||
// 配置中心 · 导入模板元数据(harness 固定展示内置默认;上传/删除不落库,刷新即还原)
|
||||
const TEMPLATE_METAS = [
|
||||
{
|
||||
@@ -177,12 +227,30 @@ const TEMPLATE_METAS = [
|
||||
updated_by: '',
|
||||
source: 'default',
|
||||
},
|
||||
{
|
||||
template_key: 'course_library',
|
||||
file_name: '课程管理导入模板.xlsx',
|
||||
file_size: 16593,
|
||||
updated_at: '',
|
||||
updated_by: '',
|
||||
source: 'default',
|
||||
},
|
||||
]
|
||||
|
||||
// 返回 { matched, body };未匹配返回 null 由 vite 放行
|
||||
export function resolveTrainingMock(method: string, url: string): { status: number; body: unknown } | null {
|
||||
const ok = (data: unknown) => ({ status: 200, body: { success: true, data } })
|
||||
if (!url.startsWith('/api/v1/training/')) return null
|
||||
if (!url.startsWith('/api/v1/training/')) {
|
||||
// 知识库文档列表(课程管理「从知识库选择课件」用,预览演示数据)
|
||||
if (url.startsWith('/api/v1/knowledge-bases/') && url.includes('/knowledge')) {
|
||||
return ok([
|
||||
{ id: 'kbdoc-1', title: '入职通识手册', file_name: '入职通识手册.pptx' },
|
||||
{ id: 'kbdoc-2', title: '安全操作规程', file_name: '安全操作规程.docx' },
|
||||
{ id: 'kbdoc-3', title: 'IATF16949 体系要点', file_name: 'IATF16949体系要点.pdf' },
|
||||
])
|
||||
}
|
||||
return null
|
||||
}
|
||||
// 模板二进制下载由 vite 配置里的中间件直接回文件,不经过本函数
|
||||
if (url === '/api/v1/training/templates' || url.endsWith('/templates')) {
|
||||
if (method === 'GET') return ok(TEMPLATE_METAS)
|
||||
@@ -190,6 +258,27 @@ export function resolveTrainingMock(method: string, url: string): { status: numb
|
||||
}
|
||||
if (method === 'GET') {
|
||||
if (url.includes('/depts')) return ok(TRAINING_MOCK.depts)
|
||||
// 规则配置(配置中心):课程分类字典 + 职称角色字典
|
||||
if (url.includes('/rule-configs')) return ok(RULE_CONFIGS_MOCK)
|
||||
// 系统默认知识库(课件/题库)摘要
|
||||
if (url.includes('/knowledge-bases')) {
|
||||
return ok({
|
||||
courseware: { id: 'kb-courseware', name: '企业培训(课件)', source: 'training_courseware' },
|
||||
question_bank: { id: 'kb-question', name: '企业培训(题库)', source: 'training_question_bank' },
|
||||
})
|
||||
}
|
||||
// 课程管理 · 试题维护(000153):课程条目题库列表 / 题库题目列表,须先于
|
||||
// /course-library、/question-banks 通用匹配
|
||||
if (url.includes('/question-banks/') && url.includes('/questions')) {
|
||||
const bankId = url.split('/question-banks/')[1]?.split('/')[0] || ''
|
||||
return ok(QUESTIONS_MOCK[bankId] || [])
|
||||
}
|
||||
if (url.includes('/course-library/') && url.includes('/question-banks')) {
|
||||
const courseId = url.split('/course-library/')[1]?.split('/')[0] || ''
|
||||
return ok(QUESTION_BANKS_MOCK.filter((b) => !courseId || b.library_course_id === courseId))
|
||||
}
|
||||
// 课程管理列表(月培训计划「课程名称」数据源)
|
||||
if (url.includes('/course-library')) return ok({ items: COURSE_LIBRARY_MOCK, total: COURSE_LIBRARY_MOCK.length })
|
||||
// 学习任务:/learning-tasks/all 为管理端课程学习情况,须先于 /learning-tasks 匹配
|
||||
if (url.includes('/learning-tasks/all')) return ok(TRAINING_MOCK.courseLearning)
|
||||
if (url.includes('/learning-tasks')) return ok(TRAINING_MOCK.myTasks)
|
||||
@@ -215,8 +304,17 @@ export function resolveTrainingMock(method: string, url: string): { status: numb
|
||||
if (url.includes('/dashboards')) return ok({})
|
||||
if (url.includes('/courses')) return ok({ items: TRAINING_MOCK.courses, total: TRAINING_MOCK.courses.length })
|
||||
if (url.includes('/sessions')) return ok(TRAINING_MOCK.sessions)
|
||||
// 年度需求收集:/demands/years 须先于 /demands 匹配(预览无历史数据,年份回当前年)
|
||||
if (url.includes('/demands/years')) return ok([NOW.getFullYear()])
|
||||
if (url.includes('/demands')) return ok({ items: TRAINING_MOCK.demands, total: TRAINING_MOCK.demands.length })
|
||||
return ok(null)
|
||||
}
|
||||
// POST(快速建课/发布/课件登记)统一回成功
|
||||
// POST/DELETE(快速建课/发布/课件登记/试题维护)统一回成功;单题保存回显入参题目
|
||||
if (url.includes('/question-banks/') && url.includes('/questions')) {
|
||||
return ok({ id: `q-new-${Date.now()}`, seq_no: 0 })
|
||||
}
|
||||
if (url.includes('/course-library/') && url.includes('/question-banks/import')) {
|
||||
return ok({ id: `b-new-${Date.now()}`, code: `QB-${String(QUESTION_BANKS_MOCK.length + 1).padStart(4, '0')}`, name: '新导入题库', question_count: 5 })
|
||||
}
|
||||
return ok({ id: `c-new-${Date.now()}` })
|
||||
}
|
||||
Reference in new issue
Block a user