fix(我的培训):「我的培训」的“与我相关”判定(学习任务/讲师/部门范围)不含「参加人员」——线下课不生成学习任务,参加人员只落场次名单与文案,刘义亮(资讯组)被课程部门范围(人事课)拦在页签外。
deploy-hxtesting / build-and-deploy (push) Successful in 20m39s

This commit is contained in:
runny committed 2026-11-24 21:22:27 +08:00
1 parent 448fbcdaff
commit 11450bdb96
8 files changed
+167 -2

No files matched your search

@@ -152,6 +152,7 @@ import {
getMyProfile,
listCourses,
listCourseLibrary,
listMyEnrolledCourseIds,
listMyExamRecords,
listMyLearningTasks,
listSessions,
@@ -241,6 +242,8 @@ const lecturerCourses = ref<TrainingCourse[]>([])
const myProfile = ref<TrainingMember | null>(null)
const myTasks = ref<LearningTask[]>([])
const sessions = ref<TrainingCourseSession[]>([])
// 我经场次学员名单报名的课程 id 集合(「我参加」判定;失败回退空集不阻断)
const myEnrolledCourseIds = ref<Set<string>>(new Set())
// 课程管理资产(000154):「和信课程」目录 = 课程管理已发布且部门范围覆盖查看人的课程
const libraryItems = ref<TrainingLibraryCourse[]>([])
// 我的考试记录(000154):「我的考试」页签数据源
@@ -311,13 +314,16 @@ const myTaskByCourse = computed(() => {
// 「我的课程」相关性口径(与后端推送口径一致):
// ① 我有该课学习任务(线上必修按部门推送);② 我是该课讲师;
// ③ 课程部门范围覆盖我(dept_ids 为空 = 全员可见,非空需包含我的部门)。
// ③ 课程部门范围覆盖我(dept_ids 为空 = 全员可见,非空需包含我的部门);
// ④ 我是该课场次参加人员(学员名单接口,线下课参加人员由此可见——此前参加
// 人员只落名单与文案,不进任何"与我相关"判定,被设为参加人员却看不到课)。
// 讲师匹配用平台用户 id(user_id)——与后端 course.LecturerID == callerUserID 同口径。
const myUserId = computed(() => myProfile.value?.user_id || '')
const isMyTeaching = (c: TrainingCourse) => !!myUserId.value && c.lecturer_id === myUserId.value
const isMyCourse = (c: TrainingCourse) => {
if (myTaskByCourse.value.has(c.id)) return true
if (isMyTeaching(c)) return true
if (myEnrolledCourseIds.value.has(c.id)) return true
const scope = c.dept_ids || []
if (!scope.length) return true
return !!myProfile.value && scope.includes(myProfile.value.dept_id)
@@ -546,7 +552,7 @@ const loadAll = async () => {
// 讲师/管理角色额外拉维护视角课程(纯讲师=自己名下含草稿;管理=全部,下方按讲师 id 过滤),
// 供「我的培训」展示我主讲(含未发布)课程与「待维护」统计;纯学员无此视角,跳过。
const needMaintainView = props.admin || props.roles.some((r) => ['hr', 'supervisor', 'exec', 'lecturer'].includes(r))
const [c, t, s, me, lc, lib, exams] = await Promise.all([
const [c, t, s, me, lc, lib, exams, enrolled] = await Promise.all([
// 学员目录视图:scope=student 统一走已发布课程口径(讲师账号的学习视角不受课程维护范围影响)
listCourses({ page_size: 100, scope: 'student' }),
listMyLearningTasks().catch(() => null),
@@ -558,6 +564,8 @@ const loadAll = async () => {
listCourseLibrary({ page_size: 500, scope: 'catalog' }).catch(() => null),
// 我的考试记录(000154)
listMyExamRecords().catch(() => null),
// 我经场次学员名单报名的课程 id(「我参加」判定;旧后端无此接口时回退空集)
listMyEnrolledCourseIds().catch(() => null),
])
courses.value = unwrap(c)?.items || []
myTasks.value = (t && unwrap(t)) || []
@@ -566,6 +574,7 @@ const loadAll = async () => {
lecturerCourses.value = (lc && unwrap(lc)?.items) || []
libraryItems.value = (lib && unwrap(lib)?.items) || []
myExamRecords.value = (exams && unwrap(exams)) || []
myEnrolledCourseIds.value = new Set((enrolled && unwrap(enrolled)) || [])
} finally {
loading.value = false
}