feat(安全培训): 新增员工安全培训相关功能
This commit is contained in:
1 parent
cbc3cb959f
commit
8e5c57790c
50 files changed
+3769
-87
No files matched your search
@@ -20,11 +20,19 @@ import {
|
||||
RefreshCcw,
|
||||
ShieldCheck,
|
||||
Target,
|
||||
User,
|
||||
FileText,
|
||||
Video,
|
||||
Lock,
|
||||
XCircle,
|
||||
} from 'lucide-vue-next';
|
||||
import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWorkspace';
|
||||
import FilePreviewModal from '@/shared/components/FilePreviewModal.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { resolveTrainingExamPdfGuide, type TrainingGuideLike } from '@/features/chat/training/trainingWorkspace.utils';
|
||||
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
|
||||
const props = defineProps<{
|
||||
currentAgent: Record<string, unknown> | null;
|
||||
currentUser: Record<string, unknown> | null;
|
||||
@@ -39,9 +47,13 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const workspace = reactive(props.training);
|
||||
|
||||
const previewFile = ref<{ name: string; url: string; actualExt?: string } | null>(null);
|
||||
const showFilePreview = ref(false);
|
||||
|
||||
// 将 workspace 内部控制弹窗的状态同步给组件本地变量(如果需要,或者直接用 workspace.showVideoModal)
|
||||
const showVideoModal = computed({
|
||||
get: () => workspace.showVideoModal,
|
||||
@@ -82,14 +94,14 @@ const handleVideoSeeking = (e: Event) => {
|
||||
};
|
||||
|
||||
const handleVideoEnded = () => {
|
||||
showVideoModal.value = false;
|
||||
workspace.markVideoCompleted();
|
||||
workspace.showVideoModal = false;
|
||||
workspace.stopMaterialTimer();
|
||||
};
|
||||
|
||||
const reportVideoDebugEvent = (event: Event) => {
|
||||
const video = event.target as HTMLVideoElement;
|
||||
// #region debug-point A-E:ios-video-runtime
|
||||
fetch('http://192.168.65.184:7777/event', { method: 'POST', body: JSON.stringify({ sessionId: 'ios-training-video', runId: 'pre-fix', hypothesisId: 'A-E', location: 'TrainingWorkspacePanel.vue:video', msg: '[DEBUG] iOS training video runtime event', data: { event: event.type, src: video.currentSrc || workspace.videoUrl, userAgent: navigator.userAgent, networkState: video.networkState, readyState: video.readyState, mediaErrorCode: video.error?.code ?? null, mediaErrorMessage: video.error?.message ?? null, duration: Number.isFinite(video.duration) ? video.duration : null, currentTime: video.currentTime }, ts: Date.now() }) }).catch(() => {});
|
||||
fetch('http://192.168.65.184:7777/event', { method: 'POST', body: JSON.stringify({ sessionId: 'ios-training-video', runId: 'pre-fix', hypothesisId: 'A-E', location: 'TrainingWorkspacePanel.vue:video', msg: '[DEBUG] iOS training video runtime event', data: { event: event.type, src: video.currentSrc || currentPreviewVideoUrl.value || workspace.videoUrl, userAgent: navigator.userAgent, networkState: video.networkState, readyState: video.readyState, mediaErrorCode: video.error?.code ?? null, mediaErrorMessage: video.error?.message ?? null, duration: Number.isFinite(video.duration) ? video.duration : null, currentTime: video.currentTime }, ts: Date.now() }) }).catch(() => {});
|
||||
// #endregion
|
||||
};
|
||||
|
||||
@@ -227,6 +239,50 @@ const examQuestionItems = computed(() => Array.from({ length: workspace.totalQue
|
||||
};
|
||||
}));
|
||||
const canNavigateExamQuestions = computed(() => workspace.stage === 'exam');
|
||||
const isMaterialCompleted = (material: any) => {
|
||||
const resourceProgress = workspace.safetyProgress.resource_progress || {};
|
||||
const record = resourceProgress[material.id];
|
||||
return record ? !!record.completed : false;
|
||||
};
|
||||
|
||||
const currentPreviewVideoUrl = ref('');
|
||||
|
||||
const handleMaterialClick = (material: any) => {
|
||||
const url = material.resource?.fileUrl;
|
||||
if (!url) {
|
||||
msg.warning('该资料暂无可预览的文件');
|
||||
return;
|
||||
}
|
||||
|
||||
if (material.resource?.fileType === 'video') {
|
||||
workspace.showVideoModal = true;
|
||||
currentPreviewVideoUrl.value = url;
|
||||
// 当点击视频资料时,我们应该记录正在观看的资源ID,以便后续更新进度
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
} else {
|
||||
previewFile.value = {
|
||||
name: material.title || material.resource?.fileName || '资料预览',
|
||||
url: url,
|
||||
actualExt: material.resource?.fileType,
|
||||
};
|
||||
showFilePreview.value = true;
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
}
|
||||
workspace.startMaterialTimer(material.id);
|
||||
};
|
||||
|
||||
const handlePreviewClose = (val: boolean) => {
|
||||
showFilePreview.value = val;
|
||||
if (!val) {
|
||||
workspace.stopMaterialTimer();
|
||||
}
|
||||
};
|
||||
|
||||
const handleVideoModalClose = () => {
|
||||
workspace.showVideoModal = false;
|
||||
currentPreviewVideoUrl.value = '';
|
||||
workspace.stopMaterialTimer();
|
||||
};
|
||||
const jumpToExamQuestion = (index: number) => {
|
||||
if (!canNavigateExamQuestions.value) return;
|
||||
workspace.syncExamQuestionIndex(index);
|
||||
@@ -239,6 +295,21 @@ const handleStageCardClick = (stageKey: string) => {
|
||||
if (!canSwitchToStage(stageKey)) return;
|
||||
workspace.stage = stageKey as typeof workspace.stage;
|
||||
};
|
||||
|
||||
// --- 安全培训相关计算属性 ---
|
||||
const safetySteps = computed(() => workspace.safetyStepItems);
|
||||
|
||||
const currentSafetySummary = computed(() => {
|
||||
return workspace.publishedSafetySummary;
|
||||
});
|
||||
|
||||
const currentSafetyStageText = computed(() => {
|
||||
if (workspace.safetyViewStage === 'company') return t('chat.training.safety.steps.company');
|
||||
if (workspace.safetyViewStage === 'department') return t('chat.training.safety.steps.department');
|
||||
if (workspace.safetyViewStage === 'team') return t('chat.training.safety.steps.team');
|
||||
if (workspace.safetyViewStage === 'exam') return t('chat.training.safety.steps.exam');
|
||||
return t('chat.training.steps.result');
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -412,7 +483,38 @@ const handleStageCardClick = (stageKey: string) => {
|
||||
</div>
|
||||
|
||||
<div v-if="!isCompactMode && workspace.activeView === 'learner'" :class="learnerWorkspaceGridClass">
|
||||
<div :class="learnerWorkspaceMainClass">
|
||||
<!-- 增加顶部 Tab 切换:入职培训 / 安全培训 -->
|
||||
<div class="col-span-full mb-1">
|
||||
<div class="inline-flex rounded-xl border border-default bg-surface-soft p-1">
|
||||
<button
|
||||
class="flex items-center gap-2 rounded-lg px-6 py-2 text-sm font-medium transition"
|
||||
:class="workspace.learnerTab === 'onboarding' ? 'bg-white text-brand-700 shadow-sm border border-brand-200' : 'text-secondary hover:text-primary'"
|
||||
@click="workspace.learnerTab = 'onboarding'"
|
||||
>
|
||||
<User class="h-4 w-4" />
|
||||
{{ $t('chat.training.safety.tabs.onboarding') }}
|
||||
</button>
|
||||
<button
|
||||
class="flex items-center gap-2 rounded-lg px-6 py-2 text-sm font-medium transition"
|
||||
:class="workspace.learnerTab === 'safety' ? 'bg-white text-brand-700 shadow-sm border border-brand-200' : 'text-secondary hover:text-primary'"
|
||||
@click="workspace.learnerTab = 'safety'"
|
||||
>
|
||||
<ShieldCheck class="h-4 w-4" />
|
||||
{{ $t('chat.training.safety.tabs.safety') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="workspace.trainingConfigLoading" class="col-span-full rounded-2xl border border-default bg-white px-6 py-16 text-center text-secondary">
|
||||
{{ $t('chat.training.noContent.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!workspace.hasPublishedTrainingConfig" class="col-span-full rounded-2xl border border-dashed border-brand-200 bg-white px-6 py-16 text-center text-secondary">
|
||||
<FileText class="mx-auto h-10 w-10 text-brand-300" />
|
||||
<div class="mt-3 text-base font-semibold text-primary">{{ $t('chat.training.noContent.title') }}</div>
|
||||
<div class="mt-1 text-sm">{{ $t('chat.training.noContent.description') }}</div>
|
||||
</div>
|
||||
<template v-else-if="workspace.learnerTab === 'onboarding'">
|
||||
<div :class="learnerWorkspaceMainClass">
|
||||
<div :class="progressCardClass">
|
||||
<div class="flex flex-col gap-1.5 lg:flex-row lg:items-start lg:justify-between">
|
||||
<div>
|
||||
@@ -666,8 +768,39 @@ const handleStageCardClick = (stageKey: string) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="min-w-0 md:sticky md:top-3 md:self-start">
|
||||
<div :class="questionNavPanelClass">
|
||||
<div class="min-w-0 md:sticky md:top-3 md:self-start space-y-4">
|
||||
<!-- 流程进度面板 (仅在非考试阶段展示) -->
|
||||
<div v-if="workspace.stage !== 'exam' && workspace.stage !== 'result'" :class="questionNavPanelClass">
|
||||
<div class="flex items-center gap-2 mb-3">
|
||||
<Target class="h-4 w-4 text-brand-600" />
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.progressLabel') }}</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="(item, index) in stageItems"
|
||||
:key="item.key"
|
||||
class="flex items-center gap-3 p-2 rounded-lg border transition"
|
||||
:class="[
|
||||
stageStep > index + 1 ? 'border-emerald-200 bg-emerald-50/50' :
|
||||
stageStep === index + 1 ? 'border-brand-300 bg-brand-50' :
|
||||
'border-slate-100 bg-slate-50/50 opacity-70'
|
||||
]"
|
||||
>
|
||||
<div class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full"
|
||||
:class="stageStep > index + 1 ? 'bg-emerald-500 text-white' : stageStep === index + 1 ? 'bg-brand-500 text-white shadow-sm' : 'bg-slate-200 text-slate-400'"
|
||||
>
|
||||
<CheckCircle2 v-if="stageStep > index + 1" class="h-4 w-4" />
|
||||
<span v-else class="text-xs font-bold">{{ index + 1 }}</span>
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="text-xs font-semibold" :class="stageStep === index + 1 ? 'text-brand-700' : 'text-slate-700'">{{ $t(item.label) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 考试题目面板 (在考试或结果阶段展示) -->
|
||||
<div v-else :class="questionNavPanelClass">
|
||||
<div class="flex items-center gap-2">
|
||||
<ClipboardCheck class="h-4 w-4 text-brand-600" />
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.examQuestionCard.title') }}</div>
|
||||
@@ -709,6 +842,335 @@ const handleStageCardClick = (stageKey: string) => {
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 安全培训视图 -->
|
||||
<template v-else>
|
||||
<div :class="learnerWorkspaceMainClass">
|
||||
<!-- 进度卡片 -->
|
||||
<div :class="progressCardClass">
|
||||
<div class="flex flex-col gap-1.5 lg:flex-row lg:items-start lg:justify-between">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-brand-600">
|
||||
{{ $t('chat.training.safety.progressTitle') }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-[11px] leading-4.5 text-secondary md:text-xs">
|
||||
{{ $t('chat.training.safety.progressHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-2.5 py-1 text-center">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.progressPercent') }}</div>
|
||||
<div class="text-base font-semibold leading-none text-primary">{{ workspace.safetyProgressPercent }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-2 grid grid-cols-2 gap-1 lg:grid-cols-4">
|
||||
<div
|
||||
v-for="step in safetySteps"
|
||||
:key="step.id"
|
||||
class="cursor-pointer rounded-xl border px-2 py-1.5 transition"
|
||||
:class="[
|
||||
step.status === 'completed' ? 'border-emerald-200 bg-emerald-50' :
|
||||
step.status === 'active' ? 'border-brand-500 bg-brand-500 text-white shadow-sm' :
|
||||
'border-default bg-surface-soft/70 opacity-60'
|
||||
]"
|
||||
@click="step.status !== 'locked' ? workspace.setSafetyStage(step.id as any) : null"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<div
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full"
|
||||
:class="step.status === 'completed' ? 'bg-emerald-500 text-white' : step.status === 'active' ? 'bg-white text-brand-600' : 'bg-white text-muted'"
|
||||
>
|
||||
<CheckCircle2 v-if="step.status === 'completed'" class="h-4 w-4" />
|
||||
<PlayCircle v-else-if="step.id !== 'exam'" class="h-4 w-4" />
|
||||
<Lock v-else-if="step.status === 'locked'" class="h-3 w-3" />
|
||||
<ClipboardCheck v-else class="h-4 w-4" />
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<div class="whitespace-normal text-[12px] font-medium leading-4" :class="step.status === 'active' ? 'text-white' : 'text-primary'">{{ step.label }}</div>
|
||||
<div class="text-[10px] font-medium mt-0.5" :class="step.status === 'active' ? 'text-white/80' : 'text-secondary'">
|
||||
<span v-if="step.status === 'completed'">{{ $t('chat.training.safety.stepStatus.completed') }}</span>
|
||||
<span v-else-if="step.status === 'active' && step.id !== 'exam'">{{ $t('chat.training.safety.stepStatus.watchVideo') }}</span>
|
||||
<span v-else-if="step.id === 'exam'">{{ $t('chat.training.safety.stepStatus.examReq') }}</span>
|
||||
<span v-else>{{ $t('chat.training.safety.stepStatus.pending') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<div v-if="workspace.safetyViewStage !== 'exam' && workspace.safetyViewStage !== 'result'" class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<span class="inline-flex rounded-md bg-amber-500 px-2 py-0.5 text-xs font-semibold text-white">
|
||||
{{ currentSafetyStageText }}
|
||||
</span>
|
||||
<span class="ml-2 text-base font-semibold text-primary">{{ $t('chat.training.safety.videoPanelSubtitle') }}</span>
|
||||
</div>
|
||||
<div class="text-xs font-medium text-amber-500">
|
||||
{{ $t('chat.training.safety.videoPanelPassLine') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<div class="text-sm font-semibold text-primary mb-3">{{ $t('chat.training.safety.materialsTitle') }}</div>
|
||||
<ul v-if="workspace.publishedTrainingMaterials.length" class="space-y-2">
|
||||
<li v-for="material in workspace.publishedTrainingMaterials" :key="material.id || `${material.resourceType}-${material.sortOrder}`" class="flex items-center justify-between gap-3 rounded-xl border border-slate-100 bg-slate-50 px-3 py-2.5 cursor-pointer hover:bg-slate-100 transition" @click="handleMaterialClick(material)">
|
||||
<div class="flex min-w-0 items-center gap-2 text-sm font-medium text-primary hover:text-brand-600">
|
||||
<Video v-if="material.resource?.fileType === 'video'" class="h-4 w-4 text-brand-500" />
|
||||
<FileText v-else class="h-4 w-4 text-slate-400" />
|
||||
<span class="truncate">{{ material.title || material.resource?.fileName || $t('chat.training.safety.materials.m2') }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col items-end gap-1">
|
||||
<span class="text-xs text-secondary">{{ currentSafetyStageText }}</span>
|
||||
<span v-if="material.requiredDuration" class="text-xs font-semibold" :class="isMaterialCompleted(material) ? 'text-emerald-500' : 'text-amber-500'">所需时间: {{ material.requiredDuration }} 分钟 ({{ isMaterialCompleted(material) ? '已完成' : '未完成' }})</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="workspace.safetyViewStage === 'exam' && workspace.currentQuestion" :class="examPanelClass">
|
||||
<div class="flex flex-col gap-2.5 md:flex-row md:items-center md:justify-between">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-brand-600">
|
||||
{{ $t('chat.training.safety.steps.exam') }}
|
||||
</div>
|
||||
<h3 class="mt-1 text-base font-semibold text-primary md:text-lg">
|
||||
{{ $t('chat.training.exam.questionCounter', { current: workspace.currentQuestionNumber, total: workspace.totalQuestionCount }) }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-1.5 text-xs text-secondary md:text-sm">
|
||||
<div class="rounded-xl bg-surface-soft px-2.5 py-1.5">
|
||||
{{ $t('chat.training.exam.currentScore', { score: workspace.score }) }}
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-2.5 py-1.5">
|
||||
{{ $t('chat.training.exam.passLine', { passScore: workspace.passScore }) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 rounded-2xl border border-brand-100 bg-brand-50/40 p-3">
|
||||
<div class="text-[15px] font-semibold leading-6 text-primary md:text-base">
|
||||
{{ workspace.currentQuestion.prompt }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-2.5 grid gap-2">
|
||||
<button
|
||||
v-for="option in workspace.currentQuestion.options"
|
||||
:key="option.id"
|
||||
type="button"
|
||||
class="rounded-2xl border px-3.5 py-2 text-left text-sm leading-5 transition"
|
||||
:class="[
|
||||
workspace.selectedOptionId === option.id
|
||||
? workspace.answerLocked
|
||||
? option.id === workspace.currentQuestion.answer
|
||||
? 'border-emerald-300 bg-emerald-50 text-emerald-700'
|
||||
: 'border-red-300 bg-red-50 text-red-700'
|
||||
: 'border-brand-300 bg-brand-50 text-brand-700'
|
||||
: workspace.answerLocked && option.id === workspace.currentQuestion.answer
|
||||
? 'border-emerald-300 bg-emerald-50 text-emerald-700'
|
||||
: 'border-default bg-white text-secondary hover:border-brand-200 hover:bg-brand-50/40',
|
||||
]"
|
||||
@click="workspace.selectAnswer(option.id)"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<span>{{ option.label }}</span>
|
||||
<CheckCircle2
|
||||
v-if="workspace.answerLocked && option.id === workspace.currentQuestion.answer"
|
||||
class="mt-0.5 h-4 w-4 shrink-0 text-emerald-500"
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="workspace.answerLocked"
|
||||
class="mt-3 rounded-2xl border p-3"
|
||||
:class="workspace.currentFeedbackCorrect ? 'border-emerald-200 bg-emerald-50/70' : 'border-red-200 bg-red-50/70'"
|
||||
>
|
||||
<div class="flex items-center gap-2 text-sm font-semibold" :class="workspace.currentFeedbackCorrect ? 'text-emerald-700' : 'text-red-700'">
|
||||
<CheckCircle2 v-if="workspace.currentFeedbackCorrect" class="h-4 w-4" />
|
||||
<XCircle v-else class="h-4 w-4" />
|
||||
{{ workspace.currentFeedbackCorrect ? $t('chat.training.exam.correctFeedback') : $t('chat.training.exam.wrongFeedback') }}
|
||||
</div>
|
||||
<div class="mt-2 text-sm leading-6 text-secondary">
|
||||
{{ $t('chat.training.exam.selectedAnswer', { answer: currentAnswerLabel || '--' }) }}
|
||||
</div>
|
||||
<div class="mt-1 text-sm leading-6 text-secondary">
|
||||
{{ $t('chat.training.exam.correctAnswer', { answer: workspace.currentQuestion.options?.find((item) => item.id === workspace.currentQuestion?.answer)?.label || '--' }) }}
|
||||
</div>
|
||||
<div class="mt-2 text-sm leading-6 text-secondary">
|
||||
{{ workspace.currentQuestion.explanation }}
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-brand-700"
|
||||
@click="workspace.examReadyToSubmit ? workspace.submitExam() : workspace.moveToNextQuestion()"
|
||||
>
|
||||
<ClipboardCheck class="h-4 w-4" />
|
||||
{{
|
||||
workspace.examReadyToSubmit
|
||||
? $t('chat.training.exam.submitPaper')
|
||||
: $t('chat.training.exam.nextQuestion')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
||||
<div>
|
||||
<div class="inline-flex items-center gap-2 rounded-full px-3 py-1 text-xs font-semibold"
|
||||
:class="workspace.isPassed ? 'bg-emerald-50 text-emerald-700' : 'bg-amber-50 text-amber-700'"
|
||||
>
|
||||
<ShieldCheck class="h-3.5 w-3.5" />
|
||||
{{ 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') }}
|
||||
</h3>
|
||||
<p 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 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>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-surface-soft px-4 py-2.5">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.result.attemptsLabel') }}</div>
|
||||
<div class="text-xl font-semibold text-primary">{{ workspace.attemptCount }}</div>
|
||||
</div>
|
||||
</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">
|
||||
<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 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>
|
||||
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.result.completionDate') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold text-primary">{{ workspace.completionDate || '--' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-wrap gap-2.5">
|
||||
<button
|
||||
v-if="!workspace.isPassed"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-brand-700"
|
||||
@click="workspace.restartExam"
|
||||
>
|
||||
<RefreshCcw class="h-4 w-4" />
|
||||
{{ $t('chat.training.result.retryExam') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="min-w-0 md:sticky md:top-3 md:self-start space-y-4">
|
||||
<!-- 流程进度面板 (仅在非考试阶段展示) -->
|
||||
<div v-if="workspace.safetyViewStage !== 'exam' && workspace.safetyViewStage !== 'result'" :class="questionNavPanelClass">
|
||||
<div class="flex items-center gap-2 mb-3">
|
||||
<Target class="h-4 w-4 text-brand-600" />
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.safety.progressTitle') }}</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="(step, index) in safetySteps"
|
||||
:key="step.id"
|
||||
class="flex items-center gap-3 p-2 rounded-lg border transition"
|
||||
:class="[
|
||||
step.status === 'completed' ? 'border-emerald-200 bg-emerald-50/50' :
|
||||
step.status === 'active' ? 'border-brand-300 bg-brand-50' :
|
||||
'border-slate-100 bg-slate-50/50 opacity-70'
|
||||
]"
|
||||
>
|
||||
<div class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full"
|
||||
:class="step.status === 'completed' ? 'bg-emerald-500 text-white' : step.status === 'active' ? 'bg-brand-500 text-white shadow-sm' : 'bg-slate-200 text-slate-400'"
|
||||
>
|
||||
<CheckCircle2 v-if="step.status === 'completed'" class="h-4 w-4" />
|
||||
<span v-else class="text-xs font-bold">{{ index + 1 }}</span>
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="text-xs font-semibold" :class="step.status === 'active' ? 'text-brand-700' : 'text-slate-700'">{{ step.label }}</div>
|
||||
<div class="text-[10px] text-slate-500 mt-0.5">
|
||||
<span v-if="step.status === 'completed'">{{ $t('chat.training.safety.stepStatus.completed') }}</span>
|
||||
<span v-else-if="step.status === 'active' && step.id !== 'exam'">{{ $t('chat.training.safety.stepStatus.watchVideo') }}</span>
|
||||
<span v-else-if="step.id === 'exam'">{{ $t('chat.training.safety.stepStatus.examReq') }}</span>
|
||||
<span v-else>{{ $t('chat.training.safety.stepStatus.pending') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 考试题目面板 (在考试阶段或结果阶段展示) -->
|
||||
<div v-else :class="questionNavPanelClass">
|
||||
<div class="flex items-center gap-2">
|
||||
<ClipboardCheck class="h-4 w-4 text-brand-600" />
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.examQuestionCard.title') }}</div>
|
||||
</div>
|
||||
<div class="mt-1.5 text-[11px] leading-4.5 text-secondary">
|
||||
{{ $t('chat.training.examQuestionCard.hint') }}
|
||||
</div>
|
||||
<div :class="questionNavGridClass">
|
||||
<button
|
||||
v-for="item in examQuestionItems"
|
||||
:key="item.index"
|
||||
type="button"
|
||||
:class="[
|
||||
questionNavButtonClass,
|
||||
item.status === 'active'
|
||||
? 'border-brand-500 bg-brand-600 text-white shadow-sm'
|
||||
: item.status === 'correct'
|
||||
? 'border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100'
|
||||
: item.status === 'wrong'
|
||||
? 'border-red-200 bg-red-50 text-red-700 hover:bg-red-100'
|
||||
: 'border-default bg-surface-soft text-muted hover:border-slate-300 hover:bg-slate-100',
|
||||
!canNavigateExamQuestions ? 'cursor-not-allowed opacity-80' : '',
|
||||
]"
|
||||
:disabled="!canNavigateExamQuestions"
|
||||
@click="jumpToExamQuestion(item.index)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="my-2.5 h-px bg-slate-100" />
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.rules.title') }}</div>
|
||||
<ul class="mt-1.5 grid gap-1 text-[11px] leading-4.5 text-secondary">
|
||||
<li v-for="rule in ruleItems" :key="rule" class="flex gap-2">
|
||||
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
|
||||
<span>{{ rule }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- 培训总结 -->
|
||||
<div v-if="currentSafetySummary && currentSafetySummary.length > 0" :class="questionNavPanelClass" class="bg-amber-50/50 border-amber-100">
|
||||
<div class="text-sm font-semibold text-amber-900 mb-2">{{ $t('chat.training.safety.summaryTitle') }}</div>
|
||||
<ul class="space-y-1.5 text-[11px] leading-4.5 text-amber-800/80">
|
||||
<li v-for="(point, idx) in currentSafetySummary" :key="idx" class="flex gap-1.5">
|
||||
<span class="mt-1.5 h-1 w-1 shrink-0 rounded-full bg-amber-400"></span>
|
||||
<span>{{ point }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!isCompactMode" class="space-y-4 p-4 md:p-5">
|
||||
@@ -747,7 +1209,7 @@ const handleStageCardClick = (stageKey: string) => {
|
||||
|
||||
<div class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,1fr)_auto] xl:items-center">
|
||||
<div class="grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto] xl:items-center">
|
||||
<label>
|
||||
<input
|
||||
v-model="workspace.hrKeyword"
|
||||
@@ -756,6 +1218,16 @@ const handleStageCardClick = (stageKey: string) => {
|
||||
:placeholder="$t('chat.training.hr.filters.keywordPlaceholder')"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<select
|
||||
v-model="workspace.hrTypeFilter"
|
||||
class="w-full rounded-xl border border-default bg-surface px-3 py-2.5 text-sm text-primary outline-none transition focus:border-brand-300"
|
||||
>
|
||||
<option value="all">{{ $t('chat.training.hr.filters.allTypes') }}</option>
|
||||
<option value="onboarding">{{ $t('chat.training.hr.filters.typeOnboarding') }}</option>
|
||||
<option value="safety">{{ $t('chat.training.hr.filters.typeSafety') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<select
|
||||
v-model="workspace.hrStatusFilter"
|
||||
@@ -840,9 +1312,9 @@ const handleStageCardClick = (stageKey: string) => {
|
||||
</section>
|
||||
|
||||
<Teleport to="body">
|
||||
<div v-if="showVideoModal" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="showVideoModal = false">
|
||||
<div v-if="workspace.showVideoModal" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="handleVideoModalClose">
|
||||
<div class="relative w-full max-w-4xl overflow-hidden rounded-3xl bg-black shadow-2xl">
|
||||
<button @click="showVideoModal = false" class="absolute top-4 right-4 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20 transition backdrop-blur-md">
|
||||
<button @click="handleVideoModalClose" class="absolute top-4 right-4 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20 transition backdrop-blur-md">
|
||||
<XCircle class="h-6 w-6" />
|
||||
</button>
|
||||
<div class="aspect-video bg-black">
|
||||
@@ -863,11 +1335,18 @@ const handleStageCardClick = (stageKey: string) => {
|
||||
@seeking="handleVideoSeeking"
|
||||
@ended="handleVideoEnded"
|
||||
>
|
||||
<source :src="workspace.videoUrl" type="video/mp4">
|
||||
<source :src="currentPreviewVideoUrl || workspace.videoUrl" type="video/mp4">
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<FilePreviewModal
|
||||
v-model="showFilePreview"
|
||||
:file="previewFile"
|
||||
:agent-id="workspace.currentTrainingAgentId || undefined"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
@update:modelValue="handlePreviewClose"
|
||||
/>
|
||||
</Teleport>
|
||||
</template>
|
||||
Reference in new issue
Block a user