1851 lines
91 KiB
Vue
1851 lines
91 KiB
Vue
<script setup lang="ts">
|
||
/**
|
||
* features/chat/components/TrainingWorkspacePanel.vue
|
||
* 用途:在培训 Agent 的聊天页顶部提供“员工培训 + 培训管理”一体化工作区。
|
||
* 依赖:useTrainingWorkspace、lucide 图标、聊天页 currentAgent/currentUser。
|
||
* 逻辑:只在培训 Agent 下渲染;员工与 HR 管理员首次进入默认展开工作区,
|
||
* 收起态下点击“员工培训 / 培训管理 / 展开工作区”会直接展开到对应工作区;
|
||
* 新建/切换会话后统一回到聊天页,避免聊天过程中被自动展开打断。
|
||
*/
|
||
import { computed, reactive, ref, watch, type ShallowUnwrapRef } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
import {
|
||
BookOpen,
|
||
CheckCircle2,
|
||
ChevronDown,
|
||
ChevronUp,
|
||
ClipboardCheck,
|
||
Download,
|
||
FileText,
|
||
PlayCircle,
|
||
RefreshCcw,
|
||
ShieldCheck,
|
||
Target,
|
||
User,
|
||
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 { getMyTrainingConfig } from '@/features/chat/api/training.api';
|
||
import type { TrainingAnswerRecord, TrainingRecord, TrainingQuestion } from '@/features/chat/training/training.types';
|
||
import html2pdf from 'html2pdf.js';
|
||
|
||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||
|
||
const props = defineProps<{
|
||
currentAgent: Record<string, unknown> | null;
|
||
currentUser: Record<string, unknown> | null;
|
||
agentGuides: TrainingGuideLike[];
|
||
newSessionTick: number;
|
||
training: ShallowUnwrapRef<ReturnType<typeof useTrainingWorkspace>>;
|
||
}>();
|
||
|
||
const emit = defineEmits<{
|
||
'open-guide': [guideId?: number];
|
||
'update:expanded': [expanded: boolean];
|
||
}>();
|
||
|
||
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,
|
||
set: (val) => { workspace.showVideoModal = val; }
|
||
});
|
||
const lastVideoTime = ref(0);
|
||
|
||
const learnerStageOrder = ['video', 'summary', 'exam', 'result'] as const;
|
||
const learnerStageIconMap = {
|
||
video: PlayCircle,
|
||
summary: BookOpen,
|
||
exam: ClipboardCheck,
|
||
result: ShieldCheck,
|
||
} as const;
|
||
const currentLearnerStageIndex = computed(() => learnerStageOrder.indexOf(workspace.stage));
|
||
const showLearnerProgressModule = computed(() => workspace.learnerProgressItems.length > 0);
|
||
const learnerProgressItems = computed(() => workspace.learnerProgressItems.map((item, index) => {
|
||
const stageIndex = learnerStageOrder.indexOf(item.stage as typeof learnerStageOrder[number]);
|
||
const status = stageIndex >= 0 && currentLearnerStageIndex.value >= 0
|
||
? currentLearnerStageIndex.value > stageIndex
|
||
? 'completed'
|
||
: currentLearnerStageIndex.value === stageIndex
|
||
? 'active'
|
||
: 'pending'
|
||
: 'pending';
|
||
return {
|
||
...item,
|
||
icon: learnerStageIconMap[item.stage as keyof typeof learnerStageIconMap] || BookOpen,
|
||
orderLabel: String(index + 1).padStart(2, '0'),
|
||
status,
|
||
};
|
||
}));
|
||
const learnerStepIntroTitle = computed(() => {
|
||
const [title] = String(workspace.learnerStepIntroText || '').split(/\r?\n/);
|
||
return title?.trim() || '';
|
||
});
|
||
const learnerStepIntroDescription = computed(() => {
|
||
const [, ...restLines] = String(workspace.learnerStepIntroText || '').split(/\r?\n/);
|
||
return restLines.join('\n').trim();
|
||
});
|
||
|
||
const userExpandedOverride = ref<boolean | null>(null);
|
||
// HR 管理员与普通员工首次进入培训 Agent 时都默认展开工作区;新建对话仍按既有约束强制收起。
|
||
const shouldDefaultExpanded = computed(() => workspace.isTrainingAgent);
|
||
|
||
const handleVideoTimeUpdate = (e: Event) => {
|
||
const video = e.target as HTMLVideoElement;
|
||
if (!video.seeking) {
|
||
lastVideoTime.value = video.currentTime;
|
||
}
|
||
};
|
||
|
||
const handleVideoSeeking = (e: Event) => {
|
||
const video = e.target as HTMLVideoElement;
|
||
if (video.currentTime > lastVideoTime.value + 1) {
|
||
video.currentTime = lastVideoTime.value;
|
||
}
|
||
};
|
||
|
||
const handleVideoEnded = () => {
|
||
workspace.showVideoModal = false;
|
||
workspace.stopMaterialTimer();
|
||
};
|
||
|
||
const reportModalVisible = ref(false);
|
||
const currentReportRecord = ref<TrainingRecord | null>(null);
|
||
const reportQuestions = ref<Record<string, TrainingQuestion>>({});
|
||
const reportLoading = ref(false);
|
||
|
||
/**
|
||
* 将学员文本答案回填到题干中的横线位置。
|
||
* 核心逻辑:仅替换填空题题干的连续下划线;若题干没有横线或答案为空,则保留原题干,避免改变非填空题与历史题目展示。
|
||
* @param question - 当前题目的题库定义。
|
||
* @param answer - 该题已保存的员工答题记录。
|
||
* @returns 含回填答案的题干片段列表,模板按 `isAnswer` 区分答案样式。
|
||
*/
|
||
const buildReportPromptParts = (question: TrainingQuestion | undefined, answer?: TrainingAnswerRecord) => {
|
||
const prompt = question?.prompt || '';
|
||
const textAnswer = String(answer?.answerText || '').trim();
|
||
if (question?.type !== 'fill' || !textAnswer || !/_{2,}/.test(prompt)) {
|
||
return [{ text: prompt, isAnswer: false }];
|
||
}
|
||
const parts = prompt.split(/(_{2,})/g);
|
||
let answerFilled = false;
|
||
return parts.map((part) => {
|
||
if (!answerFilled && /^_{2,}$/.test(part)) {
|
||
answerFilled = true;
|
||
return { text: textAnswer, isAnswer: true };
|
||
}
|
||
return { text: part, isAnswer: false };
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 将判断题的员工答案转换为报告中的可读文本。
|
||
* 核心逻辑:优先按 selectedOptionId 查找题库选项;历史题库没有选项时兼容 true/false、是/否等值。
|
||
* @param question - 当前题目的题库定义。
|
||
* @param answer - 当前题目的员工答题记录。
|
||
* @returns 员工实际作答的答案文本;无法解析时返回原始选项 ID。
|
||
*/
|
||
const resolveReportAnswerLabel = (question: TrainingQuestion | undefined, answer: TrainingAnswerRecord) => {
|
||
if (!question) return answer.selectedOptionId || answer.answerText || '--';
|
||
if (question.type === 'fill' || question.type === 'essay') return answer.answerText || '--';
|
||
return question.options?.find((option) => option.id === answer.selectedOptionId)?.label
|
||
|| answer.selectedOptionId
|
||
|| '--';
|
||
};
|
||
|
||
/**
|
||
* 组合报告题库与实际答题记录,确保未作答题目仍出现在考试报告。
|
||
* 核心逻辑:以当前发布题库为完整题目顺序,按题目 ID 合并答题记录;再保留历史记录中的已下线题目,避免旧考试报告丢失内容。
|
||
* @returns 用于在线预览与 PDF 下载的完整题目及答案行。
|
||
*/
|
||
const reportQuestionRows = computed(() => {
|
||
const answers = currentReportRecord.value?.answerDetails || [];
|
||
const answersByQuestionId = new Map(answers.map((answer) => [answer.questionId, answer]));
|
||
const configuredQuestions = Object.values(reportQuestions.value);
|
||
const configuredQuestionIds = new Set(configuredQuestions.map((question) => question.id));
|
||
const defaultAnswer = (questionId: string): TrainingAnswerRecord => ({
|
||
questionId,
|
||
selectedOptionId: '',
|
||
answerText: '',
|
||
correct: false,
|
||
});
|
||
|
||
return [
|
||
...configuredQuestions.map((question) => ({
|
||
question,
|
||
answer: answersByQuestionId.get(question.id) || defaultAnswer(question.id),
|
||
})),
|
||
...answers
|
||
.filter((answer) => !configuredQuestionIds.has(answer.questionId))
|
||
.map((answer) => ({ question: undefined, answer })),
|
||
];
|
||
});
|
||
|
||
const openReport = async (record: TrainingRecord) => {
|
||
currentReportRecord.value = record;
|
||
reportModalVisible.value = true;
|
||
reportLoading.value = true;
|
||
try {
|
||
const config = await getMyTrainingConfig(record.trainingType || 'onboarding');
|
||
const qMap: Record<string, TrainingQuestion> = {};
|
||
if (config?.resources) {
|
||
config.resources.forEach((r) => {
|
||
if (Array.isArray(r.inlineQuestions)) {
|
||
r.inlineQuestions.forEach((q: unknown) => {
|
||
const question = q as TrainingQuestion;
|
||
qMap[question.id] = question;
|
||
});
|
||
}
|
||
});
|
||
}
|
||
reportQuestions.value = qMap;
|
||
} catch (err) {
|
||
console.error('Failed to load config for report', err);
|
||
} finally {
|
||
reportLoading.value = false;
|
||
}
|
||
};
|
||
|
||
const closeReport = () => {
|
||
reportModalVisible.value = false;
|
||
currentReportRecord.value = null;
|
||
};
|
||
|
||
const printReport = async () => {
|
||
const element = document.getElementById('report-modal-content');
|
||
const report = currentReportRecord.value;
|
||
if (!element || !report) return;
|
||
const fileName = `${report.name}_${workspace.resolveTrainingTypeName(report.trainingType)}_考试报告.pdf`;
|
||
|
||
const opt = {
|
||
margin: [15, 15, 15, 15] as [number, number, number, number],
|
||
filename: fileName,
|
||
image: { type: 'jpeg' as const, quality: 0.98 },
|
||
html2canvas: {
|
||
scale: 2,
|
||
useCORS: true,
|
||
letterRendering: true,
|
||
windowWidth: 794,
|
||
scrollX: 0,
|
||
scrollY: 0,
|
||
},
|
||
pagebreak: {
|
||
mode: ['css', 'legacy'] as const,
|
||
avoid: ['.report-question', '.report-header-info', '.report-option'] as string[],
|
||
},
|
||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' as const }
|
||
};
|
||
|
||
try {
|
||
await html2pdf().set(opt).from(element).save();
|
||
msg.success(t('chat.training.hr.report.downloadSuccess') || 'PDF 下载成功');
|
||
} catch (error) {
|
||
console.error('Failed to generate PDF:', error);
|
||
msg.error(t('chat.training.hr.report.downloadFailed') || 'PDF 生成失败');
|
||
}
|
||
};
|
||
|
||
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 || 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
|
||
};
|
||
|
||
const setWorkspaceExpanded = (expanded: boolean, manual = false) => {
|
||
workspaceExpanded.value = expanded;
|
||
emit('update:expanded', expanded);
|
||
if (manual) {
|
||
userExpandedOverride.value = expanded;
|
||
} else if (!expanded) {
|
||
userExpandedOverride.value = null;
|
||
}
|
||
};
|
||
|
||
/**
|
||
* 从聊天页顶部入口切换到指定培训工作区,并立即展开工作区内容。
|
||
* AI 触发时机:当用户在 chat 主页面手动点击“员工培训 / 培训管理 / 展开工作区”时,
|
||
* 不能只切换 tab 高亮,必须同步展开对应工作区,避免用户误以为点击无效。
|
||
*/
|
||
const openWorkspaceView = (view: typeof workspace.activeView) => {
|
||
workspace.activeView = view;
|
||
setWorkspaceExpanded(true, true);
|
||
};
|
||
|
||
/**
|
||
* 收起培训工作区并回到纯聊天页面。
|
||
* AI 触发时机:点击“收起工作区”时,必须立即恢复聊天消息区与输入栏,而不是仅折叠局部内容。
|
||
*/
|
||
const collapseToChatPage = () => {
|
||
setWorkspaceExpanded(false, true);
|
||
};
|
||
|
||
/**
|
||
* 展开当前已选中的培训工作区。
|
||
* AI 触发时机:当用户已在收起态选定某个 tab 后点击“展开工作区”,
|
||
* 应沿用当前 activeView 打开对应面板,而不是切回默认视图。
|
||
*/
|
||
const expandCurrentWorkspace = () => {
|
||
setWorkspaceExpanded(true, true);
|
||
};
|
||
|
||
const currentAnswerLabel = computed(() => {
|
||
const question = workspace.currentQuestion;
|
||
if (!question) return '';
|
||
if (question.type === 'fill' || question.type === 'essay') return workspace.answerText;
|
||
return question.options?.find((item) => item.id === workspace.selectedOptionId)?.label || '';
|
||
});
|
||
|
||
const isTextQuestion = computed(() => ['fill', 'essay'].includes(workspace.currentQuestion?.type || ''));
|
||
const isTextFeedbackPending = computed(() => (
|
||
workspace.currentQuestion?.type === 'essay'
|
||
|| (workspace.currentQuestion?.type === 'fill' && !workspace.currentQuestion.answer)
|
||
));
|
||
|
||
const trainingExamPdfGuide = computed(() => resolveTrainingExamPdfGuide(props.agentGuides));
|
||
|
||
const workspaceExpanded = ref(false);
|
||
|
||
const applyDefaultExpandedState = () => {
|
||
const nextExpanded = userExpandedOverride.value ?? shouldDefaultExpanded.value;
|
||
workspaceExpanded.value = nextExpanded;
|
||
emit('update:expanded', nextExpanded);
|
||
};
|
||
|
||
// 监听 Agent/角色切换,重置本地展开态:培训角色首次进入默认展开工作区。
|
||
watch(
|
||
() => [props.currentAgent?.id, workspace.isAdminViewer],
|
||
() => {
|
||
userExpandedOverride.value = null;
|
||
applyDefaultExpandedState();
|
||
},
|
||
{ immediate: true }
|
||
);
|
||
|
||
watch(
|
||
() => props.newSessionTick,
|
||
(tick, prevTick) => {
|
||
if (!tick || tick === prevTick) return;
|
||
// [STEP 1] 新建对话或切换会话后统一收起工作区,避免聊天中因视图重建被自动展开。
|
||
userExpandedOverride.value = false;
|
||
applyDefaultExpandedState();
|
||
},
|
||
);
|
||
|
||
const isCompactMode = computed(() => !workspaceExpanded.value);
|
||
const isLearnerExamStage = computed(() => !isCompactMode.value && workspace.activeView === 'learner' && workspace.stage === 'exam');
|
||
const learnerWorkspaceGridClass = computed(() => (
|
||
workspace.stage === 'exam' || workspace.stage === 'result' || showLearnerProgressModule.value
|
||
? 'grid gap-2.5 p-3 md:grid-cols-[minmax(0,1.7fr)_208px] md:p-4 lg:gap-3 lg:grid-cols-[minmax(0,1.85fr)_220px] 2xl:grid-cols-[minmax(0,1.95fr)_240px]'
|
||
: 'grid gap-2.5 p-3 md:p-4'
|
||
));
|
||
const learnerWorkspaceMainClass = computed(() => 'min-w-0 space-y-3');
|
||
const progressCardClass = computed(() => 'rounded-2xl border border-default bg-white p-2.5 shadow-sm');
|
||
const examPanelClass = computed(() => (
|
||
isLearnerExamStage.value
|
||
? 'rounded-2xl border border-default bg-white p-3.5 shadow-sm'
|
||
: 'rounded-2xl border border-default bg-white p-4 shadow-sm'
|
||
));
|
||
const questionNavPanelClass = computed(() => 'rounded-2xl border border-default bg-white p-2.5 shadow-sm');
|
||
const questionNavGridClass = computed(() => 'mt-2 grid grid-cols-4 gap-1');
|
||
const questionNavButtonClass = computed(() => 'flex h-7 items-center justify-center rounded-lg border text-[11px] font-semibold transition');
|
||
|
||
const compactSummary = computed(() => {
|
||
if (workspace.activeView === 'admin') {
|
||
return `${workspace.stats.total}${t('chat.training.hr.stats.total')} / ${workspace.stats.passRate}% ${t('chat.training.hr.stats.passRate')}`;
|
||
}
|
||
if (workspace.stage === 'video') return learnerStepIntroTitle.value || t('chat.training.video.title');
|
||
if (workspace.stage === 'summary') return t('chat.training.summary.title');
|
||
if (workspace.stage === 'exam') {
|
||
return t('chat.training.exam.questionCounter', {
|
||
current: workspace.currentQuestionNumber,
|
||
total: workspace.totalQuestionCount,
|
||
});
|
||
}
|
||
return workspace.isPassed ? t('chat.training.result.passTitle') : t('chat.training.result.failTitle');
|
||
});
|
||
|
||
const ruleItems = computed(() => ([
|
||
t('chat.training.rules.rule1', { total: workspace.totalQuestionCount }),
|
||
t('chat.training.rules.rule2'),
|
||
t('chat.training.rules.rule3', { passScore: workspace.passScore }),
|
||
t('chat.training.rules.rule4'),
|
||
]));
|
||
const learnerIdentityItems = computed(() => ([
|
||
{ key: 'name', label: t('chat.training.learnerCard.name'), value: workspace.currentUserName },
|
||
{ key: 'employee-id', label: t('chat.training.learnerCard.employeeId'), value: workspace.currentUserEmployeeId },
|
||
{ key: 'department', label: t('chat.training.learnerCard.department'), value: workspace.currentUserDepartment },
|
||
]));
|
||
const answeredQuestionMap = computed(() => new Map(
|
||
workspace.answerRecords.map((item) => [item.questionId, item])
|
||
));
|
||
const examQuestionItems = computed(() => Array.from({ length: workspace.totalQuestionCount }, (_, index) => {
|
||
const isActive = workspace.stage === 'exam' && workspace.currentQuestionIndex === index;
|
||
const questionId = workspace.questionBank[index]?.id;
|
||
const answerRecord = questionId ? answeredQuestionMap.value.get(questionId) ?? null : null;
|
||
return {
|
||
index,
|
||
label: String(index + 1).padStart(2, '0'),
|
||
isActive,
|
||
status: isActive
|
||
? 'active'
|
||
: answerRecord
|
||
? answerRecord.correct ? 'correct' : 'wrong'
|
||
: 'pending',
|
||
};
|
||
}));
|
||
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 videoCountdownSeconds = ref(0);
|
||
let videoCountdownTimer: ReturnType<typeof setInterval> | null = null;
|
||
|
||
const startVideoCountdown = () => {
|
||
if (videoCountdownTimer) {
|
||
clearInterval(videoCountdownTimer);
|
||
videoCountdownTimer = null;
|
||
}
|
||
const requiredDuration = workspace.currentViewingMaterialRequiredDuration;
|
||
if (requiredDuration && requiredDuration > 0) {
|
||
videoCountdownSeconds.value = requiredDuration * 60;
|
||
videoCountdownTimer = setInterval(() => {
|
||
if (videoCountdownSeconds.value > 0) {
|
||
videoCountdownSeconds.value--;
|
||
} else {
|
||
if (videoCountdownTimer) clearInterval(videoCountdownTimer);
|
||
}
|
||
}, 1000);
|
||
} else {
|
||
videoCountdownSeconds.value = 0;
|
||
}
|
||
};
|
||
|
||
const stopVideoCountdown = () => {
|
||
if (videoCountdownTimer) {
|
||
clearInterval(videoCountdownTimer);
|
||
videoCountdownTimer = null;
|
||
}
|
||
};
|
||
|
||
const handleMaterialClick = (material: any) => {
|
||
const url = material.resource?.fileUrl;
|
||
if (!url) {
|
||
msg.warning('该资料暂无可预览的文件');
|
||
return;
|
||
}
|
||
|
||
if (material.resource?.fileType === 'video') {
|
||
workspace.currentViewingMaterialId = material.id;
|
||
workspace.showVideoModal = true;
|
||
currentPreviewVideoUrl.value = url;
|
||
startVideoCountdown();
|
||
} else {
|
||
workspace.currentViewingMaterialId = material.id;
|
||
previewFile.value = {
|
||
name: material.title || material.resource?.fileName || '资料预览',
|
||
url: url,
|
||
actualExt: material.resource?.fileType,
|
||
};
|
||
showFilePreview.value = true;
|
||
}
|
||
workspace.startMaterialTimer(material.id);
|
||
};
|
||
|
||
const handlePreviewClose = (val: boolean) => {
|
||
showFilePreview.value = val;
|
||
if (!val) {
|
||
workspace.stopMaterialTimer();
|
||
}
|
||
};
|
||
|
||
const handleVideoModalClose = () => {
|
||
workspace.showVideoModal = false;
|
||
currentPreviewVideoUrl.value = '';
|
||
stopVideoCountdown();
|
||
workspace.stopMaterialTimer();
|
||
};
|
||
const jumpToExamQuestion = (index: number) => {
|
||
if (!canNavigateExamQuestions.value) return;
|
||
workspace.syncExamQuestionIndex(index);
|
||
};
|
||
const canSwitchToStage = (stageKey: string) => {
|
||
if (stageKey !== 'result') return true;
|
||
return workspace.canEnterResultStage;
|
||
};
|
||
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>
|
||
<section
|
||
v-if="workspace.isTrainingAgent"
|
||
class="mx-auto w-full max-w-6xl rounded-3xl border border-brand-100 bg-gradient-to-br from-white via-brand-50/30 to-slate-50 shadow-sm"
|
||
:class="workspaceExpanded ? 'mb-0 min-h-0 flex-1 overflow-y-auto' : 'mb-4 min-w-0 flex-none'"
|
||
>
|
||
<div
|
||
v-if="isCompactMode"
|
||
class="flex flex-col gap-1.5 bg-white/90 px-4 py-2 backdrop-blur-sm md:px-5"
|
||
>
|
||
<div class="flex flex-col gap-1.5 xl:flex-row xl:items-center xl:justify-between">
|
||
<div class="min-w-0">
|
||
<div class="flex flex-wrap gap-2">
|
||
<button
|
||
type="button"
|
||
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
|
||
:class="workspace.activeView === 'learner' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||
@click="openWorkspaceView('learner')"
|
||
>
|
||
{{ $t('chat.training.tabs.learner') }}
|
||
</button>
|
||
<button
|
||
v-if="workspace.isAdminViewer"
|
||
type="button"
|
||
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
|
||
:class="workspace.activeView === 'admin' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||
@click="openWorkspaceView('admin')"
|
||
>
|
||
{{ $t('chat.training.tabs.admin') }}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||
<button
|
||
v-if="trainingExamPdfGuide"
|
||
type="button"
|
||
class="inline-flex h-9 items-center gap-2 rounded-xl border border-default bg-white px-3.5 text-xs font-medium leading-none text-secondary transition hover:bg-surface-soft"
|
||
@click="emit('open-guide', Number(trainingExamPdfGuide.id))"
|
||
>
|
||
<BookOpen class="h-4 w-4 shrink-0" />
|
||
<span class="leading-none">{{ $t('chat.training.actions.viewExamPdf') }}</span>
|
||
</button>
|
||
<button
|
||
v-if="workspace.stage === 'video'"
|
||
type="button"
|
||
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-brand-200 bg-brand-50 px-3 py-2 text-xs font-medium text-brand-700 transition hover:bg-brand-100"
|
||
@click="showVideoModal = true"
|
||
>
|
||
<PlayCircle class="h-4 w-4" />
|
||
{{ $t('chat.training.steps.video') }}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="inline-flex h-9 items-center gap-2 rounded-xl border border-default bg-white px-3.5 text-xs font-medium leading-none text-secondary transition hover:bg-surface-soft"
|
||
@click="expandCurrentWorkspace"
|
||
>
|
||
<ChevronDown class="h-4 w-4 shrink-0" />
|
||
<span class="leading-none">{{ $t('chat.training.actions.expandWorkspace') }}</span>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex flex-col gap-2 rounded-2xl border border-brand-100 bg-brand-50/40 px-3.5 py-2 md:flex-row md:items-center md:justify-between">
|
||
<div class="min-w-0">
|
||
<div class="truncate text-sm font-semibold text-primary">
|
||
{{ compactSummary }}
|
||
</div>
|
||
<div class="mt-1 text-xs leading-5 text-secondary">
|
||
<template v-if="workspace.activeView === 'admin'">
|
||
{{ $t('chat.training.hr.filters.keywordLabel') }}: {{ workspace.hrKeyword || $t('chat.training.hr.filters.noLimit') }}
|
||
· {{ $t('chat.training.hr.filters.departmentLabel') }}:
|
||
{{ workspace.hrDepartmentFilter === 'all' ? $t('chat.training.hr.filters.allDepartments') : workspace.hrDepartmentFilter }}
|
||
</template>
|
||
</div>
|
||
<div
|
||
v-if="workspace.activeView === 'learner'"
|
||
class="mt-1 flex flex-wrap gap-x-4 gap-y-1 text-xs leading-5 text-secondary"
|
||
>
|
||
<span v-for="item in learnerIdentityItems" :key="item.key">
|
||
{{ item.label }}: {{ item.value }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
<div class="flex flex-wrap items-center gap-2 text-xs">
|
||
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
|
||
{{ workspace.activeView === 'admin' ? `${$t('chat.training.hr.stats.passRate')} ${workspace.stats.passRate}%` : `${$t('chat.training.progressPercent')} ${workspace.learnerProgressPercent}%` }}
|
||
</div>
|
||
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
|
||
{{ workspace.activeView === 'admin' ? `${$t('chat.training.hr.stats.total')} ${workspace.stats.total}` : `${$t('chat.training.result.scoreLabel')} ${workspace.score}` }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-else class="flex flex-col gap-1.5 bg-white/90 px-4 py-2 backdrop-blur-sm md:px-5">
|
||
<div class="flex flex-col gap-1.5 xl:flex-row xl:items-center xl:justify-between">
|
||
<div class="min-w-0">
|
||
<div class="flex flex-wrap gap-2">
|
||
<button
|
||
type="button"
|
||
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
|
||
:class="workspace.activeView === 'learner' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||
@click="workspace.activeView = 'learner'"
|
||
>
|
||
{{ $t('chat.training.tabs.learner') }}
|
||
</button>
|
||
<button
|
||
v-if="workspace.isAdminViewer"
|
||
type="button"
|
||
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
|
||
:class="workspace.activeView === 'admin' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||
@click="workspace.activeView = 'admin'"
|
||
>
|
||
{{ $t('chat.training.tabs.admin') }}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||
<button
|
||
v-if="trainingExamPdfGuide"
|
||
type="button"
|
||
class="inline-flex h-9 items-center gap-2 rounded-xl border border-default bg-white px-3.5 text-xs font-medium leading-none text-secondary transition hover:bg-surface-soft"
|
||
@click="emit('open-guide', Number(trainingExamPdfGuide.id))"
|
||
>
|
||
<BookOpen class="h-4 w-4 shrink-0" />
|
||
<span class="leading-none">{{ $t('chat.training.actions.viewExamPdf') }}</span>
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="inline-flex h-9 items-center gap-2 rounded-xl border border-default bg-white px-3.5 text-xs font-medium leading-none text-secondary transition hover:bg-surface-soft"
|
||
@click="collapseToChatPage"
|
||
>
|
||
<ChevronUp class="h-4 w-4 shrink-0" />
|
||
<span class="leading-none">{{ $t('chat.training.actions.collapseWorkspace') }}</span>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex flex-col gap-2 rounded-2xl border border-brand-100 bg-brand-50/40 px-3.5 py-2 md:flex-row md:items-center md:justify-between">
|
||
<div class="min-w-0">
|
||
<div class="truncate text-sm font-semibold text-primary">
|
||
{{ compactSummary }}
|
||
</div>
|
||
<div v-if="workspace.activeView === 'admin'" class="mt-1 text-xs leading-5 text-secondary">
|
||
{{ $t('chat.training.hr.filters.keywordLabel') }}: {{ workspace.hrKeyword || $t('chat.training.hr.filters.noLimit') }}
|
||
· {{ $t('chat.training.hr.filters.departmentLabel') }}:
|
||
{{ workspace.hrDepartmentFilter === 'all' ? $t('chat.training.hr.filters.allDepartments') : workspace.hrDepartmentFilter }}
|
||
</div>
|
||
<div
|
||
v-if="workspace.activeView === 'learner'"
|
||
class="mt-1 flex flex-wrap gap-x-4 gap-y-1 text-xs leading-5 text-secondary"
|
||
>
|
||
<span v-for="item in learnerIdentityItems" :key="item.key">
|
||
{{ item.label }}: {{ item.value }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
<div class="flex flex-wrap items-center gap-2 text-xs">
|
||
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
|
||
{{ workspace.activeView === 'admin' ? `${$t('chat.training.hr.stats.passRate')} ${workspace.stats.passRate}%` : `${$t('chat.training.progressPercent')} ${workspace.learnerProgressPercent}%` }}
|
||
</div>
|
||
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
|
||
{{ workspace.activeView === 'admin' ? `${$t('chat.training.hr.stats.total')} ${workspace.stats.total}` : `${$t('chat.training.result.scoreLabel')} ${workspace.score}` }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="!isCompactMode && workspace.activeView === 'learner'" :class="learnerWorkspaceGridClass">
|
||
<!-- 已发布培训类型由后端配置动态提供。 -->
|
||
<div class="col-span-full mb-1">
|
||
<div class="inline-flex flex-wrap rounded-xl border border-default bg-surface-soft p-1">
|
||
<button
|
||
v-for="trainingType in workspace.trainingTypes"
|
||
:key="trainingType.code"
|
||
class="flex items-center gap-2 rounded-lg px-6 py-2 text-sm font-medium transition"
|
||
:class="workspace.learnerTab === trainingType.code ? 'bg-white text-brand-700 shadow-sm border border-brand-200' : 'text-secondary hover:text-primary'"
|
||
@click="workspace.learnerTab = trainingType.code"
|
||
>
|
||
<ShieldCheck v-if="trainingType.code === 'safety'" class="h-4 w-4" />
|
||
<User v-else-if="trainingType.code === 'onboarding'" class="h-4 w-4" />
|
||
<BookOpen v-else class="h-4 w-4" />
|
||
{{ trainingType.name }}
|
||
</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 !== 'safety'">
|
||
<div :class="learnerWorkspaceMainClass">
|
||
<div v-if="showLearnerProgressModule" :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.progressLabel') }}
|
||
</div>
|
||
<div v-if="workspace.learnerProgressHintText" class="mt-0.5 text-[11px] leading-4.5 text-secondary md:text-xs">
|
||
{{ workspace.learnerProgressHintText }}
|
||
</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.learnerProgressPercent }}%</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mt-2 grid grid-cols-2 gap-1 lg:grid-cols-4">
|
||
<div
|
||
v-for="item in learnerProgressItems"
|
||
:key="item.stage"
|
||
class="cursor-pointer rounded-xl border px-2 py-1.5 transition hover:border-brand-300"
|
||
:class="[
|
||
item.status === 'completed' || item.status === 'active' ? 'border-brand-200 bg-brand-50/70' : 'border-default bg-surface-soft/70',
|
||
canSwitchToStage(String(item.stage)) ? 'cursor-pointer hover:border-brand-300' : 'cursor-not-allowed opacity-60',
|
||
]"
|
||
@click="handleStageCardClick(String(item.stage))"
|
||
>
|
||
<div class="flex items-center gap-2">
|
||
<div
|
||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-lg"
|
||
:class="item.status === 'completed' || item.status === 'active' ? 'bg-brand-600 text-white' : 'bg-white text-muted'"
|
||
>
|
||
<component :is="item.icon" class="h-3 w-3" />
|
||
</div>
|
||
<div class="min-w-0">
|
||
<div class="text-[10px] font-semibold uppercase tracking-[0.14em] text-muted">
|
||
{{ item.orderLabel }}
|
||
</div>
|
||
<div class="whitespace-normal text-[12px] font-medium leading-4 text-primary">{{ item.label }}</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="workspace.stage === 'video'" class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||
<div v-if="learnerStepIntroTitle || learnerStepIntroDescription">
|
||
<div>
|
||
<h3 v-if="learnerStepIntroTitle" class="text-base font-semibold text-primary md:text-lg">{{ learnerStepIntroTitle }}</h3>
|
||
<p v-if="learnerStepIntroDescription" class="mt-1 whitespace-pre-line text-sm leading-6 text-secondary">{{ learnerStepIntroDescription }}</p>
|
||
</div>
|
||
</div>
|
||
<div class="mt-3">
|
||
<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 transition hover:bg-slate-100"
|
||
@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.video.playerTitle') }}</span>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="mt-3 relative group cursor-pointer overflow-hidden rounded-2xl border border-default bg-slate-900 shadow-lg aspect-video flex items-center justify-center" @click="showVideoModal = true">
|
||
<img src="https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=Professional%20corporate%20training%20video%20cover%2C%20high-quality%2C%20modern%20office%20background%2C%20play%20button%20overlay&image_size=landscape_16_9" class="absolute inset-0 w-full h-full object-cover opacity-60 group-hover:scale-105 transition-transform duration-500" />
|
||
<div class="relative z-10 flex flex-col items-center gap-3">
|
||
<div class="h-16 w-16 flex items-center justify-center rounded-full bg-white/20 backdrop-blur-md border border-white/30 group-hover:bg-brand-600 group-hover:border-brand-500 transition-all duration-300">
|
||
<PlayCircle class="h-8 w-8 text-white fill-white/20" />
|
||
</div>
|
||
<span class="text-white font-medium drop-shadow-md">{{ $t('chat.training.video.playerTitle') }}</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-else-if="workspace.stage === 'summary'" class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||
<div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
|
||
<div>
|
||
<h3 class="text-base font-semibold text-primary md:text-lg">{{ $t('chat.training.summary.title') }}</h3>
|
||
<p class="mt-1 text-sm leading-6 text-secondary">{{ $t('chat.training.summary.description') }}</p>
|
||
</div>
|
||
<div class="flex flex-wrap gap-2">
|
||
<button
|
||
type="button"
|
||
class="inline-flex items-center justify-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.startExam"
|
||
>
|
||
<Target class="h-4 w-4" />
|
||
{{ $t('chat.training.summary.startExam') }}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mt-3 grid gap-3 md:grid-cols-2">
|
||
<div class="rounded-2xl border border-brand-100 bg-brand-50/50 p-3.5">
|
||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.summary.keyPoints') }}</div>
|
||
<ul class="mt-2.5 space-y-1.5 text-sm leading-6 text-secondary">
|
||
<li v-for="point in workspace.summaryPoints" :key="point" class="flex gap-2">
|
||
<span class="mt-1.5 h-1.5 w-1.5 rounded-full bg-brand-500" />
|
||
<span>{{ point }}</span>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
|
||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.summary.mustKnow') }}</div>
|
||
<ul class="mt-2.5 space-y-1.5 text-sm leading-6 text-secondary">
|
||
<li v-for="point in workspace.summaryChecklist" :key="point" class="flex gap-2">
|
||
<CheckCircle2 class="mt-1 h-4 w-4 shrink-0 text-emerald-500" />
|
||
<span>{{ point }}</span>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-else-if="workspace.stage === '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.exam.title') }}
|
||
</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 v-if="isTextQuestion" class="mt-2.5 grid gap-2">
|
||
<textarea
|
||
v-model="workspace.answerText"
|
||
:disabled="workspace.currentQuestion.type === 'essay' && workspace.answerLocked"
|
||
:rows="workspace.currentQuestion.type === 'essay' ? 5 : 3"
|
||
class="w-full rounded-2xl border border-default bg-white px-3.5 py-2 text-sm leading-6 text-primary outline-none transition focus:border-brand-400 focus:ring-2 focus:ring-brand-100 disabled:bg-surface-soft"
|
||
:placeholder="$t(workspace.currentQuestion.type === 'essay' ? 'chat.training.exam.essayPlaceholder' : 'chat.training.exam.fillPlaceholder')"
|
||
/>
|
||
<button
|
||
v-if="!workspace.answerLocked"
|
||
type="button"
|
||
:disabled="!workspace.answerText.trim()"
|
||
class="justify-self-start rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-50"
|
||
@click="workspace.submitTextAnswer()"
|
||
>
|
||
{{ $t('chat.training.exam.submitTextAnswer') }}
|
||
</button>
|
||
</div>
|
||
<div v-else 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="isTextFeedbackPending || 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="isTextFeedbackPending || workspace.currentFeedbackCorrect ? 'text-emerald-700' : 'text-red-700'"">
|
||
<CheckCircle2 v-if="isTextFeedbackPending || workspace.currentFeedbackCorrect" class="h-4 w-4" />
|
||
<XCircle v-else class="h-4 w-4" />
|
||
{{ isTextFeedbackPending ? $t('chat.training.exam.textAnswerRecorded') : 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 v-if="isTextQuestion" class="mt-1 text-sm leading-6 text-secondary">
|
||
{{ workspace.currentQuestion.type === 'fill' && workspace.currentQuestion.answer
|
||
? $t('chat.training.exam.correctAnswer', { answer: workspace.currentQuestion.answer })
|
||
: $t('chat.training.exam.textAnswerRecorded') }}
|
||
</div>
|
||
<div v-else 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="showLearnerProgressModule && 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 in learnerProgressItems"
|
||
:key="item.stage"
|
||
class="flex items-center gap-3 p-2 rounded-lg border transition"
|
||
:class="[
|
||
item.status === 'completed' ? 'border-emerald-200 bg-emerald-50/50' :
|
||
item.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="item.status === 'completed' ? 'bg-emerald-500 text-white' : item.status === 'active' ? 'bg-brand-500 text-white shadow-sm' : 'bg-slate-200 text-slate-400'"
|
||
>
|
||
<CheckCircle2 v-if="item.status === 'completed'" class="h-4 w-4" />
|
||
<span v-else class="text-xs font-bold">{{ Number(item.orderLabel) }}</span>
|
||
</div>
|
||
<div class="min-w-0 flex-1">
|
||
<div class="text-xs font-semibold" :class="item.status === 'active' ? 'text-brand-700' : 'text-slate-700'">{{ 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>
|
||
</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>
|
||
</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>
|
||
|
||
<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 v-if="isTextQuestion" class="mt-2.5 grid gap-2">
|
||
<textarea
|
||
v-model="workspace.answerText"
|
||
:disabled="workspace.currentQuestion.type === 'essay' && workspace.answerLocked"
|
||
:rows="workspace.currentQuestion.type === 'essay' ? 5 : 3"
|
||
class="w-full rounded-2xl border border-default bg-white px-3.5 py-2 text-sm leading-6 text-primary outline-none transition focus:border-brand-400 focus:ring-2 focus:ring-brand-100 disabled:bg-surface-soft"
|
||
:placeholder="$t(workspace.currentQuestion.type === 'essay' ? 'chat.training.exam.essayPlaceholder' : 'chat.training.exam.fillPlaceholder')"
|
||
/>
|
||
<button
|
||
v-if="workspace.currentQuestion.type === 'fill' || !workspace.answerLocked"
|
||
type="button"
|
||
:disabled="!workspace.answerText.trim()"
|
||
class="justify-self-start rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-50"
|
||
@click="workspace.submitTextAnswer()"
|
||
>
|
||
{{ $t('chat.training.exam.submitTextAnswer') }}
|
||
</button>
|
||
</div>
|
||
<div v-else 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="isTextFeedbackPending || 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="isTextFeedbackPending || workspace.currentFeedbackCorrect ? 'text-emerald-700' : 'text-red-700'"">
|
||
<CheckCircle2 v-if="isTextFeedbackPending || workspace.currentFeedbackCorrect" class="h-4 w-4" />
|
||
<XCircle v-else class="h-4 w-4" />
|
||
{{ isTextFeedbackPending ? $t('chat.training.exam.textAnswerRecorded') : 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 v-if="isTextQuestion" class="mt-1 text-sm leading-6 text-secondary">
|
||
{{ workspace.currentQuestion.type === 'fill' && workspace.currentQuestion.answer
|
||
? $t('chat.training.exam.correctAnswer', { answer: workspace.currentQuestion.answer })
|
||
: $t('chat.training.exam.textAnswerRecorded') }}
|
||
</div>
|
||
<div v-else 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">
|
||
<div class="grid gap-3 sm:grid-cols-2 xl:grid-cols-5">
|
||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||
<div class="flex items-center justify-center gap-2 text-center">
|
||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.total') }}</div>
|
||
<div class="text-2xl font-semibold text-primary">{{ workspace.stats.total }}</div>
|
||
</div>
|
||
</div>
|
||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||
<div class="flex items-center justify-center gap-2 text-center">
|
||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.passed') }}</div>
|
||
<div class="text-2xl font-semibold text-emerald-600">{{ workspace.stats.passed }}</div>
|
||
</div>
|
||
</div>
|
||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||
<div class="flex items-center justify-center gap-2 text-center">
|
||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.failed') }}</div>
|
||
<div class="text-2xl font-semibold text-amber-600">{{ workspace.stats.failed }}</div>
|
||
</div>
|
||
</div>
|
||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||
<div class="flex items-center justify-center gap-2 text-center">
|
||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.inProgress') }}</div>
|
||
<div class="text-2xl font-semibold text-blue-600">{{ workspace.stats.inProgress }}</div>
|
||
</div>
|
||
</div>
|
||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||
<div class="flex items-center justify-center gap-2 text-center">
|
||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.passRate') }}</div>
|
||
<div class="text-2xl font-semibold text-primary">{{ workspace.stats.passRate }}%</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<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)_minmax(0,1fr)_auto] xl:items-center">
|
||
<label>
|
||
<input
|
||
v-model="workspace.hrKeyword"
|
||
type="text"
|
||
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"
|
||
: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 v-for="trainingType in workspace.trainingTypes" :key="trainingType.code" :value="trainingType.code">
|
||
{{ trainingType.name }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
<label>
|
||
<select
|
||
v-model="workspace.hrStatusFilter"
|
||
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.allStatuses') }}</option>
|
||
<option value="passed">{{ $t('chat.training.hr.status.passed') }}</option>
|
||
<option value="failed">{{ $t('chat.training.hr.status.failed') }}</option>
|
||
<option value="in_progress">{{ $t('chat.training.hr.status.in_progress') }}</option>
|
||
</select>
|
||
</label>
|
||
<label>
|
||
<select
|
||
v-model="workspace.hrDepartmentFilter"
|
||
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.allDepartments') }}</option>
|
||
<option v-for="department in workspace.departmentOptions" :key="department" :value="department">
|
||
{{ department }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
<div class="flex justify-center xl:justify-end">
|
||
<button
|
||
type="button"
|
||
class="inline-flex h-10 items-center gap-2 rounded-xl bg-brand-600 px-4 text-xs font-medium text-white transition hover:bg-brand-700 sm:text-sm"
|
||
@click="workspace.exportRecords"
|
||
>
|
||
<Download class="h-4 w-4" />
|
||
{{ $t('chat.training.hr.actions.export') }}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mt-4 overflow-x-auto rounded-2xl border border-default">
|
||
<table class="min-w-full border-collapse text-sm">
|
||
<thead class="bg-surface-soft">
|
||
<tr>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.joinDate') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.completionDate') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.trainingType') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.department') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.name') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.employeeId') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.score') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.attempts') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.trainingReport') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.status') }}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr v-for="record in workspace.filteredRecords" :key="record.id" class="odd:bg-white even:bg-surface-soft/30">
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.joinDate }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.completionDate || '--' }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ workspace.resolveTrainingTypeName(record.trainingType) }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.department }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 font-medium text-primary">{{ record.name }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.employeeId }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.score ?? '--' }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.attempts }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">
|
||
<button v-if="record.status === 'passed' || record.status === 'failed'" @click="openReport(record)" class="text-brand-600 hover:text-brand-700 transition" :title="$t('chat.training.hr.report.title')">
|
||
<FileText class="w-5 h-5" />
|
||
</button>
|
||
<span v-else class="text-muted">--</span>
|
||
</td>
|
||
<td class="border-b border-default px-3 py-2.5">
|
||
<span
|
||
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
|
||
:class="record.status === 'passed'
|
||
? 'bg-emerald-50 text-emerald-700'
|
||
: record.status === 'failed'
|
||
? 'bg-amber-50 text-amber-700'
|
||
: 'bg-blue-50 text-blue-700'"
|
||
>
|
||
{{ $t(`chat.training.hr.status.${record.status}`) }}
|
||
</span>
|
||
</td>
|
||
</tr>
|
||
<tr v-if="workspace.filteredRecords.length === 0">
|
||
<td colspan="8" class="px-4 py-6 text-center text-sm text-muted">
|
||
{{ $t('chat.training.hr.empty') }}
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<Teleport to="body">
|
||
<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">
|
||
<div class="absolute top-4 right-4 z-10 flex items-center gap-2">
|
||
<div v-if="videoCountdownSeconds > 0" class="flex items-center justify-center h-10 w-10 rounded-full border border-red-200 bg-red-50 text-red-500 font-semibold text-xs shadow-sm backdrop-blur-md">
|
||
{{ videoCountdownSeconds }}s
|
||
</div>
|
||
<button @click="handleVideoModalClose" class="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>
|
||
<div class="aspect-video bg-black">
|
||
<video
|
||
controls
|
||
playsinline
|
||
webkit-playsinline="true"
|
||
preload="metadata"
|
||
class="h-full w-full"
|
||
@loadstart="reportVideoDebugEvent"
|
||
@loadedmetadata="reportVideoDebugEvent"
|
||
@canplay="reportVideoDebugEvent"
|
||
@play="reportVideoDebugEvent"
|
||
@error="reportVideoDebugEvent"
|
||
@stalled="reportVideoDebugEvent"
|
||
@abort="reportVideoDebugEvent"
|
||
@timeupdate="handleVideoTimeUpdate"
|
||
@seeking="handleVideoSeeking"
|
||
@ended="handleVideoEnded"
|
||
>
|
||
<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()"
|
||
:required-duration="workspace.currentViewingMaterialRequiredDuration"
|
||
@update:modelValue="handlePreviewClose"
|
||
/>
|
||
|
||
<div v-if="reportModalVisible" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="closeReport">
|
||
<div class="relative w-full max-w-4xl max-h-[90vh] flex flex-col overflow-hidden rounded-3xl bg-white shadow-2xl">
|
||
<div class="flex items-center justify-between border-b border-default px-6 py-4">
|
||
<h3 class="text-lg font-semibold text-primary">{{ $t('chat.training.hr.report.title') }}</h3>
|
||
<div class="flex items-center gap-3">
|
||
<button @click="printReport" class="flex items-center gap-2 rounded-xl bg-brand-50 px-4 py-2 text-sm font-medium text-brand-600 transition hover:bg-brand-100">
|
||
<Download class="w-4 h-4" />
|
||
{{ $t('chat.training.hr.report.download') }}
|
||
</button>
|
||
<button @click="closeReport" class="flex h-8 w-8 items-center justify-center rounded-full bg-surface-soft text-secondary hover:bg-surface hover:text-primary transition">
|
||
<XCircle class="h-5 w-5" />
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex-1 overflow-y-auto p-6 report-print-container" id="report-modal-content">
|
||
<div class="report-pdf-page">
|
||
<div v-if="reportLoading" class="flex h-full items-center justify-center">
|
||
<div class="h-8 w-8 animate-spin rounded-full border-4 border-brand-200 border-t-brand-600"></div>
|
||
</div>
|
||
<div v-else-if="currentReportRecord">
|
||
<!-- Header Info -->
|
||
<div class="report-header-info mb-8 rounded-2xl bg-surface-soft p-6">
|
||
<h2 class="mb-4 text-center text-2xl font-bold text-primary">{{ workspace.resolveTrainingTypeName(currentReportRecord.trainingType) }} {{ $t('chat.training.hr.report.title') }}</h2>
|
||
<div class="grid grid-cols-2 gap-4 sm:grid-cols-4">
|
||
<div>
|
||
<div class="text-xs text-secondary">{{ $t('chat.training.hr.columns.name') }}</div>
|
||
<div class="font-medium text-primary">{{ currentReportRecord.name }}</div>
|
||
</div>
|
||
<div>
|
||
<div class="text-xs text-secondary">{{ $t('chat.training.hr.columns.department') }}</div>
|
||
<div class="font-medium text-primary">{{ currentReportRecord.department }}</div>
|
||
</div>
|
||
<div>
|
||
<div class="text-xs text-secondary">{{ $t('chat.training.hr.columns.employeeId') }}</div>
|
||
<div class="font-medium text-primary">{{ currentReportRecord.employeeId }}</div>
|
||
</div>
|
||
<div>
|
||
<div class="text-xs text-secondary">{{ $t('chat.training.hr.columns.score') }}</div>
|
||
<div class="font-medium" :class="currentReportRecord.status === 'passed' ? 'text-emerald-600' : 'text-rose-600'">
|
||
{{ currentReportRecord.score ?? '--' }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Exam Details -->
|
||
<div class="space-y-6">
|
||
<div v-for="(row, idx) in reportQuestionRows" :key="row.answer.questionId" class="report-question rounded-xl border border-default p-4">
|
||
<div class="report-question-header mb-3">
|
||
<div class="report-question-title font-medium text-primary">
|
||
<span class="mr-2 text-secondary">{{ idx + 1 }}.</span>
|
||
<template v-if="row.question">
|
||
<template v-for="(part, partIndex) in buildReportPromptParts(row.question, row.answer)" :key="partIndex">
|
||
<span v-if="part.isAnswer" class="report-filled-answer">{{ part.text }}</span>
|
||
<span v-else>{{ part.text }}</span>
|
||
</template>
|
||
</template>
|
||
<template v-else>[ID: {{ row.answer.questionId }}]</template>
|
||
</div>
|
||
<div class="report-question-result">
|
||
<span v-if="row.answer.correct" class="inline-flex rounded-full bg-emerald-50 px-2 py-1 text-xs font-semibold text-emerald-700">正确</span>
|
||
<span v-else class="inline-flex rounded-full bg-rose-50 px-2 py-1 text-xs font-semibold text-rose-700">错误</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="report-options pl-6">
|
||
<div v-if="row.question?.type === 'boolean'" class="report-answer-row text-sm">
|
||
员工作答:<span class="report-employee-answer">{{ resolveReportAnswerLabel(row.question, row.answer) }}</span>
|
||
</div>
|
||
<div v-else-if="row.question?.type === 'essay'" class="report-answer-row text-sm">
|
||
员工作答:<span class="report-employee-answer report-essay-answer">{{ resolveReportAnswerLabel(row.question, row.answer) }}</span>
|
||
</div>
|
||
<div v-for="(opt, optIdx) in row.question?.options || []" :key="opt.id"
|
||
class="report-option text-sm"
|
||
:class="{
|
||
'font-semibold text-emerald-600': opt.id === row.question?.answer,
|
||
'text-rose-600': !row.answer.correct && opt.id === row.answer.selectedOptionId,
|
||
'text-secondary': opt.id !== row.question?.answer && opt.id !== row.answer.selectedOptionId
|
||
}"
|
||
>
|
||
<span class="report-option-marker"
|
||
:class="{
|
||
'border-emerald-200 bg-emerald-50 text-emerald-600': opt.id === row.question?.answer,
|
||
'border-rose-200 bg-rose-50 text-rose-600': !row.answer.correct && opt.id === row.answer.selectedOptionId,
|
||
'border-default': opt.id !== row.question?.answer && opt.id !== row.answer.selectedOptionId
|
||
}"
|
||
> {{ String.fromCharCode(65 + Number(optIdx)) }}</span>
|
||
<span class="report-option-text">{{ opt.label }}</span>
|
||
</div>
|
||
|
||
<div v-if="!row.question" class="text-sm text-secondary">
|
||
<div class="mb-1">员工作答:{{ resolveReportAnswerLabel(undefined, row.answer) }}</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div v-if="!reportQuestionRows.length" class="text-center text-sm text-secondary py-8">
|
||
{{ $t('chat.training.hr.report.noReport') }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</Teleport>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.report-pdf-page {
|
||
width: 100%;
|
||
max-width: 794px;
|
||
min-height: 1123px;
|
||
margin: 0 auto;
|
||
box-sizing: border-box;
|
||
background: #fff;
|
||
}
|
||
|
||
.report-question-header {
|
||
display: grid;
|
||
grid-template-columns: minmax(0, 1fr) auto;
|
||
align-items: start;
|
||
gap: 1rem;
|
||
}
|
||
|
||
.report-question-title {
|
||
min-width: 0;
|
||
overflow-wrap: anywhere;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.report-filled-answer {
|
||
display: inline-block;
|
||
min-width: 5rem;
|
||
margin: 0 0.15rem;
|
||
padding: 0 0.25rem;
|
||
border-bottom: 1px solid currentColor;
|
||
color: #2563eb;
|
||
font-weight: 700;
|
||
text-align: center;
|
||
}
|
||
|
||
.report-answer-row {
|
||
color: #475569;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.report-employee-answer {
|
||
color: #2563eb;
|
||
font-weight: 700;
|
||
}
|
||
|
||
.report-essay-answer {
|
||
white-space: pre-wrap;
|
||
}
|
||
|
||
.report-question-result {
|
||
flex-shrink: 0;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.report-options {
|
||
display: grid;
|
||
gap: 0.5rem;
|
||
}
|
||
|
||
.report-header-info,
|
||
.report-question,
|
||
.report-option {
|
||
break-inside: avoid;
|
||
page-break-inside: avoid;
|
||
}
|
||
|
||
.report-question {
|
||
display: block;
|
||
}
|
||
|
||
.report-option {
|
||
display: grid;
|
||
grid-template-columns: 1.25rem minmax(0, 1fr);
|
||
align-items: start;
|
||
column-gap: 0.5rem;
|
||
min-width: 0;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.report-option-marker {
|
||
display: inline-flex;
|
||
width: 1.25rem;
|
||
height: 1.25rem;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
border-width: 1px;
|
||
border-radius: 9999px;
|
||
font-size: 0.75rem;
|
||
line-height: 1;
|
||
}
|
||
|
||
.report-option-text {
|
||
min-width: 0;
|
||
overflow-wrap: anywhere;
|
||
}
|
||
|
||
@media print {
|
||
body > *:not(.report-print-container) {
|
||
display: none !important;
|
||
}
|
||
.report-print-container {
|
||
position: absolute !important;
|
||
left: 0 !important;
|
||
top: 0 !important;
|
||
width: 794px !important;
|
||
max-width: none !important;
|
||
min-height: 1123px !important;
|
||
margin: 0 !important;
|
||
padding: 0 !important;
|
||
overflow: visible !important;
|
||
background: white !important;
|
||
}
|
||
.report-pdf-page {
|
||
width: 794px !important;
|
||
max-width: none !important;
|
||
min-height: 1123px !important;
|
||
margin: 0 !important;
|
||
padding: 32px !important;
|
||
}
|
||
}
|
||
</style>
|