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
@@ -157,6 +157,8 @@ export const getMyProfile = () =>
|
||||
export interface TrainingDemand {
|
||||
id: string
|
||||
year: number
|
||||
/** 年计划编号(AP-<year>-####,创建时由服务端生成,列表/详情展示) */
|
||||
code?: string
|
||||
dept_id: string
|
||||
submitter_id: string
|
||||
course_name: string
|
||||
@@ -227,11 +229,15 @@ export interface DeptProgress {
|
||||
export const listDemands = (query?: ListQuery) =>
|
||||
get<{ success: boolean; data: PagedData<TrainingDemand> }>(`${base}/demands`, { params: query })
|
||||
|
||||
/** 需求库实际年份去重列表(降序;年度需求收集页年份下拉数据源,默认选中最新一年)。 */
|
||||
export const listDemandYears = () =>
|
||||
get<{ success: boolean; data: number[] }>(`${base}/demands/years`)
|
||||
|
||||
export const saveDemand = (payload: Partial<TrainingDemand>) =>
|
||||
post<{ success: boolean; data: TrainingDemand }>(`${base}/demands`, payload)
|
||||
|
||||
export const importDemands = (demands: Partial<TrainingDemand>[]) =>
|
||||
post<{ success: boolean; data: { imported: number } }>(`${base}/demands/import`, { demands })
|
||||
post<{ success: boolean; data: { imported: number; notified?: number } }>(`${base}/demands/import`, { demands })
|
||||
|
||||
export const confirmDemand = (id: string) =>
|
||||
post<{ success: boolean; data: TrainingDemand }>(`${base}/demands/${enc(id)}/confirm`, {})
|
||||
@@ -314,6 +320,12 @@ export interface TrainingCourse {
|
||||
lecturer_external?: string
|
||||
/** 备注(需求确认同步) */
|
||||
remark?: string
|
||||
/** 课程管理条目 id(月培训计划「计划名称」从课程管理选择后关联;可空) */
|
||||
library_course_id?: string
|
||||
/** 月度计划编号(MP-<YYYYMM>-####,按授课月份分段,创建时由服务端生成) */
|
||||
plan_code?: string
|
||||
/** 来源需求 id(经理确认自动转月度计划时回填,溯源用) */
|
||||
source_demand_id?: string
|
||||
/** 讲师姓名(联查 users;覆盖不在讲师名册的需求同步讲师) */
|
||||
lecturer_name?: string
|
||||
/** 应到人数(各场次名单去重成员数,列表接口计算) */
|
||||
@@ -406,6 +418,96 @@ export const publishCourse = (id: string) =>
|
||||
export const deleteCourse = (id: string) =>
|
||||
del<{ success: boolean }>(`${base}/courses/${enc(id)}`)
|
||||
|
||||
// ---- 课程管理(课程资产主数据;月培训计划「计划名称」数据源) ----
|
||||
|
||||
/** TrainingLibraryCourse 课程管理条目(000151 tr_course_library)。 */
|
||||
export interface TrainingLibraryCourse {
|
||||
id: string
|
||||
/** 课程编号(CRS-####,创建/导入时由服务端生成,列表/详情展示) */
|
||||
code?: string
|
||||
/** 课程名称(必填) */
|
||||
name: string
|
||||
/** 所属部门(org_depts id;对应需求表「主办单位」,弹窗下拉选择/导入按部门名匹配) */
|
||||
owner_dept_id?: string
|
||||
/** 所属部门名(联查 org_depts 只读) */
|
||||
owner_dept_name?: string
|
||||
/** 说明 */
|
||||
description: string
|
||||
/** 适合人员(对应需求表「参加人员」,自由文本,如:财会人员) */
|
||||
suitable_members?: string
|
||||
/** 分类(配置中心 course_category_dict 可配,预设之外支持手动输入保存) */
|
||||
category: string
|
||||
/** 类型:required 必修课 / elective 选修课 */
|
||||
type: 'required' | 'elective'
|
||||
/** 形式:offline 线下 / online 线上 */
|
||||
mode: 'offline' | 'online'
|
||||
/** 讲师(员工 user id;外部讲师落 lecturer_external) */
|
||||
lecturer_id: string
|
||||
/** 外部讲师姓名(导入未匹配到员工名册时) */
|
||||
lecturer_external?: string
|
||||
/** 时长(学时) */
|
||||
hours: number
|
||||
/** 课件名称登记(多个用、分隔;对应需求表「课件收集」) */
|
||||
material_name?: string
|
||||
/** 课件文件(可上传,经专端点下载) */
|
||||
file_name?: string
|
||||
file_size?: number
|
||||
/** 课件同步知识库「企业培训(课件)」后的文档 id(AI 出题依赖) */
|
||||
knowledge_id?: string
|
||||
/** 发布状态(000154):draft 草稿/published 已发布/offline 已下线 */
|
||||
publish_status?: string
|
||||
/** 移除课件文件标记(保存时置 true 强制清空文件) */
|
||||
clear_file?: boolean
|
||||
/** 讲师姓名(联查 users 只读) */
|
||||
lecturer_name?: string
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
}
|
||||
|
||||
export const listCourseLibrary = (query?: ListQuery) =>
|
||||
get<{ success: boolean; data: PagedData<TrainingLibraryCourse> }>(`${base}/course-library`, { params: query })
|
||||
|
||||
export const saveCourseLibraryItem = (payload: Partial<TrainingLibraryCourse>) =>
|
||||
post<{ success: boolean; data: TrainingLibraryCourse }>(`${base}/course-library`, payload)
|
||||
|
||||
export const deleteCourseLibraryItem = (id: string) =>
|
||||
del<{ success: boolean }>(`${base}/course-library/${enc(id)}`)
|
||||
|
||||
/** 课程条目发布(000154):发布后进入培训中心「和信课程」目录。 */
|
||||
export const publishCourseLibraryItem = (id: string) =>
|
||||
post<{ success: boolean; data: TrainingLibraryCourse }>(`${base}/course-library/${enc(id)}/publish`)
|
||||
|
||||
/** 课程条目下线(000154):从培训中心「和信课程」目录撤回。 */
|
||||
export const offlineCourseLibraryItem = (id: string) =>
|
||||
post<{ success: boolean; data: TrainingLibraryCourse }>(`${base}/course-library/${enc(id)}/offline`)
|
||||
|
||||
/** 批量导入(前端解析 Excel 后逐行提交,与需求导入同口径;返回导入条数)。 */
|
||||
export const importCourseLibrary = (items: Partial<TrainingLibraryCourse>[]) =>
|
||||
post<{ success: boolean; data: { imported: number } }>(`${base}/course-library/import`, { items })
|
||||
|
||||
/** 导出 Excel(ids 空 = 全量;当前筛选由调用方传当前列表 id)。Blob 交给调用方触发保存。 */
|
||||
export const exportCourseLibrary = (ids: string[]) =>
|
||||
post(`${base}/course-library/export`, { ids }, { responseType: 'blob' })
|
||||
|
||||
/** 上传课件原始文件(multipart;名称登记为空时后端以文件名兜底;文档类同步知识库)。 */
|
||||
export const uploadCourseLibraryMaterial = (id: string, formData: FormData) =>
|
||||
post<{ success: boolean; data: TrainingLibraryCourse }>(
|
||||
`${base}/course-library/${enc(id)}/material`,
|
||||
formData,
|
||||
{ headers: { 'Content-Type': 'multipart/form-data' } },
|
||||
)
|
||||
|
||||
/** 从知识库「企业培训(课件)」选择已有文档作为课件(与上传同步同口径)。 */
|
||||
export const attachCourseLibraryMaterialFromKb = (id: string, payload: { knowledge_id: string }) =>
|
||||
post<{ success: boolean; data: TrainingLibraryCourse }>(
|
||||
`${base}/course-library/${enc(id)}/material/from-kb`,
|
||||
payload,
|
||||
)
|
||||
|
||||
/** 课件原始文件下载(在线预览/保存)。 */
|
||||
export const downloadCourseLibraryMaterial = (id: string) =>
|
||||
getDown(`${base}/course-library/${enc(id)}/material/file`)
|
||||
|
||||
export const listSessions = (query?: ListQuery) =>
|
||||
get<{ success: boolean; data: TrainingCourseSession[] }>(`${base}/sessions`, { params: query })
|
||||
|
||||
@@ -579,9 +681,13 @@ export const deleteSessionEvidence = (evidenceId: string) =>
|
||||
|
||||
export interface TrainingQuestionBank {
|
||||
id: string
|
||||
/** 试题库编号(QB-####,导入/生成时由服务端生成) */
|
||||
code?: string
|
||||
name: string
|
||||
dept_id: string
|
||||
course_id: string
|
||||
/** 课程管理条目 id(试题随课程管理维护,可与 course_id 并存) */
|
||||
library_course_id?: string
|
||||
/** 非空表示该题库 Excel 已同步进「企业培训(题库)」知识库 */
|
||||
knowledge_id: string
|
||||
question_count: number
|
||||
@@ -639,11 +745,12 @@ export const importQuestionBankExcel = (formData: FormData) =>
|
||||
})
|
||||
|
||||
// ImportQuestionBankFromKnowledge 从「企业培训(题库)」知识库文档解析建题库
|
||||
// (未传 course_id 时继承同名旧题库的课程关联)。
|
||||
// (未传 course_id/library_course_id 时继承同名旧题库的关联)。
|
||||
export const importQuestionBankFromKnowledge = (payload: {
|
||||
knowledge_id: string
|
||||
name?: string
|
||||
course_id?: string
|
||||
library_course_id?: string
|
||||
}) =>
|
||||
post<{ success: boolean; data: TrainingQuestionBank }>(`${base}/question-banks/import-from-kb`, payload)
|
||||
|
||||
@@ -651,9 +758,17 @@ export const importQuestionBankFromKnowledge = (payload: {
|
||||
export const generateCourseQuestions = (courseId: string, payload: { material_id: string; count?: number }) =>
|
||||
post<{ success: boolean; data: TrainingQuestion[] }>(`${base}/courses/${enc(courseId)}/generate-questions`, payload)
|
||||
|
||||
// GenerateLibraryCourseQuestions 课程管理课件 AI 出题(课件需已同步知识库,000153)。
|
||||
export const generateLibraryCourseQuestions = (libraryCourseId: string, payload?: { count?: number }) =>
|
||||
post<{ success: boolean; data: TrainingQuestion[] }>(
|
||||
`${base}/course-library/${enc(libraryCourseId)}/generate-questions`,
|
||||
payload ?? {},
|
||||
)
|
||||
|
||||
// ImportGeneratedQuestionBank 使用生成/编辑后的题目建题库(关联课程,文本同步知识库)。
|
||||
export const importGeneratedQuestionBank = (payload: {
|
||||
course_id?: string
|
||||
library_course_id?: string
|
||||
name?: string
|
||||
questions: TrainingQuestion[]
|
||||
}) =>
|
||||
@@ -662,6 +777,47 @@ export const importGeneratedQuestionBank = (payload: {
|
||||
export const listQuestions = (bankId: string) =>
|
||||
get<{ success: boolean; data: TrainingQuestion[] }>(`${base}/question-banks/${enc(bankId)}/questions`)
|
||||
|
||||
// ---- 课程管理 · 试题维护(000153) ----
|
||||
|
||||
/** 课程条目下的题库列表(试题维护抽屉)。 */
|
||||
export const listLibraryCourseQuestionBanks = (libraryCourseId: string) =>
|
||||
get<{ success: boolean; data: TrainingQuestionBank[] }>(
|
||||
`${base}/course-library/${enc(libraryCourseId)}/question-banks`,
|
||||
)
|
||||
|
||||
/** 更换课程条目的试题(所选题库整体替换,000156;月计划详情「试题·更换」入口)。 */
|
||||
export const linkLibraryCourseQuestionBank = (libraryCourseId: string, bankId: string) =>
|
||||
put<{ success: boolean; data: TrainingQuestionBank[] }>(
|
||||
`${base}/course-library/${enc(libraryCourseId)}/question-banks/link`,
|
||||
{ bank_id: bankId },
|
||||
)
|
||||
|
||||
/** Excel 导入题库并挂课程管理条目(同名重导入即替换)。 */
|
||||
export const importLibraryCourseQuestionBank = (libraryCourseId: string, formData: FormData) =>
|
||||
post<{ success: boolean; data: TrainingQuestionBank }>(
|
||||
`${base}/course-library/${enc(libraryCourseId)}/question-banks/import`,
|
||||
formData,
|
||||
{ headers: { 'Content-Type': 'multipart/form-data' } },
|
||||
)
|
||||
|
||||
/** 删除题库(连带题目与缓存试卷)。 */
|
||||
export const deleteQuestionBank = (bankId: string) =>
|
||||
del<{ success: boolean }>(`${base}/question-banks/${enc(bankId)}`)
|
||||
|
||||
/** 单题新增/编辑(id 空 = 新增;题库 question_count 同步刷新)。 */
|
||||
export const saveQuestion = (
|
||||
bankId: string,
|
||||
payload: Partial<TrainingQuestion> & { id?: string },
|
||||
) =>
|
||||
post<{ success: boolean; data: TrainingQuestion }>(
|
||||
`${base}/question-banks/${enc(bankId)}/questions`,
|
||||
payload,
|
||||
)
|
||||
|
||||
/** 删除单题。 */
|
||||
export const deleteQuestion = (bankId: string, questionId: string) =>
|
||||
del<{ success: boolean }>(`${base}/question-banks/${enc(bankId)}/questions/${enc(questionId)}`)
|
||||
|
||||
export const generatePaper = (bankId: string, sessionId: string, count: number, version: string) =>
|
||||
post<{ success: boolean; data: TrainingPaper }>(`${base}/papers/generate`, {
|
||||
bank_id: bankId,
|
||||
@@ -1009,6 +1165,36 @@ export async function fetchRoleDict(): Promise<TrainingRoleDef[]> {
|
||||
return DEFAULT_ROLE_DICT
|
||||
}
|
||||
|
||||
/** 课程分类字典 rule-configs 键(与后端 RuleKeyCourseCategoryDict 一致)。 */
|
||||
export const COURSE_CATEGORY_DICT_RULE_KEY = 'course_category_dict'
|
||||
|
||||
/** 课程分类默认字典(与后端 DefaultCourseCategories 一致;配置缺失/损坏时兜底)。 */
|
||||
export const DEFAULT_COURSE_CATEGORIES: string[] = [
|
||||
'专业技能类',
|
||||
'企业文化与制度类',
|
||||
'通用技能类',
|
||||
'安全与健康类',
|
||||
'管理领导类',
|
||||
'行业与产品知识类',
|
||||
]
|
||||
|
||||
/** 读取课程分类字典(rule-configs 中的 course_category_dict;缺失/损坏回退默认分类,
|
||||
* 配置中心「课程分类」卡保存后自然生效) */
|
||||
export async function fetchCourseCategories(): Promise<string[]> {
|
||||
try {
|
||||
const res = await listRuleConfigs()
|
||||
const configs = unwrap<TrainingRuleConfig[]>(res) || []
|
||||
const categories = configs.find((c) => c.rule_key === COURSE_CATEGORY_DICT_RULE_KEY)?.rule_value?.categories
|
||||
if (Array.isArray(categories)) {
|
||||
const list = categories.filter((c): c is string => typeof c === 'string' && !!c.trim())
|
||||
if (list.length > 0) return list
|
||||
}
|
||||
} catch {
|
||||
// 拉取失败回退默认分类,课程筛选与表单下拉不受影响
|
||||
}
|
||||
return DEFAULT_COURSE_CATEGORIES
|
||||
}
|
||||
|
||||
/** 沿权限分配(inherits)传递展开角色 → 权限并集(与后端 ExpandRoles 同构,环安全);
|
||||
* 存量 clerk 角色按别名映射为课长 */
|
||||
export function expandRoles(roles: string[], dict: TrainingRoleDef[]): string[] {
|
||||
@@ -1035,7 +1221,7 @@ export function roleLabelOf(key: string, dict: TrainingRoleDef[], narrow = false
|
||||
|
||||
// ---- 配置中心 · 导入模板管理 ----
|
||||
|
||||
export type TrainingTemplateKey = 'demand_collection' | 'question_bank'
|
||||
export type TrainingTemplateKey = 'demand_collection' | 'question_bank' | 'course_library'
|
||||
|
||||
export interface TrainingTemplateMeta {
|
||||
template_key: TrainingTemplateKey
|
||||
|
||||
@@ -605,10 +605,12 @@ const moreToolItems = computed<MenuItem[]>(() => {
|
||||
const items = MORE_TOOLS_ORDER
|
||||
.map(path => all.find((item: MenuItem) => item.path === path))
|
||||
.filter((item): item is MenuItem => !!item);
|
||||
// 末位固定追加「配置中心」「组织架构」;「共享空间」还原至最底
|
||||
// 末位固定追加「配置中心」「职称角色」「组织架构」;「共享空间」还原至最底
|
||||
// (入口定义与显隐规则仍在 menu store:仅空间 admin/owner 可见,随能力清单显隐)
|
||||
// 职称角色(000159):自「企业培训」分组迁入,置于配置中心之后
|
||||
const MEMBERS_TOOL_ITEM: MenuItem = { title: '职称角色', icon: 'training', path: 'training/members' };
|
||||
const orgShareItem = all.find((item: MenuItem) => item.path === 'organizations');
|
||||
return [...items, RULES_TOOL_ITEM, ORG_CENTER_TOOL_ITEM, ...(orgShareItem ? [orgShareItem] : [])];
|
||||
return [...items, RULES_TOOL_ITEM, MEMBERS_TOOL_ITEM, ORG_CENTER_TOOL_ITEM, ...(orgShareItem ? [orgShareItem] : [])];
|
||||
});
|
||||
|
||||
// 菜单图标统一映射:顶层项与「更多工具」子项共用
|
||||
@@ -632,12 +634,14 @@ const iconSrcFor = (icon: string): string => {
|
||||
// 文案与培训页内 tab 保持一致;组织成员由 Training 页内按角色控制内容。
|
||||
// 「配置中心」已移入「更多工具」末位(RULES_TOOL_ITEM),不再出现在本分组。
|
||||
const TRAINING_TABS: { key: string; title: string }[] = [
|
||||
{ key: 'dashboard', title: '工作台' },
|
||||
{ key: 'plan', title: '培训计划' },
|
||||
{ key: 'course', title: '培训课程' },
|
||||
{ key: 'dashboard', title: '培训中心' },
|
||||
{ key: 'plan', title: '年培训计划' },
|
||||
{ key: 'course', title: '月培训计划' },
|
||||
{ key: 'library', title: '课程管理' },
|
||||
{ key: 'sign', title: '培训签到' },
|
||||
{ key: 'study', title: '学习考试' },
|
||||
{ key: 'members', title: '职称角色' },
|
||||
// 数据驾驶舱(000158):自培训中心页头切换迁入侧栏
|
||||
{ key: 'data-dashboard', title: '数据驾驶舱' },
|
||||
// 职称角色(000159):迁至「更多工具」分组、配置中心之后(角色权限口径)
|
||||
];
|
||||
const TRAINING_GROUP_TITLE = '企业培训';
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import { useAuthStore } from '@/stores/auth'
|
||||
import WorkbenchPanel from '@/views/training/components/WorkbenchPanel.vue'
|
||||
import PlanPanel from '@/views/training/components/PlanPanel.vue'
|
||||
import CoursePanel from '@/views/training/components/CoursePanel.vue'
|
||||
import LibraryPanel from '@/views/training/components/LibraryPanel.vue'
|
||||
import StudyPanel from '@/views/training/components/StudyPanel.vue'
|
||||
import RulePanel from '@/views/training/components/RulePanel.vue'
|
||||
import ResourceIcon from '@/components/icons/ResourceIcon.vue'
|
||||
@@ -35,13 +36,14 @@ const HARNESS_APP = defineComponent({
|
||||
|
||||
type WorkbenchView = 'course' | 'growth' | 'dashboard'
|
||||
const workbenchTab = ref<WorkbenchView>('course')
|
||||
// 子页:工作台 / 培训计划 / 培训课程 / 学习考试 / 配置中心
|
||||
const page = ref<'workbench' | 'plan' | 'course' | 'study' | 'rules'>('workbench')
|
||||
// 子页:培训中心 / 年培训计划 / 月培训计划 / 课程管理 / 学习考试 / 配置中心
|
||||
const page = ref<'workbench' | 'plan' | 'course' | 'library' | 'study' | 'rules'>('workbench')
|
||||
|
||||
const PAGES = [
|
||||
{ key: 'workbench', title: '工作台' },
|
||||
{ key: 'plan', title: '培训计划' },
|
||||
{ key: 'course', title: '培训课程' },
|
||||
{ key: 'workbench', title: '培训中心' },
|
||||
{ key: 'plan', title: '年培训计划' },
|
||||
{ key: 'course', title: '月培训计划' },
|
||||
{ key: 'library', title: '课程管理' },
|
||||
{ key: 'study', title: '学习考试' },
|
||||
{ key: 'rules', title: '配置中心' },
|
||||
] as const
|
||||
@@ -62,8 +64,8 @@ const HARNESS_APP = defineComponent({
|
||||
const meta = computed(() => {
|
||||
if (isWorkbench.value) {
|
||||
if (workbenchTab.value === 'course') return { title: '培训课程', desc: '课程/课件上传后自动转入课件库并智能归档' }
|
||||
if (workbenchTab.value === 'growth') return { title: '工作台', desc: '个人成长进阶 · 能力模型与成就任务总览' }
|
||||
return { title: '工作台', desc: '培训运营总览、待办与达成率一览' }
|
||||
if (workbenchTab.value === 'growth') return { title: '培训中心', desc: '个人成长进阶 · 能力模型与成就任务总览' }
|
||||
return { title: '培训中心', desc: '培训运营总览、待办与达成率一览' }
|
||||
}
|
||||
const found = PAGES.find((p) => p.key === page.value)
|
||||
return { title: found?.title || '', desc: '' }
|
||||
@@ -74,6 +76,7 @@ const HARNESS_APP = defineComponent({
|
||||
switch (key) {
|
||||
case 'plan': return h(PlanPanel, common)
|
||||
case 'course': return h(CoursePanel, common)
|
||||
case 'library': return h(LibraryPanel, common)
|
||||
case 'study': return h(StudyPanel, common)
|
||||
case 'rules': return h(RulePanel, common)
|
||||
default: return h(WorkbenchPanel, { ...common, tab: workbenchTab.value })
|
||||
|
||||
@@ -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()}` })
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
</h2>
|
||||
<t-tag v-if="myRoleLabel" theme="primary" variant="light">{{ myRoleLabel }}</t-tag>
|
||||
</div>
|
||||
<!-- 工作台视图切换:课程 / 个人成长 / 数据驾驶舱(驾驶舱仅培训管理角色可见) -->
|
||||
<!-- 工作台视图切换:课程 / 个人成长(数据驾驶舱已迁侧栏,000158) -->
|
||||
<nav v-if="isWorkbench" class="workbench-switch" aria-label="工作台视图切换">
|
||||
<button
|
||||
v-for="t in workbenchSwitchTabs"
|
||||
@@ -26,7 +26,7 @@
|
||||
<p class="training-subtitle">{{ activeTabMeta.desc }}</p>
|
||||
</header>
|
||||
|
||||
<!-- 子页(工作台/培训计划/…/配置中心)由侧栏「企业培训」分组导航,此处按路由 tab 参数渲染 -->
|
||||
<!-- 子页(培训中心/年培训计划/…/配置中心)由侧栏「企业培训」分组导航,此处按路由 tab 参数渲染 -->
|
||||
<t-alert
|
||||
v-if="sessionExpired"
|
||||
class="training-session-alert"
|
||||
@@ -35,15 +35,24 @@
|
||||
description="培训数据未丢失。请重新登录后刷新本页即可查看。"
|
||||
/>
|
||||
<div class="training-body">
|
||||
<!-- 工作台:课程(默认)/个人成长/数据驾驶舱 三视图自由切换 -->
|
||||
<!-- 工作台:课程(默认)/个人成长 两视图切换;数据驾驶舱已迁侧栏(000158) -->
|
||||
<WorkbenchPanel v-if="activeTab === 'dashboard'" :roles="myRoles" :admin="isAdmin" :tab="workbenchTab" />
|
||||
<!-- 数据驾驶舱独立子页(000158):与工作台驾驶舱视图同源,非管理角色回落课程目录 -->
|
||||
<template v-else-if="activeTab === 'data-dashboard'">
|
||||
<WorkbenchPanel v-if="canSeeWorkbenchDashboard" :roles="myRoles" :admin="isAdmin" tab="dashboard" />
|
||||
<t-empty v-else class="training-empty" description="数据驾驶舱仅人事/课长/经理可见" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'plan'">
|
||||
<PlanPanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="培训计划仅课长/经理/人事可见" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'course'">
|
||||
<CoursePanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="课程维护仅课长/经理/人事/讲师可见,学员请前往工作台课程目录" />
|
||||
<t-empty v-else class="training-empty" description="月培训计划仅课长/经理/人事/讲师可见,学员请前往培训中心课程目录" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'library'">
|
||||
<LibraryPanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="课程管理仅课长/经理/人事/讲师可见" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'sign'">
|
||||
<SignPanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
@@ -51,12 +60,14 @@
|
||||
</template>
|
||||
<StudyPanel v-else-if="activeTab === 'study'" :roles="myRoles" :admin="isAdmin" />
|
||||
<template v-else-if="activeTab === 'members'">
|
||||
<MemberPanel v-if="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="职称角色维护仅人事可见" />
|
||||
<!-- 职称角色对经理开放(000159):与配置中心「角色权限」页签同口径 -->
|
||||
<MemberPanel v-if="canManageConfig" />
|
||||
<t-empty v-else class="training-empty" description="职称角色维护仅人事/经理可见" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'rules'">
|
||||
<RulePanel v-if="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="配置中心仅人事可见" />
|
||||
<!-- 配置中心对经理开放(000158):经理与人事同权查看/维护培训规则 -->
|
||||
<RulePanel v-if="canManageConfig" />
|
||||
<t-empty v-else class="training-empty" description="配置中心仅人事/经理可见" />
|
||||
</template>
|
||||
<WorkbenchPanel v-else :roles="myRoles" :admin="isAdmin" :tab="workbenchTab" />
|
||||
</div>
|
||||
@@ -72,6 +83,7 @@ import ResourceIcon from '@/components/icons/ResourceIcon.vue'
|
||||
import WorkbenchPanel from './components/WorkbenchPanel.vue'
|
||||
import PlanPanel from './components/PlanPanel.vue'
|
||||
import CoursePanel from './components/CoursePanel.vue'
|
||||
import LibraryPanel from './components/LibraryPanel.vue'
|
||||
import SignPanel from './components/SignPanel.vue'
|
||||
import MemberPanel from './components/MemberPanel.vue'
|
||||
import StudyPanel from './components/StudyPanel.vue'
|
||||
@@ -79,10 +91,14 @@ import RulePanel from './components/RulePanel.vue'
|
||||
import { expandRoles, fetchRoleDict, getMyProfile, roleLabelOf, type TrainingMember, type TrainingRoleDef } from '@/api/training'
|
||||
|
||||
// 与侧栏「企业培训」分组文案一致;title 同时用于页头显示当前页签名
|
||||
// 「学习考试」已移出侧栏导航,路由保留(学习/考试状态列点击等场景仍可直达)
|
||||
const TRAINING_TABS_META: Record<string, { title: string; desc: string }> = {
|
||||
dashboard: { title: '工作台', desc: '培训运营总览、待办与达成率一览' },
|
||||
plan: { title: '培训计划', desc: '年度培训需求收集与汇总(可切换年度)' },
|
||||
course: { title: '培训课程', desc: '课程资产库、场次安排与学员名单;课件自动同步知识库' },
|
||||
dashboard: { title: '培训中心', desc: '培训运营总览、待办与达成率一览' },
|
||||
// 数据驾驶舱(000158):侧栏独立子页,内容与工作台驾驶舱视图同源
|
||||
'data-dashboard': { title: '数据驾驶舱', desc: '部门培训达成率排名、讲师积分榜与月度盘点' },
|
||||
plan: { title: '年培训计划', desc: '年度培训需求收集与汇总(可切换年度)' },
|
||||
course: { title: '月培训计划', desc: '月度培训计划排期、场次安排与学员名单;课程从课程管理选择,计划编号自动生成' },
|
||||
library: { title: '课程管理', desc: '课程资产库维护:编号/课程名称/说明/分类/类型/线上线下/讲师/时长/课件/试题' },
|
||||
sign: { title: '培训签到', desc: '签到码生成、签到明细复核与佐证导出' },
|
||||
study: { title: '学习考试', desc: '我的课程学习、课程学习情况、课程考试情况与 AI 课程分析' },
|
||||
members: { title: '职称角色', desc: '名册来自「组织架构」,此处维护员工职称角色' },
|
||||
@@ -117,6 +133,10 @@ const canManageTabs = computed(() =>
|
||||
isAdmin.value ||
|
||||
myRoles.value.some((r) => ['hr', 'supervisor', 'exec', 'lecturer'].includes(r)))
|
||||
|
||||
// 配置中心门槛(000158):人事/空间管理员之外,经理职称角色同权查看与维护。
|
||||
const canManageConfig = computed(() =>
|
||||
isAdmin.value || myRoles.value.some((r) => r === 'exec'))
|
||||
|
||||
// 页头角色标签:展示实际分配的角色(非权限展开),文案取自配置中心字典
|
||||
const myRoleLabel = computed(() =>
|
||||
rawRoles.value.map((r) => roleLabelOf(r, roleDict.value)).join(' / '))
|
||||
@@ -130,9 +150,9 @@ const activeTab = computed(() => {
|
||||
})
|
||||
|
||||
const activeTabMeta = computed(() => {
|
||||
// 工作台三视图:页头标题/副标题跟随当前视图(课程视图与设计稿一致使用「培训课程」)
|
||||
// 工作台三视图:页头标题/副标题跟随当前视图(课程视图「培训中心」,000154)
|
||||
if (activeTab.value === 'dashboard') {
|
||||
if (workbenchTab.value === 'course') return { title: '培训课程', desc: '课件/题库上传后自动同步知识库,可对话问答' }
|
||||
if (workbenchTab.value === 'course') return { title: '培训中心', desc: '和信课程目录、我的培训与我的考试' }
|
||||
if (workbenchTab.value === 'growth') return { title: '工作台', desc: '个人成长进阶 · 能力模型与成就任务总览' }
|
||||
return TRAINING_TABS_META.dashboard
|
||||
}
|
||||
@@ -148,12 +168,12 @@ const canSeeWorkbenchDashboard = computed(
|
||||
() => isAdmin.value || myRoles.value.some((r) => r === 'hr' || r === 'supervisor' || r === 'exec'),
|
||||
)
|
||||
|
||||
// 页头视图切换(000158):数据驾驶舱已迁侧栏独立子页,工作台仅保留课程/个人成长
|
||||
const workbenchSwitchTabs = computed(() => {
|
||||
const list: { key: WorkbenchView; label: string }[] = [
|
||||
{ key: 'course', label: '课程' },
|
||||
{ key: 'growth', label: '个人成长' },
|
||||
]
|
||||
if (canSeeWorkbenchDashboard.value) list.push({ key: 'dashboard', label: '数据驾驶舱' })
|
||||
return list
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="course-catalog">
|
||||
<!-- 工具行:范围页签(全部/线上/线下/我的课程) + 搜索 -->
|
||||
<!-- 工具行:范围页签(和信课程/我的培训/我的考试,000154) + 搜索 -->
|
||||
<div class="catalog-toolbar">
|
||||
<div class="catalog-filter" role="tablist" aria-label="课程范围">
|
||||
<button
|
||||
@@ -23,19 +23,41 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 汇总行:与设计稿一致(共 N 门 · 线上 / 线下 / 本月新增或课件数)。
|
||||
待维护 = 我主讲且「草稿」状态的课程数(2026-11 需求;>0 时用与「草稿」一致的橙色提醒)。
|
||||
待开始 = 已排期且开课时间未到的课程数(按「我的课程」口径:我主讲/我参加,2026-11 需求)。 -->
|
||||
<!-- 汇总行:随页签切换口径。
|
||||
我的培训:待维护 = 我主讲且「草稿」的课程数;待开始 = 已排期且开课时间未到的课程数。 -->
|
||||
<div class="catalog-stats">
|
||||
{{ statsText }}
|
||||
<span class="catalog-stats__maintain" :class="{ 'is-alert': maintainCount > 0 }">待维护 {{ maintainCount }} 门</span>
|
||||
<span class="catalog-stats__pending" :class="{ 'is-info': pendingStartCount > 0 }">待开始 {{ pendingStartCount }} 门</span>
|
||||
<template v-if="filter === 'mine'">
|
||||
<span class="catalog-stats__maintain" :class="{ 'is-alert': maintainCount > 0 }">待维护 {{ maintainCount }} 门</span>
|
||||
<span class="catalog-stats__pending" :class="{ 'is-info': pendingStartCount > 0 }">待开始 {{ pendingStartCount }} 门</span>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 课程卡片网格 -->
|
||||
<t-loading :loading="loading" class="catalog-grid-wrap">
|
||||
<!-- 我的考试:与我相关的考试记录列表(000154) -->
|
||||
<t-loading v-if="filter === 'exam'" :loading="loading" class="catalog-grid-wrap">
|
||||
<t-table :data="examRows" :columns="examColumns" row-key="id" size="small">
|
||||
<template #course_name="{ row }">{{ row.course_name || row.paper_name || '-' }}</template>
|
||||
<template #score="{ row }">
|
||||
<span :class="row.passed ? 'exam-score is-good' : 'exam-score is-bad'">{{ row.score ?? '—' }}</span>
|
||||
</template>
|
||||
<template #pass_line="{ row }">{{ row.pass_score || '-' }} / {{ row.total_score || '-' }}</template>
|
||||
<template #submitted_at="{ row }">{{ fmtExamTime(row.submitted_at) }}</template>
|
||||
</t-table>
|
||||
<t-empty v-if="!loading && !examRows.length" class="catalog-empty" description="暂无考试记录,参加随堂考试后此处展示成绩" />
|
||||
</t-loading>
|
||||
|
||||
<!-- 课程卡片网格(和信课程/我的培训) -->
|
||||
<t-loading v-else :loading="loading" class="catalog-grid-wrap">
|
||||
<div class="catalog-grid">
|
||||
<article v-for="card in visibleCards" :key="card.id" class="course-card" role="link" tabindex="0" @click="openCourse(card)" @keydown.enter="openCourse(card)">
|
||||
<article
|
||||
v-for="card in visibleCards"
|
||||
:key="card.id"
|
||||
class="course-card"
|
||||
role="link"
|
||||
tabindex="0"
|
||||
@click="openCourse(card)"
|
||||
@keydown.enter="openCourse(card)"
|
||||
>
|
||||
<div class="course-card__cover" :class="card.mode === 'online' ? 'is-online' : 'is-offline'">
|
||||
<svg v-if="card.mode === 'online'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="12" rx="2"/><path d="m10 8.6 4 2.4-4 2.4z"/><path d="M8 21h8M12 17v4"/></svg>
|
||||
<svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17.5V5a1.6 1.6 0 0 1 1.6-1.6h9A1.6 1.6 0 0 1 16.2 5v12.5"/><path d="M4 17.5A2.5 2.5 0 0 0 6.5 20h9.7"/><path d="M16.2 8.2H19a1.4 1.4 0 0 1 1.4 1.4v3.1a2.3 2.3 0 1 1-4.6 0V9.6"/><path d="M7.5 7h5M7.5 10h5"/></svg>
|
||||
@@ -46,7 +68,7 @@
|
||||
<t-tag :theme="card.mode === 'online' ? 'primary' : 'success'" variant="light" size="small" :class="{ 'course-tag-offline': card.mode !== 'online' }">
|
||||
{{ card.mode === 'online' ? '线上课程' : '线下课程' }}
|
||||
</t-tag>
|
||||
<!-- [2026-11 需求]「我的课程」角色标记:区分我要进行培训(我主讲,橙色)/ 我要参加(蓝绿色)的课程 -->
|
||||
<!-- 「我的培训」角色标记:区分我要进行培训(我主讲,橙色)/ 我要参加(蓝绿色)的课程 -->
|
||||
<t-tag
|
||||
v-if="card.roleTag"
|
||||
:theme="card.roleTag === 'teach' ? 'warning' : 'primary'"
|
||||
@@ -70,7 +92,11 @@
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<t-empty v-if="!loading && !visibleCards.length" class="catalog-empty" :description="filter === 'mine' ? '暂无与我相关的课程' : '暂无课程'" />
|
||||
<t-empty
|
||||
v-if="!loading && !visibleCards.length"
|
||||
class="catalog-empty"
|
||||
:description="filter === 'mine' ? '暂无与我相关的课程' : '暂无已发布课程(课程管理发布后在此展示)'"
|
||||
/>
|
||||
</t-loading>
|
||||
</div>
|
||||
</template>
|
||||
@@ -81,11 +107,15 @@ import { useRouter } from 'vue-router'
|
||||
import {
|
||||
getMyProfile,
|
||||
listCourses,
|
||||
listCourseLibrary,
|
||||
listMyExamRecords,
|
||||
listMyLearningTasks,
|
||||
listSessions,
|
||||
type LearningTask,
|
||||
type MyExamRecord,
|
||||
type TrainingCourse,
|
||||
type TrainingCourseSession,
|
||||
type TrainingLibraryCourse,
|
||||
type TrainingMember,
|
||||
unwrap,
|
||||
} from '@/api/training'
|
||||
@@ -94,8 +124,10 @@ const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
|
||||
const router = useRouter()
|
||||
// 卡片点击 → 课程学习详情页(课件在线预览 + 随堂考试);
|
||||
// 未发布课程(我任讲师的草稿/待审)无学习视角,点击直达维护。
|
||||
// 未发布课程(我任讲师的草稿/待审)无学习视角,点击直达维护;
|
||||
// 和信课程卡片为课程资产展示(000154),无学习页不跳转。
|
||||
const openCourse = (card: CatalogCard) => {
|
||||
if (card.kind === 'library') return
|
||||
if (card.unpublished) {
|
||||
goMaintain(card.id)
|
||||
return
|
||||
@@ -110,26 +142,44 @@ const goMaintain = (courseId: string) => {
|
||||
|
||||
const loading = ref(false)
|
||||
const courses = ref<TrainingCourse[]>([])
|
||||
// 课程维护视角(不带 scope=student)的我名下课程:纯讲师含草稿,供「我的课程」与待维护统计
|
||||
// 课程维护视角(不带 scope=student)的我名下课程:纯讲师含草稿,供「我的培训」与待维护统计
|
||||
const lecturerCourses = ref<TrainingCourse[]>([])
|
||||
const myProfile = ref<TrainingMember | null>(null)
|
||||
const myTasks = ref<LearningTask[]>([])
|
||||
const sessions = ref<TrainingCourseSession[]>([])
|
||||
// 课程管理资产(000154):「和信课程」目录 = 课程管理已发布且部门范围覆盖查看人的课程
|
||||
const libraryItems = ref<TrainingLibraryCourse[]>([])
|
||||
// 我的考试记录(000154):「我的考试」页签数据源
|
||||
const myExamRecords = ref<MyExamRecord[]>([])
|
||||
|
||||
const FILTERS = [
|
||||
{ key: 'all', label: '全部课程' },
|
||||
{ key: 'online', label: '线上课程' },
|
||||
{ key: 'offline', label: '线下课程' },
|
||||
{ key: 'mine', label: '我的课程' },
|
||||
{ key: 'hexin', label: '和信课程' },
|
||||
{ key: 'mine', label: '我的培训' },
|
||||
{ key: 'exam', label: '我的考试' },
|
||||
] as const
|
||||
// 工作台进目录默认落在「我的课程」(2026-11 需求:与我相关的课优先展示)
|
||||
// 工作台进目录默认落在「我的培训」(与我相关的课优先展示)
|
||||
const filter = ref<string>('mine')
|
||||
const keyword = ref('')
|
||||
|
||||
// 目录页面向全体员工:仅展示已发布课程(草稿/待审在「培训课程」维护)
|
||||
const publishedCourses = computed(() => courses.value.filter((c) => c.status === 'published'))
|
||||
|
||||
// 「和信课程」(000154):课程管理中已发布、且部门范围覆盖查看人的课程
|
||||
// (所属部门为空 = 全员课程;有部门则需与我的部门一致)
|
||||
const myDeptId = computed(() => myProfile.value?.dept_id || '')
|
||||
const hexinCourses = computed<TrainingLibraryCourse[]>(() =>
|
||||
libraryItems.value.filter(
|
||||
(c) => c.publish_status === 'published' && (!c.owner_dept_id || !myDeptId.value || c.owner_dept_id === myDeptId.value),
|
||||
),
|
||||
)
|
||||
|
||||
const statsText = computed(() => {
|
||||
if (filter.value === 'exam') return `共 ${myExamRecords.value.length} 场考试`
|
||||
if (filter.value === 'hexin') {
|
||||
const list = hexinCourses.value
|
||||
const online = list.filter((c) => c.mode === 'online').length
|
||||
return `共 ${list.length} 门课程 · 线上 ${online} 门 · 线下 ${list.length - online} 门`
|
||||
}
|
||||
const list = publishedCourses.value
|
||||
const online = list.filter((c) => c.mode === 'online').length
|
||||
const offline = list.length - online
|
||||
@@ -252,27 +302,68 @@ interface CatalogCard {
|
||||
maintainable: boolean
|
||||
/** 未发布(草稿/待审)的讲师课程:无学习视角,点击直达维护 */
|
||||
unpublished: boolean
|
||||
/** [2026-11 需求]「我的课程」角色标记:teach=我主讲 / attend=我参加(其余视图不标记) */
|
||||
/** 卡片来源:plan=月计划课程(可点进学习页) / library=课程管理资产(000154,仅展示) */
|
||||
kind: 'plan' | 'library'
|
||||
/** 「我的培训」角色标记:teach=我主讲 / attend=我参加(其余视图不标记) */
|
||||
roleTag?: 'teach' | 'attend'
|
||||
}
|
||||
|
||||
// 「我的考试」表格列(000154):与我相关的考试记录
|
||||
const examColumns = [
|
||||
{ colKey: 'course_name', title: '课程/试卷' },
|
||||
{ colKey: 'score', title: '成绩', width: 90 },
|
||||
{ colKey: 'pass_line', title: '及格/总分', width: 110 },
|
||||
{ colKey: 'submitted_at', title: '交卷时间', width: 170 },
|
||||
]
|
||||
const fmtExamTime = (raw?: string | null) => {
|
||||
if (!raw) return '-'
|
||||
const d = new Date(raw)
|
||||
return Number.isNaN(d.getTime()) ? String(raw) : d.toLocaleString('zh-CN', { hour12: false })
|
||||
}
|
||||
// 「我的考试」行数据(带搜索过滤)
|
||||
const examRows = computed<MyExamRecord[]>(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
if (!kw) return myExamRecords.value
|
||||
return myExamRecords.value.filter(
|
||||
(r) => (r.course_name || '').toLowerCase().includes(kw) || (r.paper_name || '').toLowerCase().includes(kw),
|
||||
)
|
||||
})
|
||||
|
||||
// 卡片元信息与底部进度条:
|
||||
// 线上 = 我的学习任务状态(已完成/学习中/待学习/已逾期),进度条只表达确定状态,不虚构百分比;
|
||||
// 线下 = 真实排期进度(已完成场次/已排期场次)。
|
||||
// 未发布的讲师课程(仅「我的课程」视图可见)以草稿/待审态展示。
|
||||
// 未发布的讲师课程(仅「我的培训」视图可见)以草稿/待审态展示。
|
||||
const visibleCards = computed<CatalogCard[]>(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
// 数据源:全部/线上/线下 = 已发布目录;我的课程 = 我相关的已发布课 + 我任讲师的课(含未发布,已发布的按 id 去重)
|
||||
// 和信课程(000154):课程管理已发布课程(资产卡片,仅展示)
|
||||
if (filter.value === 'hexin') {
|
||||
return hexinCourses.value
|
||||
.filter((c) => !kw || c.name.toLowerCase().includes(kw) || (c.category || '').toLowerCase().includes(kw))
|
||||
.map((c) => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
mode: c.mode === 'online' ? 'online' : 'offline',
|
||||
meta: [c.category, c.type === 'elective' ? '选修' : '必修', c.hours ? `${c.hours} 学时` : '', c.suitable_members]
|
||||
.filter(Boolean)
|
||||
.join(' · '),
|
||||
state: '已发布',
|
||||
stateClass: 'is-good',
|
||||
barWidth: '0%',
|
||||
barClass: '',
|
||||
maintainable: false,
|
||||
unpublished: false,
|
||||
kind: 'library' as const,
|
||||
}))
|
||||
}
|
||||
// 数据源:我的培训 = 我相关的已发布课 + 我任讲师的课(含未发布,已发布的按 id 去重)
|
||||
let source = publishedCourses.value
|
||||
if (filter.value === 'mine') source = myCoursesSource.value
|
||||
let list = source.filter((c) => {
|
||||
if (filter.value === 'online' && c.mode !== 'online') return false
|
||||
if (filter.value === 'offline' && c.mode !== 'offline') return false
|
||||
if (filter.value === 'mine' && !isMyCourse(c) && !isMyTeaching(c)) return false
|
||||
if (kw && !(c.name.toLowerCase().includes(kw) || (c.tags || []).some((t) => String(t).toLowerCase().includes(kw)))) return false
|
||||
return true
|
||||
})
|
||||
// [2026-11 需求] 「我的课程」排序:需关注的课程(我主讲未发布/缺课件)置顶,
|
||||
// 「我的培训」排序:需关注的课程(我主讲未发布/缺课件)置顶,
|
||||
// 其余按与当前时间的邻近度升序(临近开课/结课的在前,无时间锚点的排最后)
|
||||
if (filter.value === 'mine') {
|
||||
const now = Date.now()
|
||||
@@ -292,7 +383,7 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
const head = [c.post_scope, typeText(c), `${c.hours} 学时`, c.exam_enabled ? '随堂考试' : ''].filter(Boolean).join(' · ')
|
||||
const maintainable = isMyTeaching(c) && canMaintainCourses.value
|
||||
const unpublished = c.status !== 'published'
|
||||
// [2026-11 需求]「我的课程」角色标记:我主讲(优先) / 我参加,其余视图不标记
|
||||
// 「我的培训」角色标记:我主讲(优先) / 我参加,其余视图不标记
|
||||
const roleTag = filter.value === 'mine' ? (isMyTeaching(c) ? ('teach' as const) : ('attend' as const)) : undefined
|
||||
// 未发布讲师课:无学习任务与排期进度,展示草稿/待审 + 计划时间(需求确认同步)
|
||||
if (unpublished) {
|
||||
@@ -308,24 +399,19 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
barClass: '',
|
||||
maintainable,
|
||||
unpublished,
|
||||
kind: 'plan' as const,
|
||||
roleTag,
|
||||
}
|
||||
}
|
||||
if (c.mode === 'online') {
|
||||
const task = myTaskByCourse.value.get(c.id)
|
||||
const status = task?.status || 'pending'
|
||||
const stateMap: Record<string, { state: string; cls: string }> = {
|
||||
done: { state: '已完成', cls: 'is-good' },
|
||||
doing: { state: '学习中', cls: 'is-doing' },
|
||||
overdue: { state: '已逾期', cls: 'is-bad' },
|
||||
pending: { state: '待学习', cls: '' },
|
||||
}
|
||||
const cur = status === 'done' ? { state: '已完成', cls: 'is-good', width: '100%', bar: 'is-done' }
|
||||
: status === 'doing' ? { state: '学习中', cls: 'is-doing', width: '100%', bar: 'is-doing-bar' }
|
||||
: status === 'overdue' ? { state: '已逾期', cls: 'is-bad', width: '0%', bar: '' }
|
||||
: { state: '待学习', cls: '', width: '0%', bar: '' }
|
||||
const materials = c.material_ids?.length ? ` · 课件 ${c.material_ids.length} 个` : ''
|
||||
return { id: c.id, name: c.name, mode: c.mode, meta: `${head}${materials}`, state: cur.state, stateClass: cur.cls, barWidth: cur.width, barClass: cur.bar, maintainable, unpublished, roleTag }
|
||||
return { id: c.id, name: c.name, mode: c.mode, meta: `${head}${materials}`, state: cur.state, stateClass: cur.cls, barWidth: cur.width, barClass: cur.bar, maintainable, unpublished, kind: 'plan' as const, roleTag }
|
||||
}
|
||||
const sess = (sessionByCourse.value.get(c.id) || []).sort((a, b) => String(a.start_at).localeCompare(String(b.start_at)))
|
||||
const finished = sess.filter((s) => s.status === 'finished').length
|
||||
@@ -343,6 +429,7 @@ const visibleCards = computed<CatalogCard[]>(() => {
|
||||
barClass: ratio >= 100 ? 'is-done' : '',
|
||||
maintainable,
|
||||
unpublished,
|
||||
kind: 'plan' as const,
|
||||
roleTag,
|
||||
}
|
||||
})
|
||||
@@ -352,21 +439,27 @@ const loadAll = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 讲师/管理角色额外拉维护视角课程(纯讲师=自己名下含草稿;管理=全部,下方按讲师 id 过滤),
|
||||
// 供「我的课程」展示我主讲(含未发布)课程与「待维护」统计;纯学员无此视角,跳过。
|
||||
// 供「我的培训」展示我主讲(含未发布)课程与「待维护」统计;纯学员无此视角,跳过。
|
||||
const needMaintainView = props.admin || props.roles.some((r) => ['hr', 'supervisor', 'exec', 'lecturer'].includes(r))
|
||||
const [c, t, s, me, lc] = await Promise.all([
|
||||
const [c, t, s, me, lc, lib, exams] = await Promise.all([
|
||||
// 学员目录视图:scope=student 统一走已发布课程口径(讲师账号的学习视角不受课程维护范围影响)
|
||||
listCourses({ page_size: 100, scope: 'student' }),
|
||||
listMyLearningTasks().catch(() => null),
|
||||
listSessions({ year: 0, month: 0, scope: 'student' }).catch(() => null),
|
||||
getMyProfile().catch(() => null),
|
||||
needMaintainView ? listCourses({ page_size: 100 }).catch(() => null) : Promise.resolve(null),
|
||||
// 和信课程目录(000154):课程管理已发布课程
|
||||
listCourseLibrary({ page_size: 500 }).catch(() => null),
|
||||
// 我的考试记录(000154)
|
||||
listMyExamRecords().catch(() => null),
|
||||
])
|
||||
courses.value = unwrap(c)?.items || []
|
||||
myTasks.value = (t && unwrap(t)) || []
|
||||
sessions.value = (s && unwrap(s)) || []
|
||||
myProfile.value = (me && unwrap(me)) || null
|
||||
lecturerCourses.value = (lc && unwrap(lc)?.items) || []
|
||||
libraryItems.value = (lib && unwrap(lib)?.items) || []
|
||||
myExamRecords.value = (exams && unwrap(exams)) || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -480,6 +573,19 @@ onMounted(loadAll)
|
||||
padding: 48px 0;
|
||||
}
|
||||
|
||||
// 「我的考试」成绩列:及格绿/不及格红
|
||||
.exam-score {
|
||||
font-weight: 600;
|
||||
|
||||
&.is-good {
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
|
||||
&.is-bad {
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
|
||||
.course-card {
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -4,13 +4,16 @@
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title plan-title-row">
|
||||
年度需求收集({{ selectedYear }})
|
||||
年度需求收集
|
||||
<!-- 年份下拉用 t-option 槽渲染:TDesign :options 需 {label,value} 对象,
|
||||
直接传 number[] 会渲染空白选项(无法选中) -->
|
||||
<t-select
|
||||
v-model="selectedYear"
|
||||
class="year-select"
|
||||
:options="yearOptions"
|
||||
@change="onYearChange"
|
||||
/>
|
||||
>
|
||||
<t-option v-for="y in yearOptions" :key="y" :value="y" :label="String(y)" />
|
||||
</t-select>
|
||||
</span>
|
||||
<div class="panel-box__actions">
|
||||
<t-button v-if="canManage" theme="primary" @click="openCollect">收集下年度计划</t-button>
|
||||
@@ -18,10 +21,10 @@
|
||||
<t-button v-if="canManage" variant="outline" @click="importDemandsVisible = true">批量导入</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 搜索:状态 / 部门 / 课程名称模糊;批量确认/删除与查询条件同行 -->
|
||||
<!-- 搜索:状态 / 部门 / 课程名称模糊;批量确认(仅本部门经理)/删除与查询条件同行 -->
|
||||
<div class="demand-search">
|
||||
<t-select v-model="demandSearch.state" clearable placeholder="状态" style="width: 110px">
|
||||
<t-option label="待校验" value="pending" />
|
||||
<t-option label="待核验" value="pending" />
|
||||
<t-option label="已确认" value="confirmed" />
|
||||
<t-option label="已修正" value="fixed" />
|
||||
</t-select>
|
||||
@@ -37,7 +40,7 @@
|
||||
/>
|
||||
<t-button variant="outline" @click="loadDemands">查询</t-button>
|
||||
<t-button variant="outline" @click="onResetDemandSearch">重置</t-button>
|
||||
<t-button v-if="canManage" theme="primary" variant="outline" :disabled="!selectedDemandKeys.length" :loading="batchSaving" @click="onBatchConfirm">批量确认</t-button>
|
||||
<t-button v-if="canConfirm" theme="primary" variant="outline" :disabled="!selectedDemandKeys.length" :loading="batchSaving" @click="onBatchConfirm">批量确认</t-button>
|
||||
<t-button v-if="canManage" theme="danger" variant="outline" :disabled="!selectedDemandKeys.length" :loading="batchSaving" @click="onBatchDelete">批量删除</t-button>
|
||||
<span class="demand-selected-hint">已选 {{ selectedDemandKeys.length }} 项(可批量确认/删除未确认需求)</span>
|
||||
</div>
|
||||
@@ -50,10 +53,17 @@
|
||||
:loading="loading"
|
||||
>
|
||||
<template #dept_name="{ row }">{{ row.dept_name || '-' }}</template>
|
||||
<template #code="{ row }">
|
||||
<t-tooltip v-if="row.code" :content="row.code">
|
||||
<span class="cell-ellipsis">{{ row.code }}</span>
|
||||
</t-tooltip>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #lecturer_name="{ row }">{{ row.lecturer_name || '-' }}</template>
|
||||
<template #planned_time="{ row }">{{ (row.planned_time || '').slice(0, 10) || '-' }}</template>
|
||||
<!-- 计划培训月份入库格式「YYYY-M」(如 2027-1),原样展示 -->
|
||||
<template #planned_time="{ row }">{{ row.planned_time || '-' }}</template>
|
||||
<template #location="{ row }">{{ row.location || '-' }}</template>
|
||||
<!-- 参加人员/备注可能很长:单行省略,悬停浮出全部内容 -->
|
||||
<!-- 适合人员/备注可能很长:单行省略,悬停浮出全部内容 -->
|
||||
<template #post_scope="{ row }">
|
||||
<t-tooltip v-if="row.post_scope" :content="row.post_scope">
|
||||
<span class="cell-ellipsis">{{ row.post_scope }}</span>
|
||||
@@ -68,13 +78,13 @@
|
||||
</template>
|
||||
<template #check_status="{ row }">
|
||||
<t-tag v-if="row.check_status === 'passed'" theme="success" variant="light" size="small">已确认</t-tag>
|
||||
<t-tag v-else-if="row.check_status === 'pending'" theme="warning" variant="light" size="small">待校验</t-tag>
|
||||
<t-tag v-else-if="row.check_status === 'pending'" theme="warning" variant="light" size="small">待核验</t-tag>
|
||||
<t-tag v-else theme="default" variant="light" size="small">已修正</t-tag>
|
||||
</template>
|
||||
<template #op="{ row }">
|
||||
<template v-if="row.status !== 'confirmed'">
|
||||
<t-button
|
||||
v-if="canManage"
|
||||
v-if="canConfirm"
|
||||
variant="text" theme="primary" size="small" @click="onConfirmDemand(row)"
|
||||
>确认</t-button>
|
||||
<t-button
|
||||
@@ -91,30 +101,54 @@
|
||||
<!-- 提报需求弹窗(编辑态复用:部门按提报人自动获取) -->
|
||||
<t-dialog v-model:visible="demandFormVisible" :header="demandDialogTitle" width="560">
|
||||
<t-form :data="demandForm" label-width="90" @submit="onSaveDemand">
|
||||
<t-form-item v-if="demandForm.id" label="编号" name="code">
|
||||
<t-input :value="demandCodeDisplay" disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="课程名称" name="course_name" required>
|
||||
<t-input v-model="demandForm.course_name" placeholder="请输入课程名称" />
|
||||
<!-- 000156:从课程管理选择本部门课程(自动带出分类/讲师/适合人员),也可直接填写新课程 -->
|
||||
<t-select
|
||||
v-model="demandForm.course_name"
|
||||
clearable
|
||||
filterable
|
||||
creatable
|
||||
:loading="libraryLoading"
|
||||
placeholder="从课程管理选择本部门课程,或直接填写新课程"
|
||||
style="width: 100%"
|
||||
@change="onDemandCourseChange"
|
||||
>
|
||||
<t-option
|
||||
v-for="c in deptCourseOptions"
|
||||
:key="c.id"
|
||||
:value="c.name"
|
||||
:label="`${c.name}${c.category ? `(${c.category})` : ''}`"
|
||||
/>
|
||||
</t-select>
|
||||
</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="提交时按提报人所在部门自动获取" />
|
||||
</t-form-item>
|
||||
<t-form-item label="参加人员" name="post_scope">
|
||||
<t-input v-model="demandForm.post_scope" placeholder="可填写多个参加人员,用、或,分隔(选填)" />
|
||||
<t-form-item label="适合人员" name="post_scope">
|
||||
<t-input v-model="demandForm.post_scope" placeholder="可填写多个适合人员,用、或,分隔(选填)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="计划培训时间" name="planned_time">
|
||||
<t-date-picker
|
||||
v-model="demandForm.planned_time"
|
||||
format="YYYY-MM-DD"
|
||||
<t-form-item label="计划培训月份" name="planned_month">
|
||||
<t-select
|
||||
v-model="demandForm.planned_month"
|
||||
clearable
|
||||
placeholder="选填,精确到日期;确认后同步到培训课程"
|
||||
placeholder="选填,只需选到月份;确认后同步到培训课程"
|
||||
style="width: 100%"
|
||||
/>
|
||||
>
|
||||
<t-option v-for="m in 12" :key="m" :label="`${m} 月`" :value="m" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="内/外培训" name="train_type">
|
||||
<t-radio-group v-model="demandForm.train_type" variant="default-filled">
|
||||
<t-radio-button value="">未选择</t-radio-button>
|
||||
<t-radio-button value="内部">内部</t-radio-button>
|
||||
<t-radio-button value="外部">外部</t-radio-button>
|
||||
</t-radio-group>
|
||||
<!-- 下拉选择(000154):内部/外部,清空即未选择 -->
|
||||
<t-select v-model="demandForm.train_type" clearable placeholder="从下拉选择内部或外部(选填)" style="width: 100%">
|
||||
<t-option label="内部" value="内部" />
|
||||
<t-option label="外部" value="外部" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="厂区" name="plant">
|
||||
<t-input v-model="demandForm.plant" placeholder="如:三厂(选填)" />
|
||||
@@ -158,15 +192,15 @@
|
||||
<t-textarea
|
||||
v-model="importDemandsText"
|
||||
:autosize="{ minRows: 6 }"
|
||||
placeholder="或粘贴需求行:课程名称[,计划培训时间如 2026-11-19] (支持中英文逗号)"
|
||||
placeholder="或粘贴需求行:课程名称[,计划培训月份如 3] (支持中英文逗号)"
|
||||
/>
|
||||
<div class="form-hint">模板列对应:编号/部门/课程名称/参加人员/地点/培訓費用/內外培訓(内部或外部)/计划培训时间(如 2026-11-19)/讲师/备注;参加人员可填多人(、/,分隔),讲师可填系统员工(按姓名自动匹配并带出部门)或外部讲师姓名;未指定部门的需求导入后为「待校验」,由人事确认补全。</div>
|
||||
<div class="form-hint">模板列对应:编号/部门/课程名称/适合人员/地点/培訓費用/内/外培训(内部或外部,下拉选择)/计划培训月份(1~12,下拉选择)/讲师/备注;适合人员可填多人(、/,分隔),讲师可填系统员工(按姓名自动匹配并带出部门)或外部讲师姓名;导入后统一为「待核验」,由部门经理核验确认。</div>
|
||||
<template #footer>
|
||||
<t-button theme="primary" :loading="saving" @click="onImportDemands">导入粘贴内容</t-button>
|
||||
</template>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 收集下年度计划:发送模板 + 推送人员(默认人事与各课长,可增删),确认后站内+企微批量推送 -->
|
||||
<!-- 收集下年度计划:发送模板 + 推送人员(默认各课长,可增删),确认后站内+企微批量推送 -->
|
||||
<t-dialog v-model:visible="collectVisible" :header="`收集下年度计划(${nextYear})`" width="560">
|
||||
<div class="collect-section-title">发送模板</div>
|
||||
<div class="collect-template-row">
|
||||
@@ -179,13 +213,13 @@
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
placeholder="默认各部门经理、主管、文员,可修改添加删除"
|
||||
placeholder="默认各课长,可修改添加删除"
|
||||
style="width: 100%"
|
||||
:loading="membersLoading"
|
||||
>
|
||||
<t-option v-for="m in members" :key="m.user_id" :value="m.user_id" :label="memberLabel(m)" />
|
||||
</t-select>
|
||||
<div class="form-hint">默认勾选各部门经理、主管、文员;可自行添加或移除推送人员。</div>
|
||||
<div class="form-hint">默认勾选各课长;可自行添加或移除推送人员。</div>
|
||||
<div class="collect-section-title">通知内容</div>
|
||||
<t-textarea v-model="collectForm.content" :autosize="{ minRows: 3 }" />
|
||||
<template #footer>
|
||||
@@ -208,6 +242,8 @@ import {
|
||||
deleteDemand,
|
||||
getMyProfile,
|
||||
importDemands,
|
||||
listCourseLibrary,
|
||||
listDemandYears,
|
||||
listDemands,
|
||||
listDepts,
|
||||
listLecturers,
|
||||
@@ -215,6 +251,7 @@ import {
|
||||
saveDemand,
|
||||
type TrainingDept,
|
||||
type TrainingDemand,
|
||||
type TrainingLibraryCourse,
|
||||
type TrainingLecturerOption,
|
||||
type TrainingMember,
|
||||
unwrap,
|
||||
@@ -224,35 +261,59 @@ const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
|
||||
// 计划管理(录入/推送/排课):人事/课长(roles 已按权限组展开,经理自动命中课长)
|
||||
const canManage = computed(() => props.admin || props.roles.some((r) => r === 'hr' || r === 'supervisor'))
|
||||
// 核验确认入口:经理职称角色可见(空间管理员直通,便于授权引导);
|
||||
// 实际可确认范围按行校验(本部门+经理,000154),越权点击统一提示联系部门经理。
|
||||
const canConfirm = computed(() => props.admin || props.roles.some((r) => r === 'exec'))
|
||||
// 行级确认权限:需求归属部门=本人所在部门,且本人具有经理职称角色。
|
||||
const canConfirmDemand = (row: TrainingDemand) =>
|
||||
canConfirm.value && Boolean(row.dept_id) && row.dept_id === myDeptId.value
|
||||
|
||||
const now = new Date()
|
||||
const currentYear = now.getFullYear()
|
||||
|
||||
// 年度需求收集:可切换年度查看各年的收集汇总(近 4 年 + 明年)
|
||||
// 年度需求收集:年份下拉为需求库实际年份(降序),默认展示最新一年(无数据回退当前年)
|
||||
const selectedYear = ref(currentYear)
|
||||
const yearOptions = Array.from({ length: 6 }, (_, i) => currentYear - 4 + i)
|
||||
const yearOptions = ref<number[]>([])
|
||||
const onYearChange = () => loadDemands()
|
||||
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const demands = ref<TrainingDemand[]>([])
|
||||
|
||||
// 表单/搜索数据源:部门树、讲师名册
|
||||
// 表单/搜索数据源:部门树、讲师名册、课程管理条目(课程名称下拉,000156)
|
||||
const depts = ref<TrainingDept[]>([])
|
||||
const lecturers = ref<TrainingLecturerOption[]>([])
|
||||
const libraryCourses = ref<TrainingLibraryCourse[]>([])
|
||||
const libraryLoading = ref(false)
|
||||
const myDeptName = ref('')
|
||||
// 本人所在部门 id:行级确认权限校验用(需求归属部门须与本人一致)
|
||||
const myDeptId = ref('')
|
||||
|
||||
// 本部门课程(000156):课程名称下拉仅列所属部门课程——新建按提报人部门,
|
||||
// 编辑按需求归属部门(人事代改他部门需求时同样联动);部门为空回退全部课程
|
||||
const deptCourseOptions = computed(() => {
|
||||
const deptId = demandForm.value.id
|
||||
? demands.value.find((d) => d.id === demandForm.value.id)?.dept_id || myDeptId.value
|
||||
: myDeptId.value
|
||||
return deptId
|
||||
? libraryCourses.value.filter((c) => c.owner_dept_id === deptId)
|
||||
: libraryCourses.value
|
||||
})
|
||||
|
||||
const demandFormVisible = ref(false)
|
||||
const importDemandsVisible = ref(false)
|
||||
const importDemandsText = ref('')
|
||||
|
||||
// 搜索条件:已确认按人工确认(status)过滤,待校验/已修正按规则校验状态(check_status)
|
||||
// 搜索条件:已确认按人工确认(status)过滤,待核验/已修正按规则校验状态(check_status)
|
||||
const demandSearch = ref({ state: '', dept_id: '', keyword: '' })
|
||||
|
||||
const demandForm = ref({
|
||||
id: '',
|
||||
course_name: '',
|
||||
planned_time: '',
|
||||
// 分类随所选课程自动带出(000156),确认后经需求→课程同步落到课程侧标签
|
||||
category: '',
|
||||
// 计划培训月份(1~12,选填):提交时与收集年度合成 planned_time「YYYY-M」
|
||||
planned_month: '' as '' | number,
|
||||
session_count: 1,
|
||||
train_type: '',
|
||||
plant: '',
|
||||
@@ -263,6 +324,22 @@ const demandForm = ref({
|
||||
remark: '',
|
||||
})
|
||||
|
||||
// 选定课程自动带出(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
|
||||
const lecturerValue = course.lecturer_id || course.lecturer_external || ''
|
||||
if (lecturerValue) {
|
||||
if (!lecturers.value.some((l) => l.id === lecturerValue)) {
|
||||
lecturers.value = [...lecturers.value, { id: lecturerValue, name: course.lecturer_name || lecturerValue }]
|
||||
}
|
||||
demandForm.value.lecturer = lecturerValue
|
||||
}
|
||||
}
|
||||
|
||||
// 讲师解析:名册 id 直接用;名册姓名映射为对应 id;否则作为外部讲师姓名落 lecturer_external
|
||||
const resolveLecturer = (value: string): { lecturer_id: string; lecturer_external: string } => {
|
||||
const v = (value || '').trim()
|
||||
@@ -275,6 +352,12 @@ const resolveLecturer = (value: string): { lecturer_id: string; lecturer_externa
|
||||
|
||||
const demandDialogTitle = computed(() => (demandForm.value.id ? '编辑培训需求' : '在线提报培训需求'))
|
||||
|
||||
// 编辑态展示年计划编号(服务端生成,不可改)
|
||||
const demandCodeDisplay = computed(() => {
|
||||
const row = demands.value.find((d) => d.id === demandForm.value.id)
|
||||
return row?.code || '-'
|
||||
})
|
||||
|
||||
const deptMap = computed(() => {
|
||||
const m: Record<string, string> = {}
|
||||
for (const d of depts.value) m[d.id] = d.name
|
||||
@@ -292,11 +375,13 @@ const deptDisplay = computed(() => {
|
||||
|
||||
const demandColumns = [
|
||||
{ colKey: 'row-select', type: 'multiple', width: 44, disabled: ({ row }: { row: TrainingDemand }) => row.status === 'confirmed' },
|
||||
// 年计划编号(AP-<year>-####,创建时由服务端生成)
|
||||
{ colKey: 'code', title: '编号', width: 130 },
|
||||
{ colKey: 'course_name', title: '课程名称' },
|
||||
{ colKey: 'dept_name', title: '部门', width: 100 },
|
||||
{ colKey: 'post_scope', title: '参加人员', width: 140 },
|
||||
{ colKey: 'post_scope', title: '适合人员', width: 140 },
|
||||
{ colKey: 'lecturer_name', title: '讲师', width: 100 },
|
||||
{ colKey: 'planned_time', title: '计划培训时间', width: 110 },
|
||||
{ colKey: 'planned_time', title: '计划培训月份', width: 110 },
|
||||
{ colKey: 'train_type', title: '内/外培训', width: 90 },
|
||||
{ colKey: 'location', title: '地点', width: 100 },
|
||||
{ colKey: 'remark', title: '备注', minWidth: 140 },
|
||||
@@ -315,11 +400,17 @@ const onBatchConfirm = async () => {
|
||||
MessagePlugin.warning('请先勾选未确认的需求')
|
||||
return
|
||||
}
|
||||
// 000154:批量确认仅作用于本人可确认的需求(本部门+经理),越权行全部跳过
|
||||
const allowed = rows.filter(canConfirmDemand)
|
||||
if (!allowed.length) {
|
||||
MessagePlugin.warning('暂无权限,请联系部门经理~')
|
||||
return
|
||||
}
|
||||
batchSaving.value = true
|
||||
let ok = 0
|
||||
let fail = 0
|
||||
try {
|
||||
for (const row of rows) {
|
||||
for (const row of allowed) {
|
||||
try {
|
||||
await confirmDemand(row.id)
|
||||
ok += 1
|
||||
@@ -327,7 +418,11 @@ const onBatchConfirm = async () => {
|
||||
fail += 1
|
||||
}
|
||||
}
|
||||
MessagePlugin.success(`批量确认完成:成功 ${ok} 条${fail ? `,失败 ${fail} 条` : ''};已确认需求已自动生成草稿课程到培训课程`)
|
||||
const skipped = rows.length - allowed.length
|
||||
MessagePlugin.success(
|
||||
`批量确认完成:成功 ${ok} 条${fail ? `,失败 ${fail} 条` : ''}` +
|
||||
`${skipped ? `,跳过 ${skipped} 条非本部门需求` : ''};已确认需求已自动生成草稿课程到培训课程`,
|
||||
)
|
||||
selectedDemandKeys.value = []
|
||||
loadAll()
|
||||
} finally {
|
||||
@@ -378,6 +473,20 @@ const loadDemands = async () => {
|
||||
demands.value = unwrap(d)?.items || []
|
||||
}
|
||||
|
||||
// 年份下拉数据源:需求库实际年份(降序)。resetSelection=true 时默认选中最新一年
|
||||
// (首次进入);后续刷新仅在当前选中年份已无数据时回退最新,避免打断用户选择。
|
||||
const loadDemandYears = async (resetSelection = false) => {
|
||||
try {
|
||||
const years = unwrap<number[]>(await listDemandYears()) || []
|
||||
yearOptions.value = years
|
||||
if (years.length && (resetSelection || !years.includes(selectedYear.value))) {
|
||||
selectedYear.value = years[0]
|
||||
}
|
||||
} catch {
|
||||
/* 年份拉取失败保留当前选择,列表按当前年份照常查询 */
|
||||
}
|
||||
}
|
||||
|
||||
const onResetDemandSearch = () => {
|
||||
demandSearch.value = { state: '', dept_id: '', keyword: '' }
|
||||
loadDemands()
|
||||
@@ -385,20 +494,33 @@ const onResetDemandSearch = () => {
|
||||
|
||||
// 表单下拉与提报人部门(一次性加载,失败不阻塞主列表)
|
||||
const loadFormOptions = async () => {
|
||||
libraryLoading.value = true
|
||||
try {
|
||||
const [d, l, me] = await Promise.all([listDepts(), listLecturers(), getMyProfile()])
|
||||
const [d, l, me, lib] = await Promise.all([
|
||||
listDepts(),
|
||||
listLecturers(),
|
||||
getMyProfile(),
|
||||
listCourseLibrary({ page_size: 500 }).catch(() => null),
|
||||
])
|
||||
depts.value = unwrap(d) || []
|
||||
lecturers.value = unwrap(l) || []
|
||||
libraryCourses.value = (lib && unwrap(lib))?.items || []
|
||||
const member = unwrap(me)
|
||||
if (member?.dept_id) myDeptName.value = deptMap.value[member.dept_id] || ''
|
||||
if (member?.dept_id) {
|
||||
myDeptId.value = member.dept_id
|
||||
myDeptName.value = deptMap.value[member.dept_id] || ''
|
||||
}
|
||||
} catch {
|
||||
/* 忽略:仅影响下拉可选项 */
|
||||
} finally {
|
||||
libraryLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadAll = async () => {
|
||||
const loadAll = async (resetYearSelection = false) => {
|
||||
loading.value = true
|
||||
try {
|
||||
await loadDemandYears(resetYearSelection)
|
||||
await loadDemands()
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -409,7 +531,8 @@ const onOpenDemandForm = () => {
|
||||
demandForm.value = {
|
||||
id: '',
|
||||
course_name: '',
|
||||
planned_time: '',
|
||||
category: '',
|
||||
planned_month: '',
|
||||
session_count: 1,
|
||||
train_type: '',
|
||||
plant: '',
|
||||
@@ -421,16 +544,31 @@ const onOpenDemandForm = () => {
|
||||
demandFormVisible.value = true
|
||||
}
|
||||
|
||||
// 计划培训月份回显:从「YYYY-M」取月份;旧日期格式(YYYY-MM-DD)无法映射月份留空
|
||||
const plannedMonthOfValue = (value: string): '' | number => {
|
||||
const m = (value || '').trim().match(/^\d{4}-(\d{1,2})$/)
|
||||
const month = m ? Number(m[1]) : 0
|
||||
return month >= 1 && month <= 12 ? month : ''
|
||||
}
|
||||
|
||||
// 编辑旧数据兜底:原计划培训时间为旧日期格式且未重新选择月份时,保存保留原值
|
||||
const editOriginalPlanned = ref({ planned_time: '', expect_month: 0 })
|
||||
|
||||
const onEditDemand = (row: TrainingDemand) => {
|
||||
// 讲师回显:系统员工(id)或外部姓名;不在名册的值追加临时选项避免显示裸 ID
|
||||
const lecturerValue = row.lecturer_id || row.lecturer_external || ''
|
||||
if (lecturerValue && !lecturers.value.some((l) => l.id === lecturerValue)) {
|
||||
lecturers.value = [...lecturers.value, { id: lecturerValue, name: row.lecturer_name || lecturerValue }]
|
||||
}
|
||||
editOriginalPlanned.value = {
|
||||
planned_time: row.planned_time || '',
|
||||
expect_month: row.expect_month || 0,
|
||||
}
|
||||
demandForm.value = {
|
||||
id: row.id,
|
||||
course_name: row.course_name,
|
||||
planned_time: row.planned_time || '',
|
||||
category: row.category || '',
|
||||
planned_month: plannedMonthOfValue(row.planned_time || ''),
|
||||
session_count: row.session_count || 1,
|
||||
train_type: row.train_type || '',
|
||||
plant: row.plant || '',
|
||||
@@ -449,15 +587,21 @@ const onSaveDemand = async () => {
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
// 计划培训时间只保留年月日入库;讲师解析为 id 或外部姓名
|
||||
const { lecturer, ...rest } = demandForm.value
|
||||
// 计划培训月份与收集年度合成「YYYY-M」入库,并回填期望月份;
|
||||
// 编辑旧数据且未选月份时保留原计划培训值;讲师解析为 id 或外部姓名
|
||||
const { lecturer, planned_month, ...rest } = demandForm.value
|
||||
const month = Number(planned_month) || 0
|
||||
const isEdit = Boolean(demandForm.value.id)
|
||||
await saveDemand({
|
||||
...rest,
|
||||
...resolveLecturer(lecturer),
|
||||
planned_time: plannedTimeOf(demandForm.value.planned_time),
|
||||
planned_time: month
|
||||
? `${selectedYear.value}-${month}`
|
||||
: (isEdit ? editOriginalPlanned.value.planned_time : ''),
|
||||
expect_month: month || (isEdit ? editOriginalPlanned.value.expect_month : 0) || undefined,
|
||||
year: selectedYear.value,
|
||||
})
|
||||
MessagePlugin.success(demandForm.value.id ? '需求已更新' : '需求已提交,待人事确认')
|
||||
MessagePlugin.success(demandForm.value.id ? '需求已更新' : '需求已提交,待核验')
|
||||
demandFormVisible.value = false
|
||||
loadAll()
|
||||
} catch (e: any) {
|
||||
@@ -486,17 +630,19 @@ const onImportDemands = async () => {
|
||||
const items: Partial<TrainingDemand>[] = []
|
||||
const skipped: string[] = []
|
||||
lines.forEach((line, idx) => {
|
||||
// 兼容中英文逗号(\uFF0C)与制表符拆分:课程名称[,计划培训时间]
|
||||
// 兼容中英文逗号(\uFF0C)与制表符拆分:课程名称[,计划培训月份]
|
||||
const parts = line.split(/[,\uFF0C\t]/).map((s) => s.trim())
|
||||
const courseName = parts[0] || ''
|
||||
if (!courseName) {
|
||||
skipped.push(String(idx + 1))
|
||||
return
|
||||
}
|
||||
const { planned, month } = plannedMonthFromValue(parts[1] || '', selectedYear.value)
|
||||
items.push({
|
||||
course_name: courseName,
|
||||
year: selectedYear.value,
|
||||
planned_time: plannedTimeFromRow({ v: parts[1] || '' }, 'v', selectedYear.value) || undefined,
|
||||
planned_time: planned || undefined,
|
||||
expect_month: month || undefined,
|
||||
})
|
||||
})
|
||||
if (!items.length) {
|
||||
@@ -519,41 +665,34 @@ const onImportDemands = async () => {
|
||||
}
|
||||
|
||||
// ---- 教育训练需求表模板导入(docs/moban,经 /templates/ 下发) ----
|
||||
// 模板表头:编号/部门/课程名称/参加人员/地点/培訓費用/內外培訓/计划培训时间/讲师/备注,
|
||||
// 讲师按员工档案姓名匹配(带出部门)、非系统员工落外部讲师姓名,计划培训时间只保留年月日。
|
||||
// 模板表头:编号/部门/课程名称/适合人员/地点/培訓費用/内/外培训/计划培训月份(1~12)/讲师/备注,
|
||||
// 讲师按员工档案姓名匹配(带出部门)、非系统员工落外部讲师姓名,计划培训月份按「收集年度-月份」入库。
|
||||
|
||||
const onDownloadDemandTemplate = () => downloadTrainingTemplate(DEMAND_TEMPLATE_KEY)
|
||||
|
||||
// 计划培训时间入库格式:只保留年月日(YYYY-MM-DD)
|
||||
const plannedTimeOf = (value: string) => (value || '').trim().slice(0, 10)
|
||||
|
||||
// 从模板 Excel「计划培训时间」列解析计划培训时间:兼容 2026/6/8、2026-6-8、
|
||||
// 2026年6月8日、6/8(年份缺省取当前收集年度)及"11"这类纯月份(归一到当月 1 日);
|
||||
// 尾随时分忽略(入库只到日);越界或解析失败返回空串
|
||||
const plannedTimeFromRow = (row: Record<string, string>, timeCol: string, fallbackYear: number): string => {
|
||||
const raw = (row[timeCol] || '').trim()
|
||||
if (!raw) return ''
|
||||
const pad = (n: string) => n.padStart(2, '0')
|
||||
const validDate = (m: string, d: string) => {
|
||||
const month = Number(m)
|
||||
const day = Number(d)
|
||||
return month >= 1 && month <= 12 && day >= 1 && day <= 31
|
||||
// 计划培训月份解析:兼容 1~12 纯月份数字(1、12月)与旧日期格式(2027-1、
|
||||
// 2026/6/8、2026年6月8日等取其月份);年份统一取收集年度(模板标题年),
|
||||
// 入库 planned_time=「YYYY-M」(如 2027-1);无法解析返回空。
|
||||
const plannedMonthFromValue = (raw: string, fallbackYear: number): { planned: string; month: number } => {
|
||||
const v = (raw || '').trim()
|
||||
if (!v) return { planned: '', month: 0 }
|
||||
const full = v.match(/^20\d{2}[-/.年]\s*(\d{1,2})/)
|
||||
if (full) {
|
||||
const month = Number(full[1])
|
||||
if (month >= 1 && month <= 12) return { planned: `${fallbackYear}-${month}`, month }
|
||||
}
|
||||
const full = raw.match(/(\d{4})[./\-\s年]*(\d{1,2})[./\-\s月]*(\d{1,2})日?/)
|
||||
if (full && validDate(full[2], full[3])) {
|
||||
return `${full[1]}-${pad(full[2])}-${pad(full[3])}`
|
||||
const monthOnly = v.match(/^(\d{1,2})\s*月?$/)
|
||||
if (monthOnly) {
|
||||
const month = Number(monthOnly[1])
|
||||
if (month >= 1 && month <= 12) return { planned: `${fallbackYear}-${month}`, month }
|
||||
}
|
||||
const short = raw.match(/(\d{1,2})[./月](\d{1,2})日?/)
|
||||
if (short && validDate(short[1], short[2])) {
|
||||
return `${fallbackYear}-${pad(short[1])}-${pad(short[2])}`
|
||||
}
|
||||
const monthOnly = raw.match(/^(\d{1,2})\s*月?$/)
|
||||
if (monthOnly && Number(monthOnly[1]) >= 1 && Number(monthOnly[1]) <= 12) {
|
||||
return `${fallbackYear}-${pad(monthOnly[1])}-01`
|
||||
}
|
||||
return ''
|
||||
return { planned: '', month: 0 }
|
||||
}
|
||||
|
||||
// 模板 Excel 列取值:新「计划培训月份」列优先,兼容旧「计划培训时间」列模板
|
||||
const plannedMonthFromRow = (row: Record<string, string>, fallbackYear: number) =>
|
||||
plannedMonthFromValue((row['计划培训月份'] || row['计划培训时间'] || '').trim(), fallbackYear)
|
||||
|
||||
const onImportDemandExcel = async (e: Event) => {
|
||||
const input = e.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
@@ -564,10 +703,21 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
// 定位含「课程名称」表头的工作表(模板首两行为公司/表题合并单元格);
|
||||
// 表头键做空白归一(兼容「地 点」等内含空格的列名,否则该列会被静默丢弃)
|
||||
let dataRows: Record<string, string>[] | null = null
|
||||
// 模板标题年(000157):标题行「2027 年度教育训练需求表」的年份优先于年份下拉——
|
||||
// 模板面向下一年度收集,导入按标题年入库(需求年份与计划培训「年-月」一致)
|
||||
let titleYear = selectedYear.value
|
||||
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() === '课程名称'))
|
||||
if (headerIdx < 0) continue
|
||||
for (const r of sheetRows.slice(0, Math.max(headerIdx, 1))) {
|
||||
const hit = (r || []).map((c) => String(c)).find((s) => /20\d{2}/.test(s) && s.includes('年'))
|
||||
const m = hit?.match(/20\d{2}/)
|
||||
if (m) {
|
||||
titleYear = Number(m[0])
|
||||
break
|
||||
}
|
||||
}
|
||||
const header = (sheetRows[headerIdx] || []).map((c) => String(c).trim().replace(/\s+/g, ''))
|
||||
dataRows = sheetRows.slice(headerIdx + 1).map((arr) => {
|
||||
const row: Record<string, string> = {}
|
||||
@@ -638,18 +788,22 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
externalLecturers += 1
|
||||
}
|
||||
}
|
||||
// 计划培训月份:新「计划培训月份」列(1~12)优先,兼容旧「计划培训时间」列;
|
||||
// 年份取模板标题年(000157),入库「YYYY-M」并回填期望月份
|
||||
const plannedMonth = plannedMonthFromRow(row, titleYear)
|
||||
items.push({
|
||||
course_name: courseName,
|
||||
year: selectedYear.value,
|
||||
year: titleYear,
|
||||
plant: (row['厂区'] || '').trim(),
|
||||
session_count: Number.parseInt(row['次数'] || '') || 1,
|
||||
location: (row['地点'] || '').trim(),
|
||||
post_scope: (row['参加人员'] || '').trim(),
|
||||
train_type: (row['內/外培訓'] || row['内/外培训'] || '').trim(),
|
||||
post_scope: (row['适合人员'] || row['参加人员'] || '').trim(),
|
||||
train_type: (row['内/外培训'] || row['內/外培訓'] || '').trim(),
|
||||
lecturer_id: lecturerId,
|
||||
lecturer_external: lecturerExternal || undefined,
|
||||
dept_id: deptId,
|
||||
planned_time: plannedTimeFromRow(row, '计划培训时间', selectedYear.value) || undefined,
|
||||
planned_time: plannedMonth.planned || undefined,
|
||||
expect_month: plannedMonth.month || undefined,
|
||||
remark: (row['备注'] || '').trim(),
|
||||
})
|
||||
})
|
||||
@@ -659,16 +813,19 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
await importDemands(items)
|
||||
const imported = unwrap(await importDemands(items)) as { imported: number; notified?: number } | null
|
||||
MessagePlugin.success(
|
||||
`已从模板导入 ${items.length} 条需求` +
|
||||
`已从模板导入 ${items.length} 条需求(${titleYear}年度)` +
|
||||
(lecturerHits || externalLecturers
|
||||
? `,讲师匹配 ${lecturerHits} 人${externalLecturers ? `,外部讲师 ${externalLecturers} 人` : ''}`
|
||||
: '') +
|
||||
(deptFromLecturer ? `(其中 ${deptFromLecturer} 条部门按讲师带出)` : '') +
|
||||
(skippedRows ? `,另有 ${skippedRows} 行未填课程名称已跳过` : ''),
|
||||
(skippedRows ? `,另有 ${skippedRows} 行未填课程名称已跳过` : '') +
|
||||
(imported?.notified ? `,已推送 ${imported.notified} 位部门经理核验` : ''),
|
||||
)
|
||||
importDemandsVisible.value = false
|
||||
// 导入年份与当前查看年份不同(模板为下一年度)时切到导入年份展示
|
||||
if (titleYear !== selectedYear.value) selectedYear.value = titleYear
|
||||
loadAll()
|
||||
} catch {
|
||||
MessagePlugin.error('导入失败,请稍后重试')
|
||||
@@ -681,6 +838,11 @@ const onImportDemandExcel = async (e: Event) => {
|
||||
}
|
||||
|
||||
const onConfirmDemand = async (row: TrainingDemand) => {
|
||||
// 000154:仅需求归属部门的经理可确认,其余人员点击统一提示
|
||||
if (!canConfirmDemand(row)) {
|
||||
MessagePlugin.warning('暂无权限,请联系部门经理~')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await confirmDemand(row.id)
|
||||
MessagePlugin.success('已确认,草稿课程已自动生成到培训课程')
|
||||
@@ -702,11 +864,13 @@ const collectForm = ref({ userIds: [] as string[], content: '' })
|
||||
const memberLabel = (m: TrainingMember) =>
|
||||
[m.user_name || m.employee_no, m.post, m.dept_name].filter(Boolean).join(' · ') || m.id.slice(0, 8)
|
||||
|
||||
// 默认推送人员:人事与各课长(supervisor;存量文员经别名按课长对待)
|
||||
const DEFAULT_COLLECT_ROLES = ['hr', 'supervisor']
|
||||
// 默认推送人员:各课长(supervisor;存量文员 clerk 经别名按课长对待)
|
||||
const DEFAULT_COLLECT_ROLES = ['supervisor']
|
||||
const defaultCollectUserIds = () =>
|
||||
members.value
|
||||
.filter((m) => (m.roles || []).some((r) => DEFAULT_COLLECT_ROLES.includes(r)))
|
||||
.filter((m) =>
|
||||
(m.roles || []).some((r) => DEFAULT_COLLECT_ROLES.includes(r === 'clerk' ? 'supervisor' : r)),
|
||||
)
|
||||
.map((m) => m.user_id)
|
||||
|
||||
const openCollect = async () => {
|
||||
@@ -754,7 +918,8 @@ const onSendCollect = async () => {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadAll()
|
||||
// 首次进入:年份默认选中需求库最新一年并展示该年数据
|
||||
loadAll(true)
|
||||
loadFormOptions()
|
||||
})
|
||||
</script>
|
||||
@@ -770,6 +935,12 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// 已确认行不做整行置灰:t-table 行选择列 disabled 命中时会加 __row--disabled
|
||||
// 类(整行 text-color-disabled),业务上已确认行仅禁止勾选,文字保持正常色
|
||||
:deep(.t-table__row--disabled) {
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
// 标题行内嵌年度切换下拉
|
||||
.plan-title-row {
|
||||
display: inline-flex;
|
||||
@@ -842,7 +1013,7 @@ onMounted(() => {
|
||||
font-size: var(--app-text-md);
|
||||
}
|
||||
|
||||
// 参加人员/备注等长文本单元格:单行省略,t-tooltip 悬停显示全部
|
||||
// 适合人员/备注等长文本单元格:单行省略,t-tooltip 悬停显示全部
|
||||
.cell-ellipsis {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<template>
|
||||
<div class="rule-panel">
|
||||
<!-- 卡片1:职称角色 · 角色与权限(点选式维护,自定义角色勾选权限分配即生效) -->
|
||||
<!-- [2026-11 需求] 配置中心 tab 化:角色权限/业务规则(含业务参数与课程分类)/推送管理(推送提醒配置+推送记录)/导入模板 -->
|
||||
<t-tabs v-model="activeTab" class="rule-tabs">
|
||||
<t-tab-panel value="roles" label="角色权限">
|
||||
<!-- 角色权限 · 角色与权限(点选式维护,自定义角色勾选权限分配即生效) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">职称角色 · 角色与权限</span>
|
||||
<span class="panel-box__title">角色权限 · 角色与权限</span>
|
||||
<t-button variant="outline" size="small" @click="openRoleDialog()">新增角色</t-button>
|
||||
</div>
|
||||
<t-table :data="roleRows" :columns="roleColumns" row-key="key" size="small" :loading="roleLoading">
|
||||
@@ -40,15 +43,18 @@
|
||||
系统角色不可删除,展示名与权限分配可改;「权限分配」= 继承所选权限组的全部接口与页面权限,勾选多个取并集。学员为全员默认角色,无需配置。
|
||||
</div>
|
||||
</div>
|
||||
</t-tab-panel>
|
||||
|
||||
<!-- 卡片2:业务规则(全部点选式表单,不再手写 JSON) -->
|
||||
<!-- 业务规则:签到/评分/积分/达标线/滚动等业务规则与业务参数 + 课程分类字典 + 高级配置兜底 -->
|
||||
<t-tab-panel value="rules" label="业务规则">
|
||||
<!-- 业务规则(全部点选式表单,不再手写 JSON) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">业务规则</span>
|
||||
<t-button variant="outline" size="small" :loading="seeding" @click="onSeed">初始化默认配置</t-button>
|
||||
</div>
|
||||
<div class="panel-box__sub">点选即可修改,每项保存后立即生效;未保存的修改不生效。</div>
|
||||
<div v-for="schema in RULE_SCHEMAS" :key="schema.key" class="rule-section">
|
||||
<div v-for="schema in ruleSchemas" :key="schema.key" class="rule-section">
|
||||
<div class="rule-section__head">
|
||||
<span class="rule-section__title">{{ schema.title }}</span>
|
||||
<span class="rule-section__desc">{{ schema.desc }}</span>
|
||||
@@ -99,6 +105,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 课程分类:rule-configs course_category_dict,课程管理筛选/表单下拉选项来源 -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">课程分类</span>
|
||||
<t-button variant="outline" size="small" :disabled="!categoriesDirty" :loading="categoriesSaving" @click="onSaveCategories">保存</t-button>
|
||||
</div>
|
||||
<div class="panel-box__sub">课程管理列表「按分类查询」与「新增课程」弹窗的分类下拉选项;预设之外可在课程表单直接输入自定义分类。</div>
|
||||
<div class="category-editor">
|
||||
<t-tag
|
||||
v-for="c in categoryDraft"
|
||||
:key="c"
|
||||
theme="primary"
|
||||
variant="light"
|
||||
closable
|
||||
@close="onRemoveCategory(c)"
|
||||
>{{ c }}</t-tag>
|
||||
<t-input
|
||||
v-model="categoryInput"
|
||||
class="category-input"
|
||||
size="small"
|
||||
clearable
|
||||
placeholder="输入新分类后回车或点添加"
|
||||
@enter="onAddCategory"
|
||||
/>
|
||||
<t-button variant="outline" size="small" :disabled="!categoryInput.trim()" @click="onAddCategory">添加</t-button>
|
||||
<t-button variant="text" theme="primary" size="small" class="category-reset" @click="onResetCategories">恢复默认</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 高级配置:未提供点选表单的规则键,保留 JSON 编辑兜底 -->
|
||||
<div v-if="advancedRows.length" class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
@@ -115,8 +150,64 @@
|
||||
</template>
|
||||
</t-table>
|
||||
</div>
|
||||
</t-tab-panel>
|
||||
|
||||
<!-- 卡片3:推送记录(逐人企微/站内投递明细;手动触发周一讲师提醒) -->
|
||||
<!-- 推送管理:推送提醒参数配置 + 推送投递记录 -->
|
||||
<t-tab-panel value="notify" label="推送管理">
|
||||
<!-- 推送提醒配置(与业务规则同款点选式表单) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">推送提醒配置</span>
|
||||
</div>
|
||||
<div class="panel-box__sub">点选即可修改,每项保存后立即生效;未保存的修改不生效。</div>
|
||||
<div v-for="schema in notifySchemas" :key="schema.key" class="rule-section">
|
||||
<div class="rule-section__head">
|
||||
<span class="rule-section__title">{{ schema.title }}</span>
|
||||
<span class="rule-section__desc">{{ schema.desc }}</span>
|
||||
<t-button
|
||||
variant="outline"
|
||||
size="small"
|
||||
:disabled="!isDirty(schema.key)"
|
||||
:loading="savingKey === schema.key"
|
||||
@click="onSaveRule(schema.key)"
|
||||
>保存</t-button>
|
||||
</div>
|
||||
<div class="rule-section__fields">
|
||||
<div
|
||||
v-for="field in schema.fields"
|
||||
:key="field.key"
|
||||
class="rule-field"
|
||||
:class="{ 'rule-field--block': field.type === 'text' }"
|
||||
>
|
||||
<span class="rule-field__label">{{ field.label }}</span>
|
||||
<t-input-number
|
||||
v-if="field.type === 'number'"
|
||||
v-model="ruleValues[schema.key][field.key]"
|
||||
:min="field.min"
|
||||
:max="field.max"
|
||||
theme="normal"
|
||||
size="small"
|
||||
class="rule-field__input"
|
||||
/>
|
||||
<t-switch
|
||||
v-else-if="field.type === 'switch'"
|
||||
v-model="ruleValues[schema.key][field.key]"
|
||||
/>
|
||||
<t-textarea
|
||||
v-else
|
||||
v-model="ruleValues[schema.key][field.key]"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }"
|
||||
:placeholder="field.placeholder"
|
||||
class="rule-field__textarea"
|
||||
/>
|
||||
<span v-if="field.unit" class="rule-field__unit">{{ field.unit }}</span>
|
||||
<span v-if="field.vars" class="rule-field__vars">可用变量:{{ field.vars }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 推送记录(逐人企微/站内投递明细;手动触发周一讲师提醒) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">推送记录</span>
|
||||
@@ -151,12 +242,15 @@
|
||||
展示最近 {{ pushLogs.length }} 条;pending/sending=排队与投递中,sent=企微已送达,skipped=收件人未绑定企微等跳过,dead=重试耗尽,空=仅站内通知。
|
||||
</div>
|
||||
</div>
|
||||
</t-tab-panel>
|
||||
|
||||
<!-- 卡片4:导入模板管理(上传自定义 Excel 模板替换内置默认) -->
|
||||
<!-- 导入模板:上传自定义 Excel 模板替换内置默认 -->
|
||||
<t-tab-panel value="templates" label="导入模板">
|
||||
<!-- 导入模板管理(上传自定义 Excel 模板替换内置默认) -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">导入模板</span>
|
||||
<span class="panel-box__sub">上传后,培训计划批量导入与题库 Excel 导入的下载入口即刻使用新模板</span>
|
||||
<span class="panel-box__sub">上传后,培训计划批量导入、题库 Excel 导入与课程管理批量导入的下载入口即刻使用新模板</span>
|
||||
</div>
|
||||
<t-table :data="templates" :columns="templateColumns" row-key="template_key" size="small" :loading="templateLoading">
|
||||
<template #file_name="{ row }">
|
||||
@@ -189,11 +283,13 @@
|
||||
@change="onUploadFile"
|
||||
/>
|
||||
</div>
|
||||
</t-tab-panel>
|
||||
</t-tabs>
|
||||
|
||||
<!-- 角色编辑弹窗 -->
|
||||
<t-dialog
|
||||
v-model:visible="roleDialogVisible"
|
||||
:header="roleForm.mode === 'add' ? '新增职称角色' : `编辑职称角色 · ${roleForm.label || roleForm.key}`"
|
||||
:header="roleForm.mode === 'add' ? '新增角色' : `编辑角色 · ${roleForm.label || roleForm.key}`"
|
||||
width="480"
|
||||
>
|
||||
<t-form label-width="88px">
|
||||
@@ -244,6 +340,8 @@
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import {
|
||||
COURSE_CATEGORY_DICT_RULE_KEY,
|
||||
DEFAULT_COURSE_CATEGORIES,
|
||||
ROLE_DICT_RULE_KEY,
|
||||
deleteTrainingTemplate,
|
||||
fetchRoleDict,
|
||||
@@ -265,6 +363,9 @@ import {
|
||||
import { fmtBeijingTime } from '@/utils/datetime'
|
||||
import { downloadTrainingTemplate } from '../trainingTemplates'
|
||||
|
||||
// [2026-11 需求] 配置中心 tab 切换(角色权限/业务规则/推送管理/导入模板)
|
||||
const activeTab = ref('roles')
|
||||
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const editVisible = ref(false)
|
||||
@@ -393,6 +494,8 @@ interface RuleSchemaDesc {
|
||||
title: string
|
||||
desc: string
|
||||
fields: RuleFieldDesc[]
|
||||
// group:notify = 推送提醒类配置,配置中心归入「推送管理」tab;缺省归「业务规则」tab。
|
||||
group?: 'notify'
|
||||
// serialize UI 表单值 → tr_rule_configs 落库值(默认原样 JSON);
|
||||
// notify_remind_days(数组)/notify_push_enabled(bool) 等非对象契约用。
|
||||
serialize?: (v: Record<string, any>) => any
|
||||
@@ -439,6 +542,7 @@ const RULE_SCHEMAS: RuleSchemaDesc[] = [
|
||||
// (training_scheduler.go loadNotifyConfig);原 remind_policy(t3/t1/third_week/
|
||||
// month_end)从未被后端读取,由本卡替换(third_week/month_end 无实现,随卡移除)。
|
||||
key: 'notify_remind_days',
|
||||
group: 'notify',
|
||||
title: '开课提醒时点',
|
||||
desc: '调度器按提前天数生成讲师授课提醒;学员开课通知由场次"通知方式"决定(立即或前一天),不受本项影响',
|
||||
fields: [
|
||||
@@ -457,6 +561,7 @@ const RULE_SCHEMAS: RuleSchemaDesc[] = [
|
||||
},
|
||||
{
|
||||
key: 'notify_push_enabled',
|
||||
group: 'notify',
|
||||
title: '企微推送总开关',
|
||||
desc: '关闭后新产生的通知只保留站内流水,不再推送企业微信;已入队消息不受影响',
|
||||
fields: [{ key: 'enabled', label: '启用企微推送', type: 'switch' }],
|
||||
@@ -466,6 +571,7 @@ const RULE_SCHEMAS: RuleSchemaDesc[] = [
|
||||
},
|
||||
{
|
||||
key: 'notify_weekly_lecturer',
|
||||
group: 'notify',
|
||||
title: '周一讲师未完成提醒',
|
||||
desc: '每周一上午向当月仍有未结束场次的讲师推送汇总提醒(标题带第 N 周);讲师场次全部结束即自动停推',
|
||||
fields: [
|
||||
@@ -482,6 +588,7 @@ const RULE_SCHEMAS: RuleSchemaDesc[] = [
|
||||
// [2026-11 需求] 提醒推送文案可编辑:各提醒场景的标题/内容模板,保存后新推送即刻生效;
|
||||
// {占位符} 渲染时替换为实际值,清空保存即恢复内置默认文案(后端空值回落默认)。
|
||||
key: 'notify_text_templates',
|
||||
group: 'notify',
|
||||
title: '提醒推送文案',
|
||||
desc: '各提醒推送的标题与内容模板,支持 {占位符} 替换实际值;清空并保存即恢复内置默认文案,对保存后的新推送生效',
|
||||
fields: [
|
||||
@@ -565,6 +672,58 @@ const DEFAULT_RULE_VALUES: Record<string, Record<string, any>> = {
|
||||
|
||||
const RULE_SCHEMA_KEYS = new Set(RULE_SCHEMAS.map((s) => s.key))
|
||||
|
||||
// tab 分组:业务规则(签到/评分/积分/达标线/滚动)与推送提醒(notify_*)各自成 tab
|
||||
const ruleSchemas = RULE_SCHEMAS.filter((s) => s.group !== 'notify')
|
||||
const notifySchemas = RULE_SCHEMAS.filter((s) => s.group === 'notify')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 课程分类(course_category_dict):课程管理筛选/表单下拉选项字典,
|
||||
// tag 列表增删 + 保存;保存后课程管理页下次拉取即生效。
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const categoryDraft = ref<string[]>([])
|
||||
const categorySnapshot = ref('[]')
|
||||
const categoryInput = ref('')
|
||||
const categoriesSaving = ref(false)
|
||||
const categoriesDirty = computed(() => JSON.stringify(categoryDraft.value) !== categorySnapshot.value)
|
||||
|
||||
const onAddCategory = () => {
|
||||
const name = categoryInput.value.trim()
|
||||
if (!name) return
|
||||
if (categoryDraft.value.some((c) => c === name)) {
|
||||
MessagePlugin.warning(`分类「${name}」已存在`)
|
||||
return
|
||||
}
|
||||
categoryDraft.value = [...categoryDraft.value, name]
|
||||
categoryInput.value = ''
|
||||
}
|
||||
|
||||
const onRemoveCategory = (name: string) => {
|
||||
categoryDraft.value = categoryDraft.value.filter((c) => c !== name)
|
||||
}
|
||||
|
||||
// 恢复默认分类(仅改草稿,点「保存」后落库生效)
|
||||
const onResetCategories = () => {
|
||||
categoryDraft.value = [...DEFAULT_COURSE_CATEGORIES]
|
||||
}
|
||||
|
||||
const onSaveCategories = async () => {
|
||||
if (!categoryDraft.value.length) {
|
||||
MessagePlugin.warning('至少保留一个分类')
|
||||
return
|
||||
}
|
||||
categoriesSaving.value = true
|
||||
try {
|
||||
await saveRuleConfig(COURSE_CATEGORY_DICT_RULE_KEY, { categories: categoryDraft.value })
|
||||
categorySnapshot.value = JSON.stringify(categoryDraft.value)
|
||||
MessagePlugin.success('课程分类已保存并生效')
|
||||
} catch (err: any) {
|
||||
MessagePlugin.error(err?.response?.data?.message || '保存失败')
|
||||
} finally {
|
||||
categoriesSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const ruleValues = ref<Record<string, Record<string, any>>>({})
|
||||
const savedSnapshot = ref<Record<string, string>>({})
|
||||
const savingKey = ref('')
|
||||
@@ -594,8 +753,15 @@ const applyConfigs = (configs: TrainingRuleConfig[]) => {
|
||||
ruleValues.value = values
|
||||
savedSnapshot.value = snapshot
|
||||
advancedRows.value = configs.filter(
|
||||
(c) => !RULE_SCHEMA_KEYS.has(c.rule_key) && c.rule_key !== ROLE_DICT_RULE_KEY,
|
||||
(c) => !RULE_SCHEMA_KEYS.has(c.rule_key) && c.rule_key !== ROLE_DICT_RULE_KEY && c.rule_key !== COURSE_CATEGORY_DICT_RULE_KEY,
|
||||
)
|
||||
// 课程分类字典:有专属卡片,缺省回退默认分类(与 fetchCourseCategories 同口径)
|
||||
const categoryRaw = configs.find((c) => c.rule_key === COURSE_CATEGORY_DICT_RULE_KEY)?.rule_value?.categories
|
||||
const categories = Array.isArray(categoryRaw)
|
||||
? categoryRaw.filter((c): c is string => typeof c === 'string' && !!c.trim())
|
||||
: [...DEFAULT_COURSE_CATEGORIES]
|
||||
categoryDraft.value = categories
|
||||
categorySnapshot.value = JSON.stringify(categories)
|
||||
}
|
||||
|
||||
const loadAll = async () => {
|
||||
@@ -853,6 +1019,29 @@ watch(pushScene, () => loadPushLogs())
|
||||
display: none;
|
||||
}
|
||||
|
||||
// ---- tab 化布局:tab 内容区与 panel-box 间距 ----
|
||||
.rule-tabs {
|
||||
:deep(.t-tab-panel) {
|
||||
padding: 12px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 课程分类(tag 列表增删编辑) ----
|
||||
.category-editor {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.category-input {
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
.category-reset {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.form-hint {
|
||||
margin-top: 8px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
* 模板按业务键管理:配置中心上传的自定义版本存后端 tr_templates 并全端生效,
|
||||
* 未上传时由后端回退内置默认(docs/moban 随二进制分发)。
|
||||
* - demand_collection 教育训练需求表模板.xlsx(2026-11 起的系统内置默认,
|
||||
* 含「计划培训时间」列):培训计划「年度需求收集 → 批量导入」使用;
|
||||
* 列:编号/部门/课程名称/参加人员/地点/培訓費用/內外培訓/计划培训时间/讲师/备注;
|
||||
* 后端下载时按新布局注入组织架构下拉(部门 B/参加人员 D/讲师 I)。
|
||||
* 含「计划培训月份」列):培训计划「年度需求收集 → 批量导入」使用;
|
||||
* 列:编号/部门/课程名称/参加人员/地点/培訓費用/內外培訓/计划培训月份/讲师/备注;
|
||||
* 后端下载时动态注入:标题年份=下一年度、课程名称下拉(课程管理 C)、
|
||||
* 计划培训月份下拉(1~12 H)、部门/讲师下拉(部门 B/讲师 I)。
|
||||
* - question_bank 部门培训课程试题(题库导入版)模板.xlsx:
|
||||
* 「题库与考试 → Excel 批量导入」与「培训课程 → 创建课程 → 关联题库」指引使用;
|
||||
* 工作表:单选题/多选题/判断题,列:题目/课程名称/难度/正确答案/答案A..答案L。
|
||||
* - course_library 课程管理导入模板.xlsx:「课程管理 → 批量导入」使用;
|
||||
* 列:课程名称/说明/分类/类型/线上,线下/讲师/时长(学时)/课件。
|
||||
*/
|
||||
import { downloadTrainingTemplateFile, type TrainingTemplateKey } from '@/api/training'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
@@ -17,16 +20,19 @@ export type { TrainingTemplateKey }
|
||||
|
||||
export const DEMAND_TEMPLATE_KEY: TrainingTemplateKey = 'demand_collection'
|
||||
export const QUESTION_TEMPLATE_KEY: TrainingTemplateKey = 'question_bank'
|
||||
export const COURSE_LIBRARY_TEMPLATE_KEY: TrainingTemplateKey = 'course_library'
|
||||
|
||||
export const TRAINING_TEMPLATE_LABELS: Record<TrainingTemplateKey, string> = {
|
||||
demand_collection: '教育训练需求表模板',
|
||||
question_bank: '部门培训课程试题(题库导入版)模板',
|
||||
course_library: '课程管理导入模板',
|
||||
}
|
||||
|
||||
// 兜底保存扩展名与内置默认文件一致(后端返回的 fileName 缺失时用)。
|
||||
const TRAINING_TEMPLATE_EXT: Record<TrainingTemplateKey, string> = {
|
||||
demand_collection: '.xlsx',
|
||||
question_bank: '.xlsx',
|
||||
course_library: '.xlsx',
|
||||
}
|
||||
|
||||
// 触发浏览器保存 Blob(带登录态经接口下载;fileName 可传列表接口返回的实际文件名)
|
||||
|
||||
Reference in new issue
Block a user