fix(培训): 完善培训相关细节!

This commit is contained in:
runny committed 2026-09-22 19:42:15 +08:00
1 parent 453d910364
commit ae882d5d04
8 files changed
+96 -16

No files matched your search

@@ -431,7 +431,13 @@ const compactSummary = computed(() => {
total: workspace.totalQuestionCount,
});
}
return workspace.isPassed ? t('chat.training.result.passTitle') : t('chat.training.result.failTitle');
// 通过标题按培训类型区分:出国规章培训为纯视频学习,通过文案不使用"新人培训考试"表述
if (workspace.isPassed) {
return workspace.isOverseasRegulationsTraining
? t('chat.training.result.overseasPassTitle')
: t('chat.training.result.passTitle');
}
return t('chat.training.result.failTitle');
});
const ruleItems = computed(() => ([
@@ -1189,14 +1195,15 @@ const currentSafetyStageText = computed(() => {
{{ workspace.isPassed ? $t('chat.training.result.passedTag') : $t('chat.training.result.failedTag') }}
</div>
<h3 class="mt-2.5 text-lg font-semibold text-primary md:text-xl">
{{ workspace.isPassed ? $t('chat.training.result.passTitle') : $t('chat.training.result.failTitle') }}
{{ workspace.isPassed ? (workspace.isOverseasRegulationsTraining ? $t('chat.training.result.overseasPassTitle') : $t('chat.training.result.passTitle')) : $t('chat.training.result.failTitle') }}
</h3>
<p class="mt-2 text-sm leading-6 text-secondary">
<!-- [RULE] 出国规章培训为纯视频学习(无考试),描述文案与考试语义不匹配,仅其他培训类型展示 -->
<p v-if="!workspace.isOverseasRegulationsTraining" class="mt-2 text-sm leading-6 text-secondary">
{{ workspace.isPassed ? $t('chat.training.result.passDescription') : $t('chat.training.result.failDescription', { passScore: workspace.passScore }) }}
</p>
</div>
<div class="grid grid-cols-2 gap-2 text-center">
<div v-if="!workspace.isOverseasRegulationsTraining" class="grid grid-cols-2 gap-2 text-center">
<div class="rounded-2xl bg-surface-soft px-4 py-2.5">
<div class="text-xs text-muted">{{ $t('chat.training.result.scoreLabel') }}</div>
<div class="text-xl font-semibold text-primary">{{ workspace.score }}</div>
@@ -1208,12 +1215,13 @@ const currentSafetyStageText = computed(() => {
</div>
</div>
<div class="mt-3 grid gap-2.5 md:grid-cols-3">
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
<!-- [RULE] 出国规章培训完成页仅保留与视频学习相关的完成日期,对错题数等考试统计一律隐藏 -->
<div class="mt-3 grid gap-2.5" :class="workspace.isOverseasRegulationsTraining ? '' : 'md:grid-cols-3'">
<div v-if="!workspace.isOverseasRegulationsTraining" class="rounded-2xl border border-default bg-surface-soft p-3.5">
<div class="text-xs text-muted">{{ $t('chat.training.result.correctCount') }}</div>
<div class="mt-1 text-lg font-semibold text-primary">{{ workspace.correctCount }}</div>
</div>
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
<div v-if="!workspace.isOverseasRegulationsTraining" class="rounded-2xl border border-default bg-surface-soft p-3.5">
<div class="text-xs text-muted">{{ $t('chat.training.result.wrongCount') }}</div>
<div class="mt-1 text-lg font-semibold text-primary">{{ workspace.wrongCount }}</div>
</div>
@@ -91,6 +91,18 @@ const OVERSEAS_REGULATIONS_TRAINING_TYPES = new Set([
const formatDate = (value: Date) => value.toISOString().slice(0, 10);
/**
* 将当前时刻格式化为北京时间(UTC+8)ISO 字符串,如 2026-09-22T18:47:33+08:00。
* 用途:精益培训"已观看"的本地即时回显必须与服务端展示口径(北京时间)一致;
* 此前用 toISOString()(UTC)回显,观看后立刻显示的时间比实际早 8 小时。
* 业务约束:带 +08:00 偏移,后端 save_completion 兜底入库前会归一为 UTC 存储。
*/
const formatBeijingIso = (value: Date) => {
const beijing = new Date(value.getTime() + (8 * 60 + value.getTimezoneOffset()) * 60000);
const pad = (num: number) => String(num).padStart(2, '0');
return `${beijing.getFullYear()}-${pad(beijing.getMonth() + 1)}-${pad(beijing.getDate())}T${pad(beijing.getHours())}:${pad(beijing.getMinutes())}:${pad(beijing.getSeconds())}+08:00`;
};
/**
* 按百分制计算当前答题得分。
* AI 触发时机:当题库题量改为后台可配置后,不能再假定“每题固定 5 分”,因此每次答题都要按当前题量重新折算分数。
@@ -908,7 +920,8 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
const markLeanVideoWatched = (taskId: number, resourceId: number) => {
const taskWatched = leanWatchedByTask.value[taskId] || {};
if (taskWatched[String(resourceId)]) return;
leanWatchedByTask.value = { ...leanWatchedByTask.value, [taskId]: { ...taskWatched, [String(resourceId)]: new Date().toISOString() } };
// 本地即时回显用北京时间,与服务端序列化口径一致;持久化失败时该值会经 save_completion 兜底入库(后端归一为 UTC)
leanWatchedByTask.value = { ...leanWatchedByTask.value, [taskId]: { ...taskWatched, [String(resourceId)]: formatBeijingIso(new Date()) } };
// 持久化失败不阻塞本地状态;下次刷新列表会以服务端记录为准,未持久化的视频需重新完整观看
void markMyLeanVideoWatched(taskId, resourceId).catch(() => {});
};
+1
View File
@@ -1140,6 +1140,7 @@
"passedTag": "Passed",
"failedTag": "Retake required",
"passTitle": "Congratulations, you passed the onboarding exam",
"overseasPassTitle": "Congratulations, you passed the overseas regulations training",
"failTitle": "This attempt did not meet the requirement",
"passDescription": "You passed this exam successfully. The score is automatically synced to the HR console and saved into the training record.",
"failDescription": "According to HR rules, any score below {passScore} requires a full retake until the learner passes.",
+1
View File
@@ -1140,6 +1140,7 @@
"passedTag": "ผ่านแล้ว",
"failedTag": "ต้องสอบใหม่",
"passTitle": "ยินดีด้วย คุณผ่านการสอบอบรมพนักงานใหม่แล้ว",
"overseasPassTitle": "ยินดีด้วย คุณผ่านการอบรมระเบียบการไปต่างประเทศแล้ว",
"failTitle": "การสอบครั้งนี้ยังไม่ผ่านเกณฑ์",
"passDescription": "คุณผ่านการสอบครั้งนี้แล้ว ระบบจะซิงก์คะแนนไปยังหน้าจอ HR และบันทึกลงประวัติการอบรมโดยอัตโนมัติ",
"failDescription": "ตามกฎของ HR หากได้ต่ำกว่า {passScore} คะแนน ต้องสอบใหม่จนกว่าจะผ่าน",
+1
View File
@@ -1174,6 +1174,7 @@
"passedTag": "已通过",
"failedTag": "需补考",
"passTitle": "恭喜,你已通过新人培训考试",
"overseasPassTitle": "恭喜,你已通过出国规章培训",
"failTitle": "本次考试未达标,需要重新考试",
"passDescription": "您已顺利通过本次考试,成绩会自动同步到 HR 管理端并计入培训记录。",
"failDescription": "按照 HR 规则,未达到 {passScore} 分必须重新考试,直到最终通过为止。",
+1
View File
@@ -1140,6 +1140,7 @@
"passedTag": "已通過",
"failedTag": "需補考",
"passTitle": "恭喜,你已通過新人培訓考試",
"overseasPassTitle": "恭喜,你已通過出國規章培訓",
"failTitle": "本次考試未達標,需要重新考試",
"passDescription": "你已順利通過本次考試,成績會自動同步到 HR 管理端並記入培訓紀錄。",
"failDescription": "依照 HR 規則,低於 {passScore} 分必須重新考試,直到最終通過。",