fix(培训优化):1.签到码文案改「二维码有效期至 HH:mm」、代扫码按钮改「补录」;2.课程管理「适合人员」升级「课程权限」(默认所属部门,部门+人员混合选择互斥,按权限过滤目录/选课/学员视图);3.筛选增加按状态查询,核验改审核;4.审核通过即自动发布(去发布按钮),审核时课程权限必填;5.下线课程全面拦截(和信课程撤回/计划不可选/学习提示已下线,存量计划保留);6.课件管理支持多课件追加不替换(迁移000163/000164);7.AI对话问候语改「小和」;8.登录页品牌标识提升对比度
deploy-hxtesting / build-and-deploy (push) Successful in 1m15s
deploy-hxtesting / build-and-deploy (push) Successful in 1m15s
This commit is contained in:
1 parent
9e00af1905
commit
6defb1f2c6
22 files changed
+1169
-307
No files matched your search
@@ -326,6 +326,10 @@ export interface TrainingCourse {
|
||||
remark?: string
|
||||
/** 课程管理条目 id(月培训计划「计划名称」从课程管理选择后关联;可空) */
|
||||
library_course_id?: string
|
||||
/** 关联课程管理条目的发布状态(000163 联查只读;offline 时学习入口拦截) */
|
||||
library_publish_status?: string
|
||||
/** 关联课程管理条目是否已下线(000163;学习页提示「该课程已下线」) */
|
||||
library_offline?: boolean
|
||||
/** 月度计划编号(MP-<YYYYMM>-####,按授课月份分段,创建时由服务端生成) */
|
||||
plan_code?: string
|
||||
/** 来源需求 id(经理确认自动转月度计划时回填,溯源用) */
|
||||
@@ -425,6 +429,22 @@ export const deleteCourse = (id: string) =>
|
||||
// ---- 课程管理(课程资产主数据;月培训计划「计划名称」数据源) ----
|
||||
|
||||
/** TrainingLibraryCourse 课程管理条目(000151 tr_course_library)。 */
|
||||
/** 课程管理课件条目(000164 多课件):一次上传/知识库挂接追加一条,不再整体替换。 */
|
||||
export interface TrainingLibraryMaterial {
|
||||
/** 课件条目标识(移除/预览/下载定位用) */
|
||||
mid: string
|
||||
/** 课件名称(上传文件名/知识库文档名) */
|
||||
name: string
|
||||
/** 文件字节数(知识库挂接可能为 0) */
|
||||
size?: number
|
||||
file_key?: string
|
||||
knowledge_id?: string
|
||||
/** 来源:upload 本地上传 / kb 知识库挂接 */
|
||||
origin?: string
|
||||
/** 上传时间(ISO 字符串) */
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
export interface TrainingLibraryCourse {
|
||||
id: string
|
||||
/** 课程编号(CRS-####,创建/导入时由服务端生成,列表/详情展示) */
|
||||
@@ -437,8 +457,12 @@ export interface TrainingLibraryCourse {
|
||||
owner_dept_name?: string
|
||||
/** 说明 */
|
||||
description: string
|
||||
/** 适合人员(对应需求表「参加人员」,自由文本,如:财会人员) */
|
||||
/** 适合人员(对应需求表「参加人员」,自由文本;000163 起作课程权限展示文本) */
|
||||
suitable_members?: string
|
||||
/** 课程权限-可见部门 id 列表(000163,逗号分隔 org_depts.id) */
|
||||
perm_dept_ids?: string
|
||||
/** 课程权限-可见人员 id 列表(000163,逗号分隔 users.id) */
|
||||
perm_user_ids?: string
|
||||
/** 分类(配置中心 course_category_dict 可配,预设之外支持手动输入保存) */
|
||||
category: string
|
||||
/** 类型:required 必修课 / elective 选修课 */
|
||||
@@ -456,8 +480,10 @@ export interface TrainingLibraryCourse {
|
||||
/** 课件文件(可上传,经专端点下载) */
|
||||
file_name?: string
|
||||
file_size?: number
|
||||
/** 课件同步知识库「企业培训(课件)」后的文档 id(AI 出题依赖) */
|
||||
/** 课件同步知识库「企业培训(课件)」后的文档 id(AI 出题依赖;000164 起为最新课件条目镜像) */
|
||||
knowledge_id?: string
|
||||
/** 课件列表(000164 多课件,上传/知识库挂接追加不替换) */
|
||||
materials?: TrainingLibraryMaterial[]
|
||||
/** 发布状态(000154):draft 草稿/published 已发布/offline 已下线 */
|
||||
publish_status?: string
|
||||
/** 核验状态(000157):pending 待核验/confirmed 已确认;发布前必须已确认 */
|
||||
@@ -497,9 +523,13 @@ export const publishCourseLibraryItem = (id: string) =>
|
||||
export const offlineCourseLibraryItem = (id: string) =>
|
||||
post<{ success: boolean; data: TrainingLibraryCourse }>(`${base}/course-library/${enc(id)}/offline`)
|
||||
|
||||
/** 课程条目核验(000157,单个/批量共用):仅课长/经理限本部门;返回核验/跳过条数。 */
|
||||
/** 课程条目核验(000163:审核即发布,单个/批量共用):仅课长/经理限本部门;
|
||||
* 返回审核/跳过/自动发布条数与未传课件未发布课程名。 */
|
||||
export const verifyCourseLibraryItems = (ids: string[]) =>
|
||||
post<{ success: boolean; data: { verified: number; skipped: number } }>(`${base}/course-library/verify`, { ids })
|
||||
post<{ success: boolean; data: { verified: number; skipped: number; auto_published: number; unpublished?: string[] } }>(
|
||||
`${base}/course-library/verify`,
|
||||
{ ids },
|
||||
)
|
||||
|
||||
/** 批量导入(前端解析 Excel 后逐行提交,与需求导入同口径;返回导入条数)。 */
|
||||
export const importCourseLibrary = (items: Partial<TrainingLibraryCourse>[]) =>
|
||||
@@ -524,14 +554,15 @@ export const attachCourseLibraryMaterialFromKb = (id: string, payload: { knowled
|
||||
payload,
|
||||
)
|
||||
|
||||
/** 课件原始文件下载(在线预览/保存)。 */
|
||||
export const downloadCourseLibraryMaterial = (id: string) =>
|
||||
getDown(`${base}/course-library/${enc(id)}/material/file`)
|
||||
/** 课件原始文件下载(在线预览/保存;000164 多课件:mid 定位条目,缺省最新一条)。 */
|
||||
export const downloadCourseLibraryMaterial = (id: string, mid?: string) =>
|
||||
getDown(`${base}/course-library/${enc(id)}/material/file${mid ? `?mid=${encodeURIComponent(mid)}` : ''}`)
|
||||
|
||||
/** 移除课件原始文件/知识库挂接(名称登记保留;课件变更即回待核验)。 */
|
||||
export const removeCourseLibraryMaterial = (id: string) =>
|
||||
/** 移除课件条目(000164 多课件:mid 定位,缺省移除最新一条;课件变更即回待审核)。 */
|
||||
export const removeCourseLibraryMaterial = (id: string, mid?: string) =>
|
||||
post<{ success: boolean; data: TrainingLibraryCourse }>(
|
||||
`${base}/course-library/${enc(id)}/material/remove`,
|
||||
mid ? { mid } : {},
|
||||
)
|
||||
|
||||
export const listSessions = (query?: ListQuery) =>
|
||||
|
||||
@@ -5949,7 +5949,7 @@ export default {
|
||||
}
|
||||
},
|
||||
createChat: {
|
||||
title: 'Hi,我是 Academy,让你的知识触手可及',
|
||||
title: 'Hi,我是小和,让你的知识触手可及',
|
||||
newSessionTitle: '新会话',
|
||||
openProject: '选择项目',
|
||||
clearProject: '取消绑定',
|
||||
|
||||
@@ -163,11 +163,13 @@ export const TRAINING_MOCK = {
|
||||
},
|
||||
}
|
||||
|
||||
// 课程管理(课程资产主数据):预览 harness 演示数据(编号 CRS-#### 与后端一致)
|
||||
// 课程管理(课程资产主数据):预览 harness 演示数据(编号 CRS-#### 与后端一致);
|
||||
// 000163 课程权限:perm_dept_ids/perm_user_ids 为空时沿用 suitable_members 口径;
|
||||
// 000164 多课件:materials 逐条追加
|
||||
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: '入职通识手册.pptx', file_size: 839680, knowledge_id: 'kb-lib1', question_bank_count: 1, verify_status: 'confirmed', publish_status: 'draft', 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: '安全操作规程.docx', file_size: 512000, question_bank_count: 1, verify_status: 'confirmed', publish_status: 'draft', 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, question_bank_count: 0, verify_status: 'confirmed', publish_status: 'draft', lecturer_name: '', created_at: month(-1, 12), updated_at: month(-1, 12) },
|
||||
{ id: 'lib-1', code: 'CRS-0001', name: '新员工入职通识培训', owner_dept_id: 'dept-b', owner_dept_name: '技术部', description: '公司制度、企业文化与办公系统入门', suitable_members: '全部', perm_dept_ids: '', perm_user_ids: '', materials: [{ mid: 'm-11', name: '入职通识手册.pptx', size: 839680, file_key: 'fk-11', knowledge_id: 'kb-lib1', origin: 'upload', created_at: '' }, { mid: 'm-12', name: '员工手册速查.pdf', size: 402112, file_key: 'fk-12', knowledge_id: '', origin: 'upload', created_at: '' }], category: '企业文化与制度类', type: 'required', mode: 'online', lecturer_id: 'u-m1', hours: 2, material_name: '入职通识手册.pptx', file_name: '员工手册速查.pdf', file_size: 402112, knowledge_id: 'kb-lib1', question_bank_count: 1, verify_status: 'confirmed', publish_status: 'published', 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: '冲压车间', perm_dept_ids: 'dept-a', perm_user_ids: '', materials: [{ mid: 'm-21', name: '安全操作规程.docx', size: 512000, file_key: 'fk-21', knowledge_id: '', origin: 'upload', created_at: '' }], category: '安全与健康类', type: 'required', mode: 'offline', lecturer_id: 'u-m2', hours: 4, material_name: '安全操作规程.docx、实操考核表.xlsx', file_name: '安全操作规程.docx', file_size: 512000, question_bank_count: 1, verify_status: 'pending', publish_status: 'draft', 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: '品质岗', perm_dept_ids: '', perm_user_ids: '', materials: [], category: '专业技能类', type: 'elective', mode: 'online', lecturer_id: '', lecturer_external: '王顾问', hours: 3, material_name: '', file_name: '', file_size: 0, question_bank_count: 0, verify_status: 'pending', publish_status: 'draft', lecturer_name: '', created_at: month(-1, 12), updated_at: month(-1, 12) },
|
||||
]
|
||||
|
||||
// 课程管理 · 试题管理(000153):题库与题目演示数据(编号 QB-####)
|
||||
@@ -314,12 +316,17 @@ export function resolveTrainingMock(method: string, url: string): { status: numb
|
||||
return ok({ id: `q-new-${Date.now()}`, seq_no: 0 })
|
||||
}
|
||||
// 课件管理抽屉:上传/知识库挂接/移除回显对应课程条目并模拟文件字段变更
|
||||
// (000164 多课件:上传/挂接追加条目,移除按 mid 或最新一条)
|
||||
if (url.includes('/course-library/') && url.includes('/material/remove')) {
|
||||
const course = COURSE_LIBRARY_MOCK.find((c) => url.includes(`/course-library/${c.id}/`))
|
||||
if (course) {
|
||||
course.file_name = ''
|
||||
course.file_size = 0
|
||||
course.knowledge_id = ''
|
||||
const list = course.materials || []
|
||||
list.pop()
|
||||
course.materials = list
|
||||
const latest = list[list.length - 1]
|
||||
course.file_name = latest?.name || ''
|
||||
course.file_size = latest?.size || 0
|
||||
course.knowledge_id = latest?.knowledge_id || ''
|
||||
course.verify_status = 'pending'
|
||||
}
|
||||
return ok(course || { id: `c-new-${Date.now()}` })
|
||||
@@ -327,8 +334,10 @@ export function resolveTrainingMock(method: string, url: string): { status: numb
|
||||
if (url.includes('/course-library/') && url.includes('/material')) {
|
||||
const course = COURSE_LIBRARY_MOCK.find((c) => url.includes(`/course-library/${c.id}/`))
|
||||
if (course) {
|
||||
course.file_name = '预览课件.pdf'
|
||||
course.file_size = 1024 * 820
|
||||
const entry = { mid: `m-${Date.now()}`, name: '预览课件.pdf', size: 1024 * 820, file_key: 'fk-new', knowledge_id: '', origin: 'upload', created_at: new Date().toISOString() }
|
||||
course.materials = [...(course.materials || []), entry]
|
||||
course.file_name = entry.name
|
||||
course.file_size = entry.size
|
||||
course.verify_status = 'pending'
|
||||
}
|
||||
return ok(course || { id: `c-new-${Date.now()}` })
|
||||
@@ -336,5 +345,35 @@ export function resolveTrainingMock(method: string, url: string): { status: numb
|
||||
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 })
|
||||
}
|
||||
// 审核(000163:审核即发布):pending → confirmed + published(有课件时)
|
||||
// (预览 harness 不解析请求体,对全部 pending 条目生效)
|
||||
if (url.includes('/course-library/verify')) {
|
||||
let verified = 0
|
||||
let autoPublished = 0
|
||||
const unpublished: string[] = []
|
||||
for (const course of COURSE_LIBRARY_MOCK) {
|
||||
if (course.verify_status !== 'pending') continue
|
||||
course.verify_status = 'confirmed'
|
||||
verified += 1
|
||||
if (course.file_name || course.knowledge_id) {
|
||||
course.publish_status = 'published'
|
||||
autoPublished += 1
|
||||
} else {
|
||||
unpublished.push(course.name)
|
||||
}
|
||||
}
|
||||
return ok({ verified, skipped: 0, auto_published: autoPublished, unpublished })
|
||||
}
|
||||
// 下线(000163:下线后从和信课程撤回,计划存量行保留)
|
||||
if (url.includes('/course-library/') && url.includes('/offline')) {
|
||||
const course = COURSE_LIBRARY_MOCK.find((c) => url.includes(`/course-library/${c.id}/offline`))
|
||||
if (course) course.publish_status = 'offline'
|
||||
return ok(course || { id: `c-new-${Date.now()}` })
|
||||
}
|
||||
if (url.includes('/course-library/') && url.includes('/publish')) {
|
||||
const course = COURSE_LIBRARY_MOCK.find((c) => url.includes(`/course-library/${c.id}/publish`))
|
||||
if (course) course.publish_status = 'published'
|
||||
return ok(course || { id: `c-new-${Date.now()}` })
|
||||
}
|
||||
return ok({ id: `c-new-${Date.now()}` })
|
||||
}
|
||||
@@ -1246,6 +1246,24 @@ onMounted(async () => {
|
||||
width: 120px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
// 品牌标识增强(测试反馈 2026-11-26):登录页为深绿渐变背景,共用 Logo 的
|
||||
// 绿色渐变文字对比度不足 —— 此处覆写为白色高亮文字(保留流光动效)并放大字号,
|
||||
// 光点同步提亮;侧边栏(白底)不受影响,仍用共用样式。
|
||||
.aido-logo__text {
|
||||
font-size: 23px;
|
||||
letter-spacing: 2.5px;
|
||||
background-image:
|
||||
linear-gradient(110deg, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, 0.95) 50%, rgba(255, 255, 255, 0) 58%),
|
||||
linear-gradient(180deg, #ffffff 0%, #e8fff2 100%);
|
||||
-webkit-text-fill-color: transparent;
|
||||
filter: drop-shadow(0 1px 8px rgba(0, 64, 32, 0.6));
|
||||
}
|
||||
|
||||
.aido-logo__dot {
|
||||
background: radial-gradient(circle at 35% 35%, #ffffff, #7df7c3 60%);
|
||||
box-shadow: 0 0 7px 2px rgba(255, 255, 255, 0.65);
|
||||
}
|
||||
}
|
||||
|
||||
.header-links {
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
</t-tag>
|
||||
<h2 class="detail-name">{{ course?.name || '课程详情' }}</h2>
|
||||
<t-tag v-if="course" theme="default" variant="outline" size="small">{{ typeText }}</t-tag>
|
||||
<!-- 课程下线(000163):关联课程管理条目已下线时标注并拦截学习入口 -->
|
||||
<t-tag v-if="libraryOffline" theme="danger" variant="light" size="small">课程已下线</t-tag>
|
||||
<!-- 培训签到:跳「培训签到」页并自动定位本课程场次(SignPanel 读取 courseId 查询参数) -->
|
||||
<t-button v-if="course" variant="outline" theme="primary" size="small" class="detail-signin" @click="goSignin">
|
||||
培训签到
|
||||
@@ -53,8 +55,14 @@
|
||||
<!-- 预览区 -->
|
||||
<main class="preview-pane">
|
||||
<t-loading :loading="previewLoading" class="preview-pane__inner" :fullscreen="false">
|
||||
<!-- 课程已下线(000163):不能再打开学习,统一提示 -->
|
||||
<t-empty
|
||||
v-if="libraryOffline"
|
||||
class="preview-empty"
|
||||
description="该课程已下线,不能再继续学习;如有疑问请联系培训管理员"
|
||||
/>
|
||||
<DocumentPreview
|
||||
v-if="current && docBlob"
|
||||
v-else-if="current && docBlob"
|
||||
:source-blob="docBlob"
|
||||
:file-type="previewKind(current)"
|
||||
:file-name="current.name"
|
||||
@@ -71,8 +79,8 @@
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- 随堂考试(开启随堂考试或绑定题库即可考) -->
|
||||
<div v-if="course?.exam_enabled || course?.exam_ready" class="panel-box exam-box">
|
||||
<!-- 随堂考试(开启随堂考试或绑定题库即可考;课程已下线时不提供) -->
|
||||
<div v-if="!libraryOffline && (course?.exam_enabled || course?.exam_ready)" class="panel-box exam-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">随堂考试</span>
|
||||
<div class="panel-box__actions">
|
||||
@@ -182,6 +190,10 @@ const wrongCount = ref(0)
|
||||
|
||||
const typeText = computed(() => (course.value?.type === 'elective' ? '选修' : '必修'))
|
||||
|
||||
// 课程已下线(000163):关联课程管理条目 publish_status=offline 时拦截学习
|
||||
// (课件预览/进度上报/随堂考试统一提示「该课程已下线」;已有培训计划保留展示)
|
||||
const libraryOffline = computed(() => Boolean(course.value?.library_offline))
|
||||
|
||||
const taskState = computed(() => {
|
||||
const map: Record<string, string> = { done: '已完成', doing: '学习中', overdue: '已逾期', pending: '待学习' }
|
||||
return myTask.value ? map[myTask.value.status] || '' : ''
|
||||
@@ -225,6 +237,10 @@ const stopHeartbeat = () => {
|
||||
// 跨空间学员(培训数据在档案空间)会被 403「Permission denied」拦截;培训域
|
||||
// 文件流按解析后的培训租户服务端取文件,与下载/和信课程抽屉同口径。
|
||||
const openMaterial = async (m: TrainingMaterial) => {
|
||||
if (libraryOffline.value) {
|
||||
MessagePlugin.warning('该课程已下线,不能再继续学习')
|
||||
return
|
||||
}
|
||||
if (current.value?.id === m.id) return
|
||||
stopHeartbeat()
|
||||
current.value = m
|
||||
@@ -306,6 +322,10 @@ const bindVideoHeartbeat = () => {
|
||||
// ---- 随堂考试 ----
|
||||
|
||||
const startExam = async () => {
|
||||
if (libraryOffline.value) {
|
||||
MessagePlugin.warning('该课程已下线,不能再参加考试')
|
||||
return
|
||||
}
|
||||
examLoading.value = true
|
||||
try {
|
||||
const data = unwrap<{ paper: TrainingPaper; questions: TrainingQuestion[] }>(await getCourseExamPaper(courseId))
|
||||
@@ -377,6 +397,8 @@ const loadAll = async () => {
|
||||
const exam = r && unwrap<{ record: TrainingExamRecord | null; passed: boolean }>(r)
|
||||
examRecord.value = exam?.record || null
|
||||
examPassed.value = !!exam?.passed
|
||||
// 课程已下线(000163):不自动打开课件,页面统一展示「该课程已下线」
|
||||
if (libraryOffline.value) return
|
||||
// [2026-11 需求] 进入有课件的课程默认打开第一个课件,免手动从左侧选择
|
||||
if (materials.value.length) void openMaterial(materials.value[0])
|
||||
} finally {
|
||||
|
||||
@@ -269,19 +269,28 @@ const keyword = ref('')
|
||||
// 目录页面向全体员工:仅展示已发布课程(草稿/待审在「培训课程」维护)
|
||||
const publishedCourses = computed(() => courses.value.filter((c) => c.status === 'published'))
|
||||
|
||||
// 「和信课程」(000160):已发布 + 适合人员覆盖查看人 —— 「全部」全员可见;
|
||||
// 000159 多部门口径:值按「、」拆分(逗号/分号兼容归一)后与查看人部门名做
|
||||
// 成员匹配;未设置适合人员的存量课程沿用原部门范围口径(所属部门为空 = 全员,
|
||||
// 否则须与我的部门一致)。后端 scope=catalog 已按同口径过滤,此处保留客户端兜底。
|
||||
// 「和信课程」(000160):已发布 + 课程权限覆盖查看人。000163 权限口径:
|
||||
// perm_dept_ids 含我的部门 id 或 perm_user_ids 含我的用户 id 即可见;perm 两列
|
||||
// 为空的存量课程沿用适合人员老口径 —— 「全部」全员可见,000159 多部门口径按
|
||||
// 「、」拆分(逗号/分号兼容归一)后与我的部门名成员匹配;未设置适合人员的
|
||||
// 存量课程沿用原部门范围口径(所属部门为空 = 全员,否则须与我的部门一致)。
|
||||
// 后端 scope=catalog 已按同口径过滤,此处保留客户端兜底。
|
||||
const myDeptId = computed(() => myProfile.value?.dept_id || '')
|
||||
const myDeptName = computed(() => (myProfile.value?.dept_name || '').trim())
|
||||
const myPermUserId = computed(() => myProfile.value?.user_id || '')
|
||||
const splitNames = (v: string) =>
|
||||
(v || '').split(/[、,,;;]/).map((s) => s.trim()).filter(Boolean)
|
||||
const inPermIds = (ids: string, want: string) =>
|
||||
Boolean(want) && ids.split(',').map((s) => s.trim()).includes(want)
|
||||
const hexinCourses = computed<TrainingLibraryCourse[]>(() =>
|
||||
libraryItems.value.filter((c) => {
|
||||
if (c.publish_status !== 'published') return false
|
||||
const suitableNames = (c.suitable_members || '')
|
||||
.split(/[、,,;;]/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
// 新口径(000163):perm 任一列非空按 id 精确匹配
|
||||
if ((c.perm_dept_ids || '').trim() || (c.perm_user_ids || '').trim()) {
|
||||
return inPermIds(c.perm_dept_ids || '', myDeptId.value) || inPermIds(c.perm_user_ids || '', myPermUserId.value)
|
||||
}
|
||||
// 存量老口径:suitable_members 文本 / 所属部门兜底
|
||||
const suitableNames = splitNames(c.suitable_members || '')
|
||||
if (suitableNames.length) {
|
||||
return suitableNames.includes('全部') || (!!myDeptName.value && suitableNames.includes(myDeptName.value))
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
<template #plan_code="{ row }">{{ row.plan_code || '-' }}</template>
|
||||
<template #name="{ row }">
|
||||
<span class="course-name-link clamp-2" title="点击前往培训签到" @click="goSignTab(row)">{{ row.name }}</span>
|
||||
<!-- 课程已下线(000163):关联课程管理条目 offline 时标注(计划行保留,
|
||||
学习入口提示「该课程已下线」) -->
|
||||
<t-tag v-if="row.library_offline" theme="danger" variant="outline" size="small" class="offline-flag">课程已下线</t-tag>
|
||||
</template>
|
||||
<template #mode="{ row }">
|
||||
<t-tag :theme="row.mode === 'online' ? 'primary' : 'default'" variant="light" size="small" :class="{ 'course-tag-offline': row.mode !== 'online' }">
|
||||
@@ -123,7 +126,7 @@
|
||||
<t-input :value="deptNamesOf(form.dept_ids)" disabled placeholder="随课程带出" />
|
||||
</t-form-item>
|
||||
<!-- 课程资产侧信息随所选课程带出(000156);000163 起课件/试题可在创建时
|
||||
上传/更换(回写课程管理主数据,变更后课程回「待核验」须课长/经理签核) -->
|
||||
上传/更换(回写课程管理主数据,变更后课程回「待审核」须课长/经理审核) -->
|
||||
<t-form-item label="适合人员">
|
||||
<t-input :value="formLibraryCourse?.suitable_members || '-'" disabled placeholder="随所选课程带出" />
|
||||
</t-form-item>
|
||||
@@ -158,7 +161,7 @@
|
||||
</t-select>
|
||||
<t-button theme="primary" size="small" :loading="formAssetSaving" :disabled="!formKbCoursewareDocId" @click="onFormAttachKbCourseware">确定</t-button>
|
||||
</div>
|
||||
<div class="bank-hint">课件上传/更换后自动回写课程管理,该课程回「待核验」,需所属部门课长/经理签核后方可发布计划</div>
|
||||
<div class="bank-hint">课件上传/更换后自动回写课程管理,该课程回「待审核」,需所属部门课长/经理审核后方可发布计划</div>
|
||||
</t-form-item>
|
||||
<t-form-item label="试题">
|
||||
<div class="asset-row">
|
||||
@@ -279,14 +282,14 @@
|
||||
</div>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<div class="form-hint">发布后将自动生成计划与学员名单(线下计划含签到码),并推送讲师与学员通知;课程信息随所选课程带出,课件/试题可在本弹窗上传/更换(自动同步课程管理,变更后该课程回「待核验」,需课长/经理重新签核后方可发布)。</div>
|
||||
<div class="form-hint">发布后将自动生成计划与学员名单(线下计划含签到码),并推送讲师与学员通知;课程信息随所选课程带出,课件/试题可在本弹窗上传/更换(自动同步课程管理,变更后该课程回「待审核」,需课长/经理重新审核后方可发布)。</div>
|
||||
<template #footer>
|
||||
<t-button variant="outline" :loading="saving" @click="onSaveDraft">暂存草稿</t-button>
|
||||
<t-button theme="primary" :loading="saving" @click="onSave">保存并发布</t-button>
|
||||
</template>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 计划调整:计划编号展示 + 课程名称/讲师(000161 可调整,讲师改动回写课程管理并重置待核验) + 六项授课安排维护 -->
|
||||
<!-- 计划调整:计划编号展示 + 课程名称/讲师(000161 可调整,讲师改动回写课程管理并重置待审核) + 六项授课安排维护 -->
|
||||
<t-dialog v-model:visible="sessionsVisible" :header="`计划调整 · ${activeCourse?.name || ''}`" width="760" :footer="false">
|
||||
<t-form label-width="90" class="detail-form">
|
||||
<t-form-item label="计划编号">
|
||||
@@ -295,7 +298,7 @@
|
||||
<t-form-item label="课程名称">
|
||||
<!-- 000161 可切换关联课程:改选即换 library_course_id,名称/类型随新课程带出
|
||||
(形式为计划侧独立字段,000162 起不随课程联动);讲师改动保存后回写
|
||||
课程管理并重置待核验,发布前须重新签核 -->
|
||||
课程管理并重置待审核,发布前须重新审核 -->
|
||||
<t-select
|
||||
v-model="editForm.library_course_id"
|
||||
:disabled="!canManage"
|
||||
@@ -864,7 +867,7 @@ const sessionsVisible = ref(false)
|
||||
const activeCourse = ref<TrainingCourse | null>(null)
|
||||
|
||||
// ---- 创建弹窗课件/试题维护(000163):与调整弹窗同口径,直接回写课程管理
|
||||
// 主数据;课件/试题变更后端自动置该课程「待核验」,须课长/经理签核后方可发布 ----
|
||||
// 主数据;课件/试题变更后端自动置该课程「待审核」,须课长/经理审核后方可发布 ----
|
||||
const formAssetSaving = ref(false)
|
||||
const formMaterialInput = ref<HTMLInputElement | null>(null)
|
||||
const formKbCoursewareVisible = ref(false)
|
||||
@@ -910,7 +913,7 @@ const onFormChangeMaterial = async (e: Event) => {
|
||||
fd.append('file', file)
|
||||
const updated = unwrap(await uploadCourseLibraryMaterial(lc.id, fd)) as TrainingLibraryCourse | null
|
||||
replaceLibraryCourse(updated)
|
||||
MessagePlugin.success(`课件已上传到课程「${lc.name}」,该课程回「待核验」,需所属部门课长/经理签核后方可发布计划`)
|
||||
MessagePlugin.success(`课件已上传到课程「${lc.name}」课件列表(追加不替换),该课程回「待审核」,需所属部门课长/经理审核后方可发布计划`)
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '课件上传失败,请稍后重试'))
|
||||
} finally {
|
||||
@@ -918,7 +921,7 @@ const onFormChangeMaterial = async (e: Event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 从知识库选文档挂为课件(与上传同口径,变更后回「待核验」)
|
||||
// 从知识库选文档挂为课件(与上传同口径,变更后回「待审核」)
|
||||
const onFormAttachKbCourseware = async () => {
|
||||
const lc = requireFormLibraryCourse()
|
||||
const doc = kbCoursewareDocs.value.find((d) => d.id === formKbCoursewareDocId.value)
|
||||
@@ -932,7 +935,7 @@ const onFormAttachKbCourseware = async () => {
|
||||
replaceLibraryCourse(updated)
|
||||
formKbCoursewareVisible.value = false
|
||||
formKbCoursewareDocId.value = ''
|
||||
MessagePlugin.success(`课件已更换为知识库文档「${doc.file_name}」,课程「${lc.name}」回「待核验」,需课长/经理签核后方可发布计划`)
|
||||
MessagePlugin.success(`课件「${doc.file_name}」已挂接为课程「${lc.name}」最新课件(原课件保留),课程回「待审核」,需课长/经理审核后方可发布计划`)
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '课件更换失败,请稍后重试'))
|
||||
} finally {
|
||||
@@ -940,7 +943,7 @@ const onFormAttachKbCourseware = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 更换试题:所选题库整体替换该课程条目的题库(后端同步重置签核状态)
|
||||
// 更换试题:所选题库整体替换该课程条目的题库(后端同步重置审核状态)
|
||||
const onFormRelinkBank = async () => {
|
||||
const lc = requireFormLibraryCourse()
|
||||
if (!lc || !formRelinkBankId.value) {
|
||||
@@ -959,7 +962,7 @@ const onFormRelinkBank = async () => {
|
||||
})
|
||||
formRelinkVisible.value = false
|
||||
formRelinkBankId.value = ''
|
||||
MessagePlugin.success(`试题已更换到课程「${lc.name}」,该课程回「待核验」,需课长/经理签核后方可发布计划`)
|
||||
MessagePlugin.success(`试题已更换到课程「${lc.name}」,该课程回「待审核」,需课长/经理审核后方可发布计划`)
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '试题更换失败,请稍后重试'))
|
||||
} finally {
|
||||
@@ -967,7 +970,7 @@ const onFormRelinkBank = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 从知识库题库文档解析建题库并挂当前所选课程条目(后端同步重置签核状态)
|
||||
// 从知识库题库文档解析建题库并挂当前所选课程条目(后端同步重置审核状态)
|
||||
const onFormImportKbBank = async () => {
|
||||
const lc = requireFormLibraryCourse()
|
||||
const doc = kbBankDocs.value.find((d) => d.id === formKbBankDocId.value)
|
||||
@@ -985,7 +988,7 @@ const onFormImportKbBank = async () => {
|
||||
formKbBankVisible.value = false
|
||||
formKbBankDocId.value = ''
|
||||
if (bank) allBanks.value = [bank, ...allBanks.value.filter((b) => b.id !== bank.id)]
|
||||
MessagePlugin.success(`试题已更换为知识库题库「${bank?.name || doc.file_name}」,课程「${lc.name}」回「待核验」,需课长/经理签核后方可发布计划`)
|
||||
MessagePlugin.success(`试题已更换为知识库题库「${bank?.name || doc.file_name}」,课程「${lc.name}」回「待审核」,需课长/经理审核后方可发布计划`)
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '试题更换失败,请稍后重试'))
|
||||
} finally {
|
||||
@@ -1429,10 +1432,10 @@ const onSave = async () => {
|
||||
// 报笼统的「保存失败」且不刷新列表(草稿其实已落库),表现为“无法创建月度计划”。
|
||||
// 现与后端 PublishCourse 同口径,在提交前逐项拦截并给出明确提示。
|
||||
const selectedLib = libraryCourses.value.find((c) => c.id === form.value.library_course_id)
|
||||
// 课程须已完成签核(000157/000158):未核验时发布被后端拦截,这里提前提示
|
||||
// 000163:课程须已审核(审核通过即自动发布);未审核时发布被后端拦截,这里提前提示
|
||||
if (selectedLib && selectedLib.verify_status !== 'confirmed') {
|
||||
MessagePlugin.warning(
|
||||
`课程「${selectedLib.name}」尚未完成签核,请先联系所属部门课长/经理在「课程管理」中核验确认后再创建发布`,
|
||||
`课程「${selectedLib.name}」尚未审核,请先联系所属部门课长/经理在「课程管理」中审核(审核通过即发布)后再创建发布`,
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -1557,7 +1560,7 @@ const onSaveDraft = async () => {
|
||||
|
||||
const onPublish = async (row: TrainingCourse) => {
|
||||
// 与后端同口径的前置校验(000161):线上必须有课件;线下须有讲师(外部姓名
|
||||
// 亦可)/授课时间/授课地点;两者均须已设置参加人员且关联课程已签核
|
||||
// 亦可)/授课时间/授课地点;两者均须已设置参加人员且关联课程已审核
|
||||
if (row.mode === 'online') {
|
||||
try {
|
||||
const res = await listMaterials(row.id)
|
||||
@@ -2150,6 +2153,11 @@ watch(() => route?.query?.courseId, openDetailFromRoute)
|
||||
}
|
||||
}
|
||||
|
||||
// 课程已下线标签(000163):紧跟课程名称,警示已下线课程不可再学习
|
||||
.offline-flag {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.course-panel :deep(.t-table .t-table__cell) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 查询条件:课程编号/名称/分类/类型/形式。列表全量加载(page_size=500),
|
||||
企业内部数据量小,分类/类型/形式过滤在前端本地完成,不新增后端查询参数。 -->
|
||||
<!-- 查询条件:课程编号/名称/分类/类型/形式/状态。列表全量加载(page_size=500),
|
||||
企业内部数据量小,分类/类型/形式/状态过滤在前端本地完成,不新增后端查询参数。 -->
|
||||
<div class="library-filters">
|
||||
<t-input v-model="filters.keyword" placeholder="按课程编号/名称查询" clearable style="width: 200px" />
|
||||
<t-select v-model="filters.category" placeholder="按分类查询" clearable style="width: 140px">
|
||||
@@ -27,13 +27,18 @@
|
||||
<t-option value="offline" label="线下" />
|
||||
<t-option value="online" label="线上" />
|
||||
</t-select>
|
||||
<!-- 按状态查询(测试反馈 2026-11-26):审核状态列(待审核/已审核) -->
|
||||
<t-select v-model="filters.status" placeholder="按状态查询" clearable style="width: 120px">
|
||||
<t-option value="pending" label="待审核" />
|
||||
<t-option value="confirmed" label="已审核" />
|
||||
</t-select>
|
||||
<t-button variant="text" theme="primary" size="small" @click="resetFilters">重置</t-button>
|
||||
<span class="library-filter-count">共 {{ filteredItems.length }} 门</span>
|
||||
<!-- 批量操作(000157):核验/删除均仅课长/经理限本部门,且仅待核验行可删 -->
|
||||
<!-- 批量操作(000157):审核/删除均仅课长/经理限本部门,且仅待审核行可删 -->
|
||||
<t-button
|
||||
v-if="canVerify" variant="outline" theme="primary" size="small"
|
||||
:disabled="!selectedKeys.length" :loading="batchSaving" @click="onBatchVerify"
|
||||
>批量核验</t-button>
|
||||
>批量审核</t-button>
|
||||
<t-button
|
||||
v-if="canDelete" variant="outline" theme="danger" size="small"
|
||||
:disabled="!selectedKeys.length" :loading="batchSaving" @click="onBatchDelete"
|
||||
@@ -74,7 +79,8 @@
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #suitable_members="{ row }">
|
||||
<span v-if="row.suitable_members" class="cell-ellipsis" :title="row.suitable_members">{{ row.suitable_members }}</span>
|
||||
<!-- 课程权限(000163,原「适合人员」):部门+人员展示文本 -->
|
||||
<span v-if="permissionText(row)" class="cell-ellipsis" :title="permissionText(row)">{{ permissionText(row) }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #material="{ row }">
|
||||
@@ -96,10 +102,11 @@
|
||||
variant="light" size="small"
|
||||
>{{ publishStatusText(row.publish_status) }}</t-tag>
|
||||
</template>
|
||||
<!-- 核验状态(000157):新增/编辑后待核验,课长/经理核验确认后方可发布 -->
|
||||
<!-- 审核状态(000157/000163):新增/编辑后待审核,课长/经理审核确认后
|
||||
即自动发布(无需再点发布) -->
|
||||
<template #verify_status="{ row }">
|
||||
<t-tag :theme="row.verify_status === 'confirmed' ? 'success' : 'warning'" variant="light" size="small">
|
||||
{{ row.verify_status === 'confirmed' ? '已确认' : '待核验' }}
|
||||
{{ row.verify_status === 'confirmed' ? '已审核' : '待审核' }}
|
||||
</t-tag>
|
||||
</template>
|
||||
<template #op="{ row }">
|
||||
@@ -108,28 +115,23 @@
|
||||
<t-button variant="text" size="small" @click="openQuestions(row)">试题</t-button>
|
||||
<t-popconfirm
|
||||
v-if="canVerifyCourse(row)"
|
||||
content="核验确认后该课程方可发布,确认核验通过?" theme="primary"
|
||||
content="审核通过后将立即发布(权限范围内的部门和人员可在培训中心/培训计划中查看),确认审核通过?" theme="primary"
|
||||
@confirm="onVerify(row)"
|
||||
>
|
||||
<t-button variant="text" theme="primary" size="small">核验</t-button>
|
||||
</t-popconfirm>
|
||||
<t-popconfirm
|
||||
v-if="canManage && row.publish_status !== 'published'"
|
||||
content="发布后该课程进入培训中心「和信课程」目录(本部门可见)。" theme="primary"
|
||||
@confirm="onSetPublishStatus(row, 'published')"
|
||||
>
|
||||
<t-button variant="text" theme="primary" size="small">发布</t-button>
|
||||
<t-button variant="text" theme="primary" size="small">审核</t-button>
|
||||
</t-popconfirm>
|
||||
<!-- 下线(000163):下线后课程不能再被使用 —— 和信课程撤回、计划不可
|
||||
再选用、已建计划学习时提示「该课程已下线」;存量培训计划保留 -->
|
||||
<t-popconfirm
|
||||
v-if="canManage && row.publish_status === 'published'"
|
||||
content="下线后该课程将从培训中心「和信课程」目录撤回。" theme="danger"
|
||||
content="下线后该课程不能再被使用:培训中心「和信课程」不再展示,培训计划不可再选用,已建计划学习时提示「该课程已下线」(已有培训计划不会消失)。确定下线?" theme="danger"
|
||||
@confirm="onSetPublishStatus(row, 'offline')"
|
||||
>
|
||||
<t-button variant="text" theme="danger" size="small">下线</t-button>
|
||||
</t-popconfirm>
|
||||
<t-popconfirm
|
||||
v-if="canDeleteCourse(row)"
|
||||
content="仅待核验状态的课程可删除,确定删除该课程?已创建的月培训计划不受影响。" theme="danger" @confirm="onDelete(row)"
|
||||
content="仅待审核状态的课程可删除,确定删除该课程?已创建的月培训计划不受影响。" theme="danger" @confirm="onDelete(row)"
|
||||
>
|
||||
<t-button variant="text" theme="danger" size="small">删除</t-button>
|
||||
</t-popconfirm>
|
||||
@@ -161,14 +163,31 @@
|
||||
<t-form-item label="说明">
|
||||
<t-textarea v-model="form.description" placeholder="课程内容简介(选填)" :autosize="{ minRows: 2 }" />
|
||||
</t-form-item>
|
||||
<t-form-item label="适合人员">
|
||||
<!-- 000159 部门多选口径:归属部门(可多选)或「全部」(互斥);发布后
|
||||
培训中心按此展示给对应人员,存量自由文本值回显为选项 -->
|
||||
<t-form-item label="课程权限">
|
||||
<!-- 000163 课程权限(原「适合人员」):默认所属部门;可同时选择部门和
|
||||
人员,部门与其下人员互斥(选了部门即覆盖其全员,不能再重复选该
|
||||
部门下的人员,可选其他部门人员);「全部」=全员可见互斥项。审核
|
||||
后仅所选部门和人员可在月/年培训计划、课程管理、培训中心看到该课程 -->
|
||||
<t-select
|
||||
v-model="suitableList" clearable filterable multiple
|
||||
placeholder="选择部门(可多选),或选「全部」" style="width: 100%"
|
||||
v-model="permList" multiple filterable clearable
|
||||
:min-collapsed-num="8"
|
||||
placeholder="默认所属部门;可同时选择部门和人员(部门与其下人员互斥)" style="width: 100%"
|
||||
>
|
||||
<t-option v-for="opt in suitableOptions" :key="opt" :value="opt" :label="opt" />
|
||||
<t-option :value="PERM_ALL" label="全部(全员可见)" />
|
||||
<t-option-group v-if="permDeptOptions.length" label="按部门">
|
||||
<t-option
|
||||
v-for="o in permDeptOptions" :key="o.value" :value="o.value"
|
||||
:label="o.label" :disabled="permOptionDisabled(o)"
|
||||
/>
|
||||
</t-option-group>
|
||||
<t-option-group v-if="permUserOptions.length" label="按人员">
|
||||
<t-option
|
||||
v-for="o in permUserOptions" :key="o.value" :value="o.value"
|
||||
:label="o.label" :disabled="permOptionDisabled(o)"
|
||||
/>
|
||||
</t-option-group>
|
||||
<!-- 存量自由文本权限回显为额外选项(未匹配到部门/人员名册的旧值) -->
|
||||
<t-option v-for="v in permLegacyExtras" :key="v" :value="v" :label="v" />
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item label="分类">
|
||||
@@ -199,7 +218,7 @@
|
||||
<t-input-number v-model="form.hours" :min="0" :step="0.5" style="width: 100%" />
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<div class="form-hint">分类选项由配置中心「课程分类」维护,支持手动输入保存;讲师可为员工名册内人员或外部讲师;月培训计划「课程名称」将从本页课程中选择并自动带出此处维护的信息(不可修改);课件上传/预览/下载经列表「课件」入口、试题经列表「试题」入口维护;发布课程前必须已上传课件。</div>
|
||||
<div class="form-hint">分类选项由配置中心「课程分类」维护,支持手动输入保存;讲师可为员工名册内人员或外部讲师;课程权限默认所属部门,审核通过后仅所选部门和人员可在培训中心「和信课程」、月/年培训计划及课程管理中查看学习该课程;月培训计划「课程名称」将从本页课程中选择并自动带出此处维护的信息(不可修改);课件上传/预览/下载经列表「课件」入口、试题经列表「试题」入口维护。</div>
|
||||
<template #footer>
|
||||
<t-button variant="outline" @click="formVisible = false">取消</t-button>
|
||||
<t-button theme="primary" :loading="saving" @click="onSave">保存</t-button>
|
||||
@@ -239,11 +258,12 @@
|
||||
<t-radio-button value="kb">从知识库选择</t-radio-button>
|
||||
</t-radio-group>
|
||||
<template v-if="materialSourceMode === 'upload'">
|
||||
<input ref="materialFileInputRef" type="file" class="bank-upload-input" @change="onMaterialPicked" />
|
||||
<!-- 000164 多课件:支持一次选择多个文件,逐个追加为课件条目(不替换既有课件) -->
|
||||
<input ref="materialFileInputRef" type="file" multiple class="bank-upload-input" @change="onMaterialPicked" />
|
||||
<t-button variant="outline" size="small" @click="materialFileInputRef?.click()">选择文件</t-button>
|
||||
<span v-if="materialFile" class="bank-file-name">{{ materialFile.name }}</span>
|
||||
<span v-if="materialFiles.length" class="bank-file-name">已选 {{ materialFiles.length }} 个文件</span>
|
||||
<span v-else class="bank-file-placeholder">未选择文件</span>
|
||||
<t-button theme="primary" size="small" :loading="materialUploading" :disabled="!materialFile" @click="onUploadMaterial">上传并关联课件</t-button>
|
||||
<t-button theme="primary" size="small" :loading="materialUploading" :disabled="!materialFiles.length" @click="onUploadMaterial">上传并关联课件</t-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<t-select
|
||||
@@ -261,20 +281,23 @@
|
||||
</template>
|
||||
</div>
|
||||
<div class="form-hint">
|
||||
数据来源:知识库「{{ coursewareKbRef?.name || '企业培训(课件)' }}」共 {{ kbDocs.length }} 个文档;课件变更后课程回「待核验」,重新核验后方可发布;文档类课件上传后自动同步知识库(月培训计划带出/AI 出题/对话问答共用);发布课程前必须已上传课件。
|
||||
数据来源:知识库「{{ coursewareKbRef?.name || '企业培训(课件)' }}」共 {{ kbDocs.length }} 个文档;课件上传/挂接按条目追加,支持多个课件不再整体替换(000164),课件变更后课程回「待审核」,重新审核通过后自动发布;文档类课件上传后自动同步知识库(月培训计划带出/AI 出题/对话问答共用);课程发布前必须已上传课件。
|
||||
</div>
|
||||
|
||||
<t-table v-if="materialCourse" :data="materialRows" :columns="materialColumns" row-key="key" size="small">
|
||||
<t-table v-if="materialCourse" :data="materialRows" :columns="materialColumns" row-key="mid" size="small">
|
||||
<template #size="{ row }">{{ row.size ? fmtSize(row.size) : '-' }}</template>
|
||||
<template #op>
|
||||
<t-button variant="text" theme="primary" size="small" @click="onPreviewMaterial">预览</t-button>
|
||||
<t-button variant="text" theme="primary" size="small" @click="onDownloadMaterial(materialCourse)">下载</t-button>
|
||||
<t-popconfirm content="移除后课程回「待核验」,需重新上传课件方可发布,确定移除?" theme="danger" @confirm="onRemoveMaterial">
|
||||
<template #op="{ row }">
|
||||
<t-button variant="text" theme="primary" size="small" @click="onPreviewMaterial(row)">预览</t-button>
|
||||
<t-button variant="text" theme="primary" size="small" @click="onDownloadMaterial(materialCourse, row)">下载</t-button>
|
||||
<t-popconfirm content="移除后课程回「待审核」,需重新上传课件并审核后才会发布,确定移除该课件?" theme="danger" @confirm="onRemoveMaterial(row)">
|
||||
<t-button variant="text" theme="danger" size="small">移除</t-button>
|
||||
</t-popconfirm>
|
||||
</template>
|
||||
</t-table>
|
||||
<t-empty v-if="materialCourse && !hasMaterial(materialCourse)" description="暂无课件,可在上方上传文件或从知识库选择;发布课程前必须已上传课件" />
|
||||
<t-empty
|
||||
v-if="materialCourse && !materialRows.length"
|
||||
description="暂无课件,可在上方上传文件(可多选)或从知识库选择;课程发布前必须已上传课件"
|
||||
/>
|
||||
</t-drawer>
|
||||
|
||||
<!-- 试题管理抽屉:题库与试题随课程条目增删改查(上传 Excel/知识库导入/AI 出题) -->
|
||||
@@ -528,7 +551,6 @@ import {
|
||||
listMembers,
|
||||
listQuestions,
|
||||
offlineCourseLibraryItem,
|
||||
publishCourseLibraryItem,
|
||||
removeCourseLibraryMaterial,
|
||||
saveCourseLibraryItem,
|
||||
saveQuestion,
|
||||
@@ -544,7 +566,7 @@ import {
|
||||
|
||||
const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
// 课程维护(新增/编辑/发布/导入/导出):人事/课长/讲师(roles 已按权限组展开,
|
||||
// 经理经课长继承自动命中)。人事无核验/删除权限(000157)。
|
||||
// 经理经课长继承自动命中)。人事无审核/删除权限(000157)。
|
||||
const canManage = computed(() => props.admin || props.roles.some((r) => r === 'hr' || r === 'supervisor' || r === 'lecturer'))
|
||||
|
||||
const loading = ref(false)
|
||||
@@ -559,40 +581,152 @@ const configCategories = ref<string[]>([])
|
||||
const myDeptId = ref('')
|
||||
// 本人用户 id:学员「与我相关」课程的编辑权限判断(创建人/讲师为本人)
|
||||
const myUserId = ref('')
|
||||
// 本人部门名(000160):「适合人员」默认值 = 创建人所属部门名;经 me 的
|
||||
// dept_name 联查字段直取,回退本地部门名册映射。
|
||||
const myDeptName = computed(() => {
|
||||
const fromMe = (meDeptName.value || '').trim()
|
||||
if (fromMe) return fromMe
|
||||
const hit = depts.value.find((d) => d.id === myDeptId.value)
|
||||
return hit?.name || ''
|
||||
})
|
||||
// /training/members/me 联查返回的部门名(handler 000160 起填充)
|
||||
const meDeptName = ref('')
|
||||
// 「适合人员」下拉选项(000160/000159 多选口径):全部 + 各部门名;存量自由文本值保留可选
|
||||
const suitableOptions = computed(() => {
|
||||
const opts = ['全部', ...depts.value.map((d) => d.name)]
|
||||
for (const v of splitSuitable(form.value.suitable_members)) {
|
||||
if (!opts.includes(v)) opts.push(v)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 课程权限(000163,原「适合人员」):部门 + 人员混合选择,默认所属部门;
|
||||
// 部门与其下人员互斥(选了人事部即覆盖其全员,不能再选人事部下的人员,可选
|
||||
// 其他部门人员);「全部」=全员可见互斥项。落库:perm_dept_ids/perm_user_ids
|
||||
// 为逗号分隔 id,suitable_members 为部门名+人员名展示文本(存量口径兼容)。
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const PERM_ALL = '__all__'
|
||||
// 选项值编码:dept:<id> / user:<id> / PERM_ALL / 存量自由文本原值
|
||||
const permList = ref<string[]>([])
|
||||
|
||||
// 部门选项(含 id 供互斥判定)
|
||||
const permDeptOptions = computed(() =>
|
||||
depts.value.map((d) => ({ value: `dept:${d.id}`, label: d.name || `部门${d.id}`, deptId: d.id })),
|
||||
)
|
||||
// 人员选项(含其部门 id:已选部门时该部门下人员置灰)
|
||||
const permUserOptions = computed(() =>
|
||||
members.value
|
||||
.filter((m) => m.user_id)
|
||||
.map((m) => ({
|
||||
value: `user:${m.user_id}`,
|
||||
label: [m.user_name || m.employee_no, m.dept_name].filter(Boolean).join(' · '),
|
||||
deptId: m.dept_id || '',
|
||||
})),
|
||||
)
|
||||
// 存量自由文本回显:permList 中既非「全部」也非 id 编码的旧值补为临时选项
|
||||
const permLegacyExtras = computed(() =>
|
||||
permList.value.filter((v) => v !== PERM_ALL && !v.startsWith('dept:') && !v.startsWith('user:')),
|
||||
)
|
||||
|
||||
// 互斥置灰:「全部」已选时部门/人员全部置灰;人员选项在其所属部门已被选中时置灰
|
||||
const permOptionDisabled = (o: { value: string; deptId?: string }) => {
|
||||
if (permList.value.includes(PERM_ALL)) return o.value !== PERM_ALL
|
||||
if (o.value.startsWith('user:') && o.deptId && permList.value.includes(`dept:${o.deptId}`)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
// 部门与其下人员互斥兜底(watch):勾选部门后自动移除该部门下已选人员;
|
||||
// 「全部」与具体部门/人员互斥(勾全部清其余,勾其余移除全部)。
|
||||
watch(permList, (list, prev) => {
|
||||
if (list.includes(PERM_ALL) && list.length > 1) {
|
||||
permList.value = (prev || []).includes(PERM_ALL) ? list.filter((v) => v !== PERM_ALL) : [PERM_ALL]
|
||||
return
|
||||
}
|
||||
return opts
|
||||
})
|
||||
// 适合人员多选值(000159):form.suitable_members 存「、」join 后的落库串,
|
||||
// 选项交互走本数组;「全部」与具体部门互斥(勾全部清部门,勾部门移除全部)。
|
||||
const suitableList = ref<string[]>([])
|
||||
const splitSuitable = (v: string) =>
|
||||
(v || '').split(/[、,,;;]/).map((s) => s.trim()).filter(Boolean)
|
||||
watch(suitableList, (list, prev) => {
|
||||
if (list.includes('全部') && list.length > 1) {
|
||||
suitableList.value = (prev || []).includes('全部') ? list.filter((v) => v !== '全部') : ['全部']
|
||||
const deptIds = new Set(
|
||||
list.filter((v) => v.startsWith('dept:')).map((v) => v.slice('dept:'.length)),
|
||||
)
|
||||
if (!deptIds.size) return
|
||||
const dupUsers = list.filter((v) => {
|
||||
if (!v.startsWith('user:')) return false
|
||||
const opt = permUserOptions.value.find((o) => o.value === v)
|
||||
return Boolean(opt?.deptId && deptIds.has(opt.deptId))
|
||||
})
|
||||
if (dupUsers.length) {
|
||||
permList.value = list.filter((v) => !dupUsers.includes(v))
|
||||
MessagePlugin.warning('所选部门已包含其下人员,已自动移除重复选择的人员')
|
||||
}
|
||||
})
|
||||
|
||||
// 核验/删除权限(000157):严格限「本部门课长/经理」——人事/空间管理员一律无
|
||||
// 跨部门核验/删除权(roles 已按权限组展开,经理经课长继承自动命中 supervisor)。
|
||||
const splitSuitable = (v: string) =>
|
||||
(v || '').split(/[、,,;;]/).map((s) => s.trim()).filter(Boolean)
|
||||
|
||||
// 人员显示名(成员名册联查;未命中回退原始 id,避免标签显示为空)
|
||||
const memberDisplayName = (userId: string) => {
|
||||
const hit = members.value.find((m) => m.user_id === userId)
|
||||
return hit?.user_name || hit?.employee_no || userId
|
||||
}
|
||||
|
||||
// 行数据 → 课程权限选项值(回显):优先 perm 两列;存量课程回退解析
|
||||
// suitable_members(部门名/人员名/「全部」,未命中文本原样保留)
|
||||
const parsePermFromRow = (row?: TrainingLibraryCourse): string[] => {
|
||||
if (!row) {
|
||||
// 新增默认:课程权限 = 所属部门(创建人所在部门)
|
||||
return myDeptId.value ? [`dept:${myDeptId.value}`] : []
|
||||
}
|
||||
const deptIds = (row.perm_dept_ids || '').split(',').map((s) => s.trim()).filter(Boolean)
|
||||
const userIds = (row.perm_user_ids || '').split(',').map((s) => s.trim()).filter(Boolean)
|
||||
if (deptIds.length || userIds.length) {
|
||||
return [...deptIds.map((id) => `dept:${id}`), ...userIds.map((id) => `user:${id}`)]
|
||||
}
|
||||
const names = splitSuitable(row.suitable_members || '')
|
||||
if (names.includes('全部')) return [PERM_ALL]
|
||||
const out: string[] = []
|
||||
for (const n of names) {
|
||||
const dept = depts.value.find((d) => d.name === n)
|
||||
if (dept) {
|
||||
out.push(`dept:${dept.id}`)
|
||||
continue
|
||||
}
|
||||
const member = members.value.find((m) => (m.user_name || '') === n)
|
||||
if (member?.user_id) {
|
||||
out.push(`user:${member.user_id}`)
|
||||
continue
|
||||
}
|
||||
out.push(n)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// permList → 落库三字段:perm_dept_ids/perm_user_ids(suitable_members 同步为
|
||||
// 展示文本,兼容导出/需求模板 VLOOKUP 与存量匹配口径;「全部」=存量全员口径)
|
||||
const permToFields = () => {
|
||||
const deptIds: string[] = []
|
||||
const userIds: string[] = []
|
||||
const extraNames: string[] = []
|
||||
for (const v of permList.value) {
|
||||
if (v === PERM_ALL) continue
|
||||
if (v.startsWith('dept:')) deptIds.push(v.slice('dept:'.length))
|
||||
else if (v.startsWith('user:')) userIds.push(v.slice('user:'.length))
|
||||
else extraNames.push(v)
|
||||
}
|
||||
const isAll = permList.value.includes(PERM_ALL)
|
||||
const displayNames = [
|
||||
...deptIds.map((id) => depts.value.find((d) => d.id === id)?.name || id),
|
||||
...userIds.map(memberDisplayName),
|
||||
...extraNames,
|
||||
]
|
||||
return {
|
||||
perm_dept_ids: isAll ? '' : deptIds.join(','),
|
||||
perm_user_ids: isAll ? '' : userIds.join(','),
|
||||
suitable_members: isAll ? '全部' : displayNames.join('、'),
|
||||
}
|
||||
}
|
||||
|
||||
// 列表「课程权限」列展示文本:perm 两列解析为「部门、人员」;存量行回退原文本
|
||||
const permissionText = (row: TrainingLibraryCourse) => {
|
||||
if ((row.perm_dept_ids || '').trim() || (row.perm_user_ids || '').trim()) {
|
||||
const deptNames = (row.perm_dept_ids || '').split(',').filter(Boolean).map((id) => depts.value.find((d) => d.id === id)?.name || id)
|
||||
const userNames = (row.perm_user_ids || '').split(',').filter(Boolean).map(memberDisplayName)
|
||||
return [...deptNames, ...userNames].join('、')
|
||||
}
|
||||
return row.suitable_members || ''
|
||||
}
|
||||
|
||||
// 课程权限是否已设置(审核前置,000163:权限必填)
|
||||
const hasPermSet = (row: TrainingLibraryCourse) =>
|
||||
Boolean((row.perm_dept_ids || '').trim() || (row.perm_user_ids || '').trim() || (row.suitable_members || '').trim())
|
||||
|
||||
// 审核/删除权限(000157):严格限「本部门课长/经理」——人事/空间管理员一律无
|
||||
// 跨部门审核/删除权(roles 已按权限组展开,经理经课长继承自动命中 supervisor)。
|
||||
const canVerify = computed(() => props.roles.includes('supervisor'))
|
||||
const canDelete = canVerify
|
||||
// 仅本部门「待核验」课程可核验/删除;与后端 callerVerifyDeptScope 同口径:
|
||||
// 仅本部门「待审核」课程可审核/删除;与后端 callerVerifyDeptScope 同口径:
|
||||
// 无部门身份或课程所属部门与本人不一致时一律不可操作。
|
||||
const canVerifyCourse = (row: TrainingLibraryCourse) =>
|
||||
canVerify.value &&
|
||||
@@ -608,10 +742,10 @@ const canEditCourse = (row: TrainingLibraryCourse) =>
|
||||
canManage.value ||
|
||||
(Boolean(myUserId.value) && (row.creator_id === myUserId.value || row.lecturer_id === myUserId.value))
|
||||
|
||||
// ---- 查询条件(编号/名称/分类/类型/形式;列表全量加载,本地过滤) ----
|
||||
const filters = ref({ keyword: '', category: '', type: '', mode: '' })
|
||||
// ---- 查询条件(编号/名称/分类/类型/形式/状态;列表全量加载,本地过滤) ----
|
||||
const filters = ref({ keyword: '', category: '', type: '', mode: '', status: '' })
|
||||
const resetFilters = () => {
|
||||
filters.value = { keyword: '', category: '', type: '', mode: '' }
|
||||
filters.value = { keyword: '', category: '', type: '', mode: '', status: '' }
|
||||
}
|
||||
|
||||
// 分类选项:配置中心字典 + 库内已有自定义分类(去重),供筛选与表单下拉共用
|
||||
@@ -630,6 +764,7 @@ const filteredItems = computed(() => {
|
||||
if (filters.value.category && row.category !== filters.value.category) return false
|
||||
if (filters.value.type && row.type !== filters.value.type) return false
|
||||
if (filters.value.mode && row.mode !== filters.value.mode) return false
|
||||
if (filters.value.status && (row.verify_status || 'pending') !== filters.value.status) return false
|
||||
return true
|
||||
})
|
||||
})
|
||||
@@ -647,14 +782,14 @@ const {
|
||||
watch(filteredItems, resetItemPage)
|
||||
|
||||
const columns = [
|
||||
// 批量勾选列(000157):配合批量核验/批量删除
|
||||
// 批量勾选列(000157):配合批量审核/批量删除
|
||||
{ colKey: 'row-select', type: 'multiple', width: 44 },
|
||||
// 左侧列不固定(000154):课程编号/课程名称随横向滚动,操作仍固定右侧
|
||||
{ colKey: 'code', title: '课程编号', width: 105 },
|
||||
{ colKey: 'name', title: '课程名称', width: 170 },
|
||||
{ colKey: 'owner_dept', title: '所属部门', width: 110 },
|
||||
{ colKey: 'description', title: '说明', width: 200 },
|
||||
{ colKey: 'suitable_members', title: '适合人员', width: 110 },
|
||||
{ colKey: 'suitable_members', title: '课程权限', width: 110 },
|
||||
{ colKey: 'category', title: '分类', width: 120 },
|
||||
{ colKey: 'type', title: '类型', width: 84 },
|
||||
{ colKey: 'mode', title: '线上/线下', width: 92 },
|
||||
@@ -714,6 +849,9 @@ const form = ref({
|
||||
owner_dept_id: '',
|
||||
description: '',
|
||||
suitable_members: '',
|
||||
// 课程权限(000163):部门/人员 id 列表(逗号分隔),随保存落库
|
||||
perm_dept_ids: '',
|
||||
perm_user_ids: '',
|
||||
category: '',
|
||||
type: 'required' as 'required' | 'elective',
|
||||
// 新增默认「线上」(000162):线上课为常规形态;编辑随原值
|
||||
@@ -777,8 +915,10 @@ const openForm = (row?: TrainingLibraryCourse) => {
|
||||
// 新增默认当前登录用户所在部门(锁定不可改);编辑保持原部门
|
||||
owner_dept_id: row?.owner_dept_id || (row ? '' : myDeptId.value),
|
||||
description: row?.description || '',
|
||||
// 适合人员(000160):新增默认创建人所属部门名,可改「全部」或其他部门
|
||||
suitable_members: row?.suitable_members || (row ? '' : myDeptName.value),
|
||||
// 课程权限(000163):新增默认所属部门;编辑按 perm 两列回显(存量回退解析)
|
||||
suitable_members: row?.suitable_members || '',
|
||||
perm_dept_ids: row?.perm_dept_ids || '',
|
||||
perm_user_ids: row?.perm_user_ids || '',
|
||||
category: row?.category || '',
|
||||
type: row?.type === 'elective' ? 'elective' : 'required',
|
||||
// 新增默认「线上」(000162);编辑随原值
|
||||
@@ -787,8 +927,8 @@ const openForm = (row?: TrainingLibraryCourse) => {
|
||||
hours: row?.hours || 0,
|
||||
material_name: row?.material_name || '',
|
||||
}
|
||||
// 适合人员多选回显(000159):落库串「、」join → 数组;新增默认本部门
|
||||
suitableList.value = splitSuitable(form.value.suitable_members)
|
||||
// 课程权限回显(000163):落库 id 列表 → 选项值数组;新增默认本部门
|
||||
permList.value = parsePermFromRow(row)
|
||||
formVisible.value = true
|
||||
}
|
||||
|
||||
@@ -808,14 +948,19 @@ const onSave = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
const lecturer = resolveLecturer(form.value.lecturer.trim())
|
||||
// 适合人员多选 → 「、」join 落库(000159);「全部」与部门互斥由 watch 保证
|
||||
form.value.suitable_members = suitableList.value.join('、')
|
||||
// 课程权限落库(000163):perm 两列 id 列表 + suitable_members 展示文本
|
||||
const perm = permToFields()
|
||||
form.value.suitable_members = perm.suitable_members
|
||||
form.value.perm_dept_ids = perm.perm_dept_ids
|
||||
form.value.perm_user_ids = perm.perm_user_ids
|
||||
const res = await saveCourseLibraryItem({
|
||||
id: form.value.id || undefined,
|
||||
name: form.value.name.trim(),
|
||||
owner_dept_id: form.value.owner_dept_id || undefined,
|
||||
description: form.value.description.trim(),
|
||||
suitable_members: form.value.suitable_members.trim(),
|
||||
perm_dept_ids: form.value.perm_dept_ids,
|
||||
perm_user_ids: form.value.perm_user_ids,
|
||||
category: form.value.category.trim(),
|
||||
type: form.value.type,
|
||||
mode: form.value.mode,
|
||||
@@ -854,47 +999,68 @@ const onDelete = async (row: TrainingLibraryCourse) => {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 核验(000157):待核验 → 已确认,单个/批量共用核验端点(仅课长/经理限本部门) ----
|
||||
// ---- 审核(000163:核验升级为审核,审核通过即自动发布;仅课长/经理限本部门) ----
|
||||
const selectedKeys = ref<string[]>([])
|
||||
const batchSaving = ref(false)
|
||||
|
||||
const onVerify = async (row: TrainingLibraryCourse) => {
|
||||
// 审核前置(000163):课程权限必填,未设置先去编辑设置
|
||||
if (!hasPermSet(row)) {
|
||||
MessagePlugin.warning(`课程「${row.name}」未设置课程权限,请先在「编辑」中设置课程权限后再审核`)
|
||||
return
|
||||
}
|
||||
try {
|
||||
await verifyCourseLibraryItems([row.id])
|
||||
const res = unwrap(await verifyCourseLibraryItems([row.id]))
|
||||
row.verify_status = 'confirmed'
|
||||
MessagePlugin.success(`课程「${row.name}」已核验确认,可发布`)
|
||||
if ((res?.auto_published || 0) > 0) {
|
||||
row.publish_status = 'published'
|
||||
MessagePlugin.success(`课程「${row.name}」已审核通过并自动发布,权限范围内部门和人员可在培训中心/培训计划中查看`)
|
||||
} else if (res?.unpublished?.length) {
|
||||
MessagePlugin.warning(`课程「${row.name}」已审核通过;尚未上传课件暂未发布,上传课件并重新审核后将自动发布`)
|
||||
} else {
|
||||
MessagePlugin.success(`课程「${row.name}」已审核通过`)
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '核验失败'))
|
||||
MessagePlugin.error(apiErrorMessage(e, '审核失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const onBatchVerify = async () => {
|
||||
// 与后端口径一致:仅本部门待核验行提交,已确认/越权行直接跳过
|
||||
// 与后端口径一致:仅本部门待审核行提交,已审核/越权行直接跳过
|
||||
const rows = filteredItems.value.filter(
|
||||
(r) => selectedKeys.value.includes(r.id) && r.verify_status !== 'confirmed' && canVerifyCourse(r),
|
||||
)
|
||||
if (!rows.length) {
|
||||
MessagePlugin.warning('请先勾选本部门待核验状态的课程')
|
||||
MessagePlugin.warning('请先勾选本部门待审核状态的课程')
|
||||
return
|
||||
}
|
||||
// 课程权限必填(000163):未设置权限的行先行拦截并提示
|
||||
const noPerm = rows.filter((r) => !hasPermSet(r))
|
||||
if (noPerm.length) {
|
||||
MessagePlugin.warning(`课程「${noPerm.map((r) => r.name).join('、')}」未设置课程权限,请先设置后再审核`)
|
||||
return
|
||||
}
|
||||
batchSaving.value = true
|
||||
try {
|
||||
const { verified, skipped } = unwrap(await verifyCourseLibraryItems(rows.map((r) => r.id)))
|
||||
MessagePlugin.success(`批量核验完成:成功 ${verified} 条${skipped ? `,跳过 ${skipped} 条` : ''}`)
|
||||
const res = unwrap(await verifyCourseLibraryItems(rows.map((r) => r.id)))
|
||||
const unpublished = res?.unpublished?.length ? `,${res.unpublished.length} 门因未上传课件暂未发布` : ''
|
||||
MessagePlugin.success(
|
||||
`批量审核完成:成功 ${res?.verified || 0} 条${(res?.auto_published || 0) > 0 ? `,自动发布 ${res?.auto_published} 条` : ''}${unpublished}${res?.skipped ? `,跳过 ${res?.skipped} 条` : ''}`,
|
||||
)
|
||||
selectedKeys.value = []
|
||||
loadAll()
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '批量核验失败'))
|
||||
MessagePlugin.error(apiErrorMessage(e, '批量审核失败'))
|
||||
} finally {
|
||||
batchSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onBatchDelete = async () => {
|
||||
// 与后端口径一致:仅本部门待核验行提交(已确认/越权行跳过)
|
||||
// 与后端口径一致:仅本部门待审核行提交(已审核/越权行跳过)
|
||||
const rows = filteredItems.value.filter((r) => selectedKeys.value.includes(r.id) && canDeleteCourse(r))
|
||||
if (!rows.length) {
|
||||
MessagePlugin.warning('请先勾选本部门待核验状态的课程')
|
||||
MessagePlugin.warning('请先勾选本部门待审核状态的课程')
|
||||
return
|
||||
}
|
||||
batchSaving.value = true
|
||||
@@ -917,48 +1083,33 @@ const onBatchDelete = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 发布状态展示文案(000154;000157 起草稿文案调整为「待发布」)
|
||||
// 发布状态展示文案(000154;000163 审核即发布后,draft 仅存于未审核/未传课件课程)
|
||||
const publishStatusText = (status?: string) =>
|
||||
({ published: '已发布', offline: '已下线', draft: '待发布' }[status || 'draft'] || '待发布')
|
||||
|
||||
// 发布/下线(000154):发布后进入培训中心「和信课程」目录,下线即从目录撤回
|
||||
const onSetPublishStatus = async (row: TrainingLibraryCourse, status: 'published' | 'offline') => {
|
||||
// 发布前置校验(000157):仅「已确认」课程可发布(后端兜底同样拦截)
|
||||
if (status === 'published' && row.verify_status !== 'confirmed') {
|
||||
MessagePlugin.warning('该课程尚未核验,请先由本部门课长/经理核验确认后再发布')
|
||||
return
|
||||
}
|
||||
// 发布前置校验(000162):必须有课件(名称登记不算,后端兜底同样拦截)
|
||||
if (status === 'published' && !hasMaterial(row)) {
|
||||
MessagePlugin.warning('该课程尚未上传课件,请先在「课件」入口上传课件文件(或从知识库选择)后再发布')
|
||||
return
|
||||
}
|
||||
// 下线(000154/000163):下线后课程不能再被使用 —— 培训中心「和信课程」撤回、
|
||||
// 月/年培训计划不可再选用、已建计划学习时提示「该课程已下线」;存量计划行保留。
|
||||
// (发布不再单独提供:审核通过即自动发布,见 onVerify/onBatchVerify)
|
||||
const onSetPublishStatus = async (row: TrainingLibraryCourse, status: 'offline') => {
|
||||
try {
|
||||
const updated = unwrap(
|
||||
status === 'published' ? await publishCourseLibraryItem(row.id) : await offlineCourseLibraryItem(row.id),
|
||||
) as TrainingLibraryCourse | null
|
||||
const updated = unwrap(await offlineCourseLibraryItem(row.id)) as TrainingLibraryCourse | null
|
||||
if (updated) {
|
||||
const idx = items.value.findIndex((it) => it.id === updated.id)
|
||||
if (idx >= 0) items.value.splice(idx, 1, updated)
|
||||
}
|
||||
MessagePlugin.success(
|
||||
status === 'published'
|
||||
? `课程「${row.name}」已发布,可在培训中心「和信课程」目录查看`
|
||||
: `课程「${row.name}」已下线,已从培训中心「和信课程」目录撤回`,
|
||||
)
|
||||
MessagePlugin.success(`课程「${row.name}」已下线,已从培训中心「和信课程」目录撤回,不能再被培训计划选用/学习`)
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, status === 'published' ? '发布失败' : '下线失败'))
|
||||
MessagePlugin.error(apiErrorMessage(e, '下线失败'))
|
||||
}
|
||||
}
|
||||
|
||||
// 课件有无口径:已上传原始文件或已挂接知识库课件文档(名称登记不算,与发布校验同口径)
|
||||
const hasMaterial = (row: TrainingLibraryCourse) => Boolean(row.file_name || row.knowledge_id)
|
||||
|
||||
const onDownloadMaterial = async (row: TrainingLibraryCourse | null) => {
|
||||
// 课件下载(000164 多课件:mid 定位条目,缺省最新一条;列表「无课件」等单条
|
||||
// 场景由调用方省略 mid 走默认口径)
|
||||
const onDownloadMaterial = async (row: TrainingLibraryCourse | null, entry?: { mid?: string }) => {
|
||||
if (!row) return
|
||||
try {
|
||||
// getDown 直接返回 Blob(trainingTemplates 同款消费方式)
|
||||
const blob = await downloadCourseLibraryMaterial(row.id)
|
||||
const blob = await downloadCourseLibraryMaterial(row.id, entry?.mid || undefined)
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
@@ -980,13 +1131,14 @@ const materialUploading = ref(false)
|
||||
type MaterialSourceMode = 'upload' | 'kb'
|
||||
const materialSourceMode = ref<MaterialSourceMode>('upload')
|
||||
const materialFileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const materialFile = ref<File | null>(null)
|
||||
// 000164 多课件:一次可选择多个文件,逐个追加为课件条目(不替换既有课件)
|
||||
const materialFiles = ref<File[]>([])
|
||||
const materialKbDocId = ref('')
|
||||
|
||||
const materialColumns = [
|
||||
{ colKey: 'name', title: '课件名称', minWidth: 220 },
|
||||
{ colKey: 'size', title: '大小', width: 110 },
|
||||
{ colKey: 'source', title: '来源', width: 130 },
|
||||
{ colKey: 'source', title: '来源', width: 150 },
|
||||
{ colKey: 'op', title: '操作', width: 190 },
|
||||
]
|
||||
|
||||
@@ -996,21 +1148,37 @@ const fmtSize = (size: number) => {
|
||||
return `${size} B`
|
||||
}
|
||||
|
||||
// 抽屉内课件信息行:与列表「有」口径一致(文件或知识库文档任一存在)
|
||||
// 课件条目行(000164 多课件):courses.materials 逐条展示;
|
||||
// 存量行(未跑回填迁移,列表为空而主字段有课件)由主字段合成一条兜底
|
||||
const materialRows = computed(() => {
|
||||
const c = materialCourse.value
|
||||
if (!c || !hasMaterial(c)) return []
|
||||
return [
|
||||
{
|
||||
key: 'material',
|
||||
name: c.file_name || c.material_name || '知识库课件文档',
|
||||
size: c.file_size || 0,
|
||||
source: c.file_name ? '本地上传文件' : '知识库文档',
|
||||
},
|
||||
]
|
||||
if (!c) return []
|
||||
if (c.materials?.length) {
|
||||
return c.materials.map((m) => ({
|
||||
mid: m.mid,
|
||||
name: m.name,
|
||||
size: m.size || 0,
|
||||
source: m.origin === 'kb' ? '知识库文档' : m.knowledge_id ? '本地上传 · 已同步知识库' : '本地上传文件',
|
||||
}))
|
||||
}
|
||||
if (hasMaterial(c)) {
|
||||
return [
|
||||
{
|
||||
mid: '',
|
||||
name: c.file_name || c.material_name || '知识库课件文档',
|
||||
size: c.file_size || 0,
|
||||
source: c.file_name ? '本地上传文件' : '知识库文档',
|
||||
},
|
||||
]
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
// 列表行原位替换:课件变更回「待核验」等状态随接口响应同步到列表与抽屉
|
||||
// 抽屉内课件信息行:与列表「有」口径一致(文件或知识库文档任一存在)
|
||||
const hasMaterial = (row: TrainingLibraryCourse) =>
|
||||
Boolean(row.materials?.length || row.file_name || row.knowledge_id)
|
||||
|
||||
// 列表行原位替换:课件变更回「待审核」等状态随接口响应同步到列表与抽屉
|
||||
const replaceLibraryRow = (updated?: TrainingLibraryCourse | null) => {
|
||||
if (!updated) return
|
||||
const idx = items.value.findIndex((it) => it.id === updated.id)
|
||||
@@ -1023,7 +1191,7 @@ const openMaterialDrawer = (row: TrainingLibraryCourse) => {
|
||||
materialCourse.value = row
|
||||
materialVisible.value = true
|
||||
materialSourceMode.value = 'upload'
|
||||
materialFile.value = null
|
||||
materialFiles.value = []
|
||||
materialKbDocId.value = ''
|
||||
if (materialFileInputRef.value) materialFileInputRef.value.value = ''
|
||||
}
|
||||
@@ -1035,25 +1203,41 @@ const onMaterialModeChange = (mode: unknown) => {
|
||||
|
||||
const onMaterialPicked = (e: Event) => {
|
||||
const input = e.target as HTMLInputElement
|
||||
materialFile.value = input.files?.[0] || null
|
||||
materialFiles.value = Array.from(input.files || [])
|
||||
}
|
||||
|
||||
// 上传课件(000164 多课件):多文件逐个追加为课件条目,不替换既有课件;
|
||||
// 任一失败继续其余文件,结束按成功/失败汇总提示。
|
||||
const onUploadMaterial = async () => {
|
||||
const course = materialCourse.value
|
||||
const file = materialFile.value
|
||||
if (!course || !file) return
|
||||
const files = materialFiles.value
|
||||
if (!course || !files.length) return
|
||||
materialUploading.value = true
|
||||
let ok = 0
|
||||
let last: TrainingLibraryCourse | null | undefined
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
// 名称登记为空时后端以文件名兜底;文档类自动同步知识库「企业培训(课件)」
|
||||
const updated = unwrap<TrainingLibraryCourse>(await uploadCourseLibraryMaterial(course.id, fd))
|
||||
replaceLibraryRow(updated)
|
||||
materialFile.value = null
|
||||
if (materialFileInputRef.value) materialFileInputRef.value.value = ''
|
||||
MessagePlugin.success(`课件「${updated?.file_name || file.name}」已上传;课程回「待核验」,核验后方可发布`)
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '课件上传失败'))
|
||||
for (const file of files) {
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
// 名称登记为空时后端以文件名兜底;文档类自动同步知识库「企业培训(课件)」
|
||||
const updated = unwrap<TrainingLibraryCourse>(await uploadCourseLibraryMaterial(course.id, fd))
|
||||
last = updated
|
||||
ok += 1
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(`课件「${file.name}」上传失败:${apiErrorMessage(e, '请稍后重试')}`)
|
||||
}
|
||||
}
|
||||
if (last) replaceLibraryRow(last)
|
||||
if (ok) {
|
||||
materialFiles.value = []
|
||||
if (materialFileInputRef.value) materialFileInputRef.value.value = ''
|
||||
MessagePlugin.success(
|
||||
ok > 1
|
||||
? `已追加 ${ok} 个课件;课程回「待审核」,审核通过后自动发布`
|
||||
: `课件「${last?.file_name || ''}」已上传;课程回「待审核」,审核通过后自动发布`,
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
materialUploading.value = false
|
||||
}
|
||||
@@ -1070,7 +1254,7 @@ const onAttachMaterialKb = async () => {
|
||||
)
|
||||
replaceLibraryRow(updated)
|
||||
materialKbDocId.value = ''
|
||||
MessagePlugin.success(`课件「${updated?.file_name || doc.file_name}」已挂接;课程回「待核验」,核验后方可发布`)
|
||||
MessagePlugin.success(`课件「${updated?.file_name || doc.file_name}」已挂接;课程回「待审核」,审核通过后自动发布`)
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '课件挂接失败'))
|
||||
} finally {
|
||||
@@ -1078,13 +1262,14 @@ const onAttachMaterialKb = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 预览:取回 Blob 后新开页签展示(文件端点对安全类型 inline,浏览器按类型渲染;
|
||||
// 不可预览类型浏览器按附件处理,回退下载)
|
||||
const onPreviewMaterial = async () => {
|
||||
// 预览(000164:mid 定位课件条目,缺省最新一条):取回 Blob 后新开页签展示
|
||||
// (文件端点对安全类型 inline,浏览器按类型渲染;不可预览类型浏览器按附件
|
||||
// 处理,回退下载)
|
||||
const onPreviewMaterial = async (entry?: { mid?: string }) => {
|
||||
const course = materialCourse.value
|
||||
if (!course) return
|
||||
try {
|
||||
const blob = await downloadCourseLibraryMaterial(course.id)
|
||||
const blob = await downloadCourseLibraryMaterial(course.id, entry?.mid || undefined)
|
||||
const url = URL.createObjectURL(blob)
|
||||
window.open(url, '_blank')
|
||||
// 延迟回收对象 URL,留足新页签加载时间
|
||||
@@ -1094,13 +1279,16 @@ const onPreviewMaterial = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const onRemoveMaterial = async () => {
|
||||
// 移除课件条目(000164:mid 定位,缺省移除最新一条;存量兜底行 mid 为空走默认口径)
|
||||
const onRemoveMaterial = async (entry?: { mid?: string }) => {
|
||||
const course = materialCourse.value
|
||||
if (!course) return
|
||||
try {
|
||||
const updated = unwrap<TrainingLibraryCourse>(await removeCourseLibraryMaterial(course.id))
|
||||
const updated = unwrap<TrainingLibraryCourse>(
|
||||
await removeCourseLibraryMaterial(course.id, entry?.mid || undefined),
|
||||
)
|
||||
replaceLibraryRow(updated)
|
||||
MessagePlugin.success('课件已移除;课程回「待核验」,需重新上传课件后方可发布')
|
||||
MessagePlugin.success('课件已移除;课程回「待审核」,需重新上传课件并审核后才会发布')
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '课件移除失败'))
|
||||
}
|
||||
|
||||
@@ -315,13 +315,15 @@ const myDeptId = ref('')
|
||||
|
||||
// 本部门课程(000156):课程名称下拉仅列所属部门课程——新建按提报人部门,
|
||||
// 编辑按需求归属部门(人事代改他部门需求时同样联动);部门为空回退全部课程
|
||||
// (000163:已下线课程不能再被需求选用,存量需求行不受影响)
|
||||
const selectableCourses = computed(() => libraryCourses.value.filter((c) => c.publish_status !== 'offline'))
|
||||
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
|
||||
? selectableCourses.value.filter((c) => c.owner_dept_id === deptId)
|
||||
: selectableCourses.value
|
||||
})
|
||||
|
||||
const demandFormVisible = ref(false)
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
<img v-if="signQrUrl" :src="signQrUrl" class="sign-code-box__qr" alt="培训签到二维码" />
|
||||
<div class="sign-code-box__token">{{ signCode?.token || '尚未生成' }}</div>
|
||||
<div class="sign-code-box__meta" v-if="signCode">
|
||||
有效期至 {{ fmtTime(signCode.expire_at) }}
|
||||
<!-- 文案口径(测试反馈 2026-11-26):「二维码有效期至 HH:mm」,不展示年月日 -->
|
||||
二维码有效期至 {{ fmtClock(signCode.expire_at) }}
|
||||
<template v-if="signCode.geo_radius"> · 定位半径 {{ signCode.geo_radius }}m</template>
|
||||
</div>
|
||||
<!-- 二维码地址预检:非对外域名生成时当场提醒,避免学员扫码后企微报
|
||||
@@ -110,7 +111,7 @@
|
||||
<!-- 签到明细 -->
|
||||
<div class="records-header">
|
||||
<span class="records-header__title">签到明细</span>
|
||||
<t-button v-if="canReview && signCode" variant="outline" size="small" @click="proxyVisible = true">代扫码 / 补录</t-button>
|
||||
<t-button v-if="canReview && signCode" variant="outline" size="small" @click="proxyVisible = true">补录</t-button>
|
||||
</div>
|
||||
<t-table :data="pagedRecords" :columns="recordColumns" row-key="id" size="small" :loading="loading">
|
||||
<template #member="{ row }">{{ memberLabel(row.member_id) }}</template>
|
||||
@@ -130,8 +131,8 @@
|
||||
<!-- 共用分页(000163):默认每页 15 条 -->
|
||||
<TrainingPagination v-model:current="recordPage" v-model:page-size="recordPageSize" :total="recordTotal" />
|
||||
|
||||
<!-- 代扫码 / 补录:走同一防伪规则引擎,proxy 标记留痕 -->
|
||||
<t-dialog v-model:visible="proxyVisible" header="代扫码 / 现场补录" width="460">
|
||||
<!-- 补录:走同一防伪规则引擎,proxy 标记留痕 -->
|
||||
<t-dialog v-model:visible="proxyVisible" header="现场补录" width="460">
|
||||
<t-form label-width="90">
|
||||
<t-form-item label="学员" required>
|
||||
<t-select v-model="proxyMemberId" filterable placeholder="选择要补录的学员" style="width: 100%">
|
||||
@@ -202,7 +203,7 @@ import {
|
||||
type TrainingSignRecord,
|
||||
unwrap,
|
||||
} from '@/api/training'
|
||||
import { fmtBeijingTime, fmtBeijingTimeSec } from '@/utils/datetime'
|
||||
import { fmtBeijingClock, fmtBeijingTime, fmtBeijingTimeSec } from '@/utils/datetime'
|
||||
import TrainingPagination from './TrainingPagination.vue'
|
||||
import { useTrainingPager } from './useTrainingPager'
|
||||
|
||||
@@ -361,6 +362,8 @@ const flagText = (f: string) => ({ late: '迟到', outside: '定位异常', not_
|
||||
|
||||
const courseName = (courseId: string) => courses.value.find((c) => c.id === courseId)?.name || '课程'
|
||||
const fmtTime = (raw: string | null) => fmtBeijingTime(raw) || '—'
|
||||
// 签到码有效期只展示时分(测试反馈 2026-11-26:去掉年月日)
|
||||
const fmtClock = (raw: string | null) => fmtBeijingClock(raw) || '—'
|
||||
|
||||
const memberLabels = ref<Record<string, string>>({})
|
||||
const members = ref<TrainingMember[]>([])
|
||||
|
||||
Reference in new issue
Block a user