- 新增 shared/utils/redirect.ts 安全回跳校验(防开放重定向) - 路由守卫未登录跳转携带 redirect 完整深链,已登录访问登录页优先回跳 - 登录成功统一按 redirect 深链落地,支持企微卡片点击直达精益培训模块
2202 lines
116 KiB
Vue
2202 lines
116 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 { useRoute, useRouter } from 'vue-router';
|
||
import {
|
||
BookOpen,
|
||
Bell,
|
||
CheckCircle2,
|
||
ChevronDown,
|
||
ChevronUp,
|
||
ClipboardCheck,
|
||
Download,
|
||
FileText,
|
||
PlayCircle,
|
||
RefreshCcw,
|
||
Share2,
|
||
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 TrainingShareModal from './TrainingShareModal.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, LeanTrainingMyTask, LeanTrainingTaskStatus, LeanTrainingVideo } 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 > 1);
|
||
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 = () => {
|
||
// 精益任务视频:仅当播放到结尾才记录观看完成(配合防拖拽保证按时长完整观看)
|
||
if (activeLeanVideo.value) {
|
||
workspace.markLeanVideoWatched(activeLeanVideo.value.taskId, activeLeanVideo.value.resourceId);
|
||
msg.success(t('chat.training.lean.videoWatchedToast'));
|
||
activeLeanVideo.value = null;
|
||
}
|
||
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);
|
||
};
|
||
|
||
// [STEP] 培训深链支持:/chat/<agentId>?training_type=<培训类型code>
|
||
// 来源 1:企微“和信AI智能工作台”精益提醒卡片(training_type=lean_management&weekly_task_id=<id>)
|
||
// 来源 2:员工培训分享链接(HR 在分享弹窗复制/生成二维码,员工扫码或点击后进入)
|
||
// AI 触发时机:员工/HR 从企微卡片或分享链接点入时,自动展开并定位到对应培训模块,
|
||
// 无需手动点页签,保证“点击直达”体验;精益卡片的管理员仍直达管理端精益看板。
|
||
const route = useRoute();
|
||
const router = useRouter();
|
||
let trainingDeepLinkConsumed = false;
|
||
watch(
|
||
() => [workspace.isTrainingAgent, Boolean(props.currentUser), workspace.canManageTrainingWorkspace] as const,
|
||
([isTraining, loggedIn]) => {
|
||
// 仅在培训 Agent 且登录态就绪后消费一次,避免身份权限异步未加载时误判视图归属
|
||
if (!isTraining || !loggedIn || trainingDeepLinkConsumed) return;
|
||
const targetTrainingType = String(route.query.training_type || '').trim();
|
||
if (!targetTrainingType) return;
|
||
trainingDeepLinkConsumed = true;
|
||
if (targetTrainingType === 'lean_management' && workspace.canManageTrainingWorkspace) {
|
||
// 兼容企微精益提醒卡片:管理员直达管理端精益看板,学员进学员侧精益学习页。
|
||
workspace.activeView = 'admin';
|
||
workspace.hrTrainingTab = 'lean';
|
||
} else {
|
||
// 分享链接与其余培训类型:统一进员工培训页并定位到目标模块
|
||
//(learnerTab 直接赋值即可,loadTrainingTypes 拉取后若类型有效会保留)。
|
||
workspace.activeView = 'learner';
|
||
workspace.learnerTab = targetTrainingType;
|
||
}
|
||
setWorkspaceExpanded(true, true);
|
||
// 消费后清理深链参数,避免刷新或二次分享时重复自动展开
|
||
void router.replace({ query: { ...route.query, training_type: undefined, weekly_task_id: undefined } });
|
||
},
|
||
{ immediate: true },
|
||
);
|
||
|
||
/**
|
||
* 组装当前培训模块的分享深链(绝对地址),供分享弹窗展示链接与生成二维码。
|
||
* AI 触发时机:有培训管理权限的用户点击“分享”时使用;必须带上 training_type 参数,
|
||
* 接收方登录后会自动定位到当前正在查看的培训模块。
|
||
*/
|
||
const shareModalOpen = ref(false);
|
||
const trainingShareUrl = computed(() => {
|
||
const agentId = workspace.currentTrainingAgentId;
|
||
if (!agentId) return '';
|
||
return `${window.location.origin}/chat/${agentId}?training_type=${encodeURIComponent(workspace.learnerTab)}`;
|
||
});
|
||
const trainingShareName = computed(() => workspace.resolveTrainingTypeName(workspace.learnerTab));
|
||
|
||
/**
|
||
* 收起培训工作区并回到纯聊天页面。
|
||
* 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.canManageTrainingWorkspace],
|
||
() => {
|
||
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 activeNonSafetyVideoId = ref<number | null>(null);
|
||
const nonSafetyVideoMaterials = computed(() => workspace.publishedTrainingMaterials.filter((material) => (
|
||
material.resource?.fileType === 'video' && Boolean(material.resource.fileUrl)
|
||
)));
|
||
const activeNonSafetyVideo = computed(() => (
|
||
nonSafetyVideoMaterials.value.find((material) => material.id === activeNonSafetyVideoId.value)
|
||
|| nonSafetyVideoMaterials.value[0]
|
||
|| null
|
||
));
|
||
|
||
const selectNonSafetyVideo = (material: { id?: number | null; resource?: { fileUrl?: string } | null }) => {
|
||
if (!material.resource?.fileUrl) return;
|
||
if (workspace.currentViewingMaterialId !== material.id) {
|
||
workspace.stopMaterialTimer();
|
||
}
|
||
activeNonSafetyVideoId.value = material.id ?? null;
|
||
workspace.currentViewingMaterialId = material.id ?? null;
|
||
};
|
||
|
||
const startNonSafetyVideoTimer = () => {
|
||
if (activeNonSafetyVideo.value?.id != null) {
|
||
workspace.startMaterialTimer(activeNonSafetyVideo.value.id);
|
||
}
|
||
};
|
||
|
||
const stopNonSafetyVideoTimer = () => {
|
||
workspace.stopMaterialTimer();
|
||
};
|
||
|
||
watch([() => workspace.learnerTab, nonSafetyVideoMaterials], () => {
|
||
if (!nonSafetyVideoMaterials.value.some((material) => material.id === activeNonSafetyVideoId.value)) {
|
||
activeNonSafetyVideoId.value = nonSafetyVideoMaterials.value[0]?.id ?? null;
|
||
}
|
||
}, { immediate: true });
|
||
|
||
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 = () => {
|
||
// 提前关闭弹窗视为未完成观看:清空精益视频定位,不记录观看
|
||
activeLeanVideo.value = null;
|
||
workspace.showVideoModal = false;
|
||
currentPreviewVideoUrl.value = '';
|
||
stopVideoCountdown();
|
||
workspace.stopMaterialTimer();
|
||
};
|
||
|
||
/** 当前弹窗正在播放的精益任务视频定位(非精益视频播放时为 null),用于播放到结尾时记录对应任务与视频。 */
|
||
const activeLeanVideo = ref<{ taskId: number; resourceId: number } | null>(null);
|
||
|
||
/** 精益任务状态徽章样式与文案键映射:进行中 / 已延期 / 已完成。 */
|
||
const leanStatusMeta: Record<LeanTrainingTaskStatus, { badgeClass: string; labelKey: string }> = {
|
||
in_progress: { badgeClass: 'border-blue-200 bg-blue-50 text-blue-700', labelKey: 'chat.training.lean.taskStatus.in_progress' },
|
||
overdue: { badgeClass: 'border-red-200 bg-red-50 text-red-600', labelKey: 'chat.training.lean.taskStatus.overdue' },
|
||
completed: { badgeClass: 'border-emerald-200 bg-emerald-50 text-emerald-700', labelKey: 'chat.training.lean.taskStatus.completed' },
|
||
};
|
||
|
||
/** 看板总结弹框上下文:员工姓名 + 完整总结文案;为 null 时弹框关闭。 */
|
||
const summaryModal = ref<{ name: string; text: string } | null>(null);
|
||
|
||
/** 总结列预览截断:最多显示 15 个字,超出部分以省略号收尾,点击可弹框查看全文。 */
|
||
const truncateSummary = (text: string) => (text.length > 15 ? `${text.slice(0, 15)}…` : text);
|
||
|
||
/** 打开总结详情弹框:仅当该行有总结文案时可点击(无总结的行显示 "--" 不可点)。 */
|
||
const openSummaryModal = (name: string, text: string) => {
|
||
summaryModal.value = { name, text };
|
||
};
|
||
|
||
/** 视频缩略图取首帧地址:追加 #t=0.1 让浏览器在 preload=metadata 下渲染首帧画面。 */
|
||
const leanThumbSrc = (url?: string | null) => (url ? (url.includes('#') ? url : `${url}#t=0.1`) : '');
|
||
|
||
/**
|
||
* 打开精益任务视频弹窗播放。
|
||
* AI 触发时机:学员在精益管理时间树上点击任务视频缩略图时调用;无播放地址时给出提示且不打开弹窗。
|
||
* 注意:此处不记录观看,观看完成仅在视频播放到结尾(handleVideoEnded)时记录。
|
||
*/
|
||
const openLeanVideo = (task: LeanTrainingMyTask, video: LeanTrainingVideo) => {
|
||
if (!video.fileUrl) {
|
||
msg.warning(t('chat.training.lean.videoUnavailable'));
|
||
return;
|
||
}
|
||
activeLeanVideo.value = { taskId: task.id, resourceId: video.id };
|
||
workspace.showVideoModal = true;
|
||
currentPreviewVideoUrl.value = video.fileUrl;
|
||
};
|
||
|
||
/**
|
||
* 提交精益学习感悟前的友好校验:未看完全部已推送视频或感悟字数不足时仅提示,不发请求。
|
||
* AI 触发时机:学员点击某期任务的"提交学习感悟"按钮时调用。
|
||
*/
|
||
const handleLeanSubmit = (task: LeanTrainingMyTask) => {
|
||
const watchedCount = Object.keys(workspace.leanWatchedByTask[task.id] || {}).length;
|
||
if (watchedCount < task.videos.length) {
|
||
msg.warning(t('chat.training.lean.completeVideosFirst'));
|
||
return;
|
||
}
|
||
if ((workspace.leanSummaryByTask[task.id] || '').trim().length < task.minSummaryLength) {
|
||
msg.warning(t('chat.training.lean.summaryTooShort', { minSummaryLength: task.minSummaryLength }));
|
||
return;
|
||
}
|
||
void workspace.submitLeanTrainingCompletion(task.id);
|
||
};
|
||
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.canManageTrainingWorkspace"
|
||
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 && workspace.learnerTab === 'safety'"
|
||
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.learnerTab === 'safety' && workspace.safetyViewStage !== 'exam' && workspace.safetyViewStage !== 'result'"
|
||
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.canManageTrainingWorkspace"
|
||
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 && workspace.learnerTab === 'safety'"
|
||
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 flex flex-wrap items-center justify-between gap-2">
|
||
<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>
|
||
<!-- [STEP 1] 分享入口:仅培训管理权限可见,分享当前培训类型深链 -->
|
||
<button
|
||
v-if="workspace.canManageTrainingWorkspace"
|
||
type="button"
|
||
class="inline-flex flex-shrink-0 items-center gap-1.5 rounded-full bg-brand-600 px-4 py-2 text-sm font-semibold text-white shadow-md transition-all hover:bg-brand-700 hover:shadow-lg active:scale-95"
|
||
@click="shareModalOpen = true"
|
||
>
|
||
<Share2 class="h-4 w-4" />
|
||
{{ $t('chat.training.share.button') }}
|
||
</button>
|
||
</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>
|
||
<div v-if="workspace.learnerTab === 'lean_management'" class="col-span-full">
|
||
<div v-if="!workspace.leanMyTasks.length" class="rounded-2xl border border-dashed border-default bg-white px-6 py-12 text-center text-sm text-secondary">
|
||
{{ $t('chat.training.lean.learner.empty') }}
|
||
</div>
|
||
<!-- 时间树:后端按发布周期倒序返回,最新任务在最上方 -->
|
||
<div v-else class="rounded-2xl border border-emerald-200 bg-emerald-50/40 p-4">
|
||
<div class="text-base font-semibold text-primary">{{ $t('chat.training.lean.learner.title') }}</div>
|
||
<div class="relative mt-4">
|
||
<div class="absolute bottom-3 left-[7px] top-3 w-px bg-emerald-200" aria-hidden="true"></div>
|
||
<div v-for="(task, index) in workspace.leanMyTasks" :key="task.id" class="relative pl-7" :class="index > 0 ? 'pt-4' : ''">
|
||
<span class="absolute left-0 top-7 h-[15px] w-[15px] rounded-full border-[3px] bg-white" :class="task.taskStatus === 'completed' ? 'border-emerald-500' : task.taskStatus === 'overdue' ? 'border-red-400' : 'border-blue-500'" aria-hidden="true"></span>
|
||
<article class="rounded-2xl border border-default bg-white p-4">
|
||
<div class="flex flex-wrap items-start justify-between gap-2">
|
||
<div>
|
||
<!-- 期号优先用后端 weekIndex(按周次升序,最早为第 1 期),与管理端口径一致;旧数据兜底按返回顺序倒推编号 -->
|
||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.lean.learner.taskTitle', { index: task.weekIndex ?? workspace.leanMyTasks.length - index }) }}</div>
|
||
<div class="mt-1 text-xs text-secondary">{{ $t('chat.training.lean.learner.description', { count: task.videos.length, minSummaryLength: task.minSummaryLength }) }}</div>
|
||
</div>
|
||
<div class="flex flex-wrap items-center gap-2">
|
||
<span class="rounded-full border px-3 py-1 text-xs font-medium" :class="leanStatusMeta[task.taskStatus].badgeClass">{{ $t(leanStatusMeta[task.taskStatus].labelKey) }}</span>
|
||
<span class="rounded-full bg-surface-soft px-3 py-1 text-xs text-secondary">{{ $t('chat.training.lean.learner.taskPeriod', { start: task.weekKey, end: task.dueAt.slice(0, 10) }) }}</span>
|
||
</div>
|
||
</div>
|
||
<!-- 任务视频缩略图:点击弹出播放器完成学习并记录观看 -->
|
||
<div class="mt-3 grid gap-3 md:grid-cols-2">
|
||
<div v-for="video in task.videos" :key="video.id" class="overflow-hidden rounded-xl border border-default bg-surface-soft">
|
||
<button type="button" class="group relative block h-32 w-full" @click="openLeanVideo(task, video)">
|
||
<video v-if="video.fileUrl" :src="leanThumbSrc(video.fileUrl)" preload="metadata" muted playsinline class="h-full w-full object-cover"></video>
|
||
<div v-else class="flex h-full w-full items-center justify-center text-secondary"><Video class="h-8 w-8" /></div>
|
||
<span class="absolute inset-0 flex items-center justify-center transition group-hover:bg-slate-900/20">
|
||
<PlayCircle class="h-9 w-9 text-white drop-shadow" />
|
||
</span>
|
||
<!-- 观看完成标记:服务端持久化,刷新后仍显示 -->
|
||
<span v-if="(workspace.leanWatchedByTask[task.id] || {})[String(video.id)]" class="absolute top-2 right-2 rounded-full bg-emerald-500 px-2 py-0.5 text-xs font-medium text-white shadow">{{ $t('chat.training.lean.videoWatchedBadge') }}</span>
|
||
</button>
|
||
<div class="p-3">
|
||
<div class="flex items-center gap-2 text-sm font-medium text-primary"><Video class="h-4 w-4 shrink-0 text-emerald-600" /><span class="truncate">{{ video.name }}</span></div>
|
||
<div class="mt-1 text-xs" :class="(workspace.leanWatchedByTask[task.id] || {})[String(video.id)] ? 'text-emerald-600' : 'text-secondary'">
|
||
{{ (workspace.leanWatchedByTask[task.id] || {})[String(video.id)] ? $t('chat.training.lean.watchedAt', { time: ((workspace.leanWatchedByTask[task.id] || {})[String(video.id)] || '').slice(0, 16).replace('T', ' ') }) : $t('chat.training.lean.markVideoWatched') }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- 已完成:只读展示已提交感悟与完成时间;进行中/已延期:可继续编辑并提交 -->
|
||
<div v-if="task.taskStatus === 'completed' && task.completion" class="mt-3 rounded-xl bg-emerald-50/60 p-3">
|
||
<div class="text-xs font-medium text-emerald-700">{{ $t('chat.training.lean.learner.completedSummary') }}<template v-if="task.completion.completedAt"> · {{ $t('chat.training.lean.learner.completedAt', { time: task.completion.completedAt.slice(0, 16).replace('T', ' ') }) }}</template></div>
|
||
<p class="mt-1 whitespace-pre-wrap text-sm text-primary">{{ task.completion.summaryText }}</p>
|
||
</div>
|
||
<template v-else>
|
||
<textarea v-model="workspace.leanSummaryByTask[task.id]" rows="4" class="mt-3 w-full rounded-xl border border-default bg-white p-3 text-sm" :placeholder="$t('chat.training.lean.summaryPlaceholder', { minSummaryLength: task.minSummaryLength })" />
|
||
<div class="mt-2 flex items-center justify-between gap-3">
|
||
<span class="text-xs" :class="(workspace.leanSummaryByTask[task.id] || '').length >= task.minSummaryLength ? 'text-emerald-600' : 'text-amber-600'">{{ $t('chat.training.lean.summaryLength', { current: (workspace.leanSummaryByTask[task.id] || '').length, minSummaryLength: task.minSummaryLength }) }}</span>
|
||
<!-- 未看完视频/字数不足时不静默禁用,点击由 handleLeanSubmit 给出友好提示 -->
|
||
<button type="button" class="rounded-xl bg-emerald-600 px-4 py-2 text-sm font-medium text-white" @click="handleLeanSubmit(task)">{{ $t('chat.training.lean.submitSummary') }}</button>
|
||
</div>
|
||
</template>
|
||
</article>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<template v-if="workspace.learnerTab !== 'safety' && workspace.learnerTab !== 'lean_management'">
|
||
<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 v-if="activeNonSafetyVideo" class="mt-3 overflow-hidden rounded-2xl border border-default bg-black shadow-lg">
|
||
<video
|
||
:key="activeNonSafetyVideo.id ?? activeNonSafetyVideo.resource?.fileUrl"
|
||
controls
|
||
playsinline
|
||
preload="metadata"
|
||
class="aspect-video w-full"
|
||
:src="activeNonSafetyVideo.resource?.fileUrl"
|
||
@play="startNonSafetyVideoTimer"
|
||
@pause="stopNonSafetyVideoTimer"
|
||
@ended="stopNonSafetyVideoTimer"
|
||
/>
|
||
</div>
|
||
<div v-else class="mt-3 rounded-2xl border border-dashed border-default bg-surface-soft px-4 py-10 text-center text-sm text-muted">
|
||
{{ $t('chat.training.video.empty') }}
|
||
</div>
|
||
<div v-if="nonSafetyVideoMaterials.length > 1" class="mt-3 grid gap-2 sm:grid-cols-2">
|
||
<button
|
||
v-for="(material, index) in nonSafetyVideoMaterials"
|
||
:key="material.id || `${material.resourceType}-${material.sortOrder}`"
|
||
type="button"
|
||
class="flex min-w-0 items-center gap-2 rounded-xl border px-3 py-2.5 text-left text-sm transition"
|
||
:class="activeNonSafetyVideo?.id === material.id ? 'border-brand-300 bg-brand-50 text-brand-700' : 'border-default bg-white text-primary hover:border-brand-200'"
|
||
@click="selectNonSafetyVideo(material)"
|
||
>
|
||
<Video class="h-4 w-4 shrink-0" />
|
||
<span class="min-w-0 flex-1 truncate">{{ material.title || material.resource?.fileName || `${$t('chat.training.video.playerTitle')} ${index + 1}` }}</span>
|
||
</button>
|
||
</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-if="showLearnerProgressModule" :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-if="workspace.learnerTab === 'safety'">
|
||
<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>
|
||
<div class="inline-flex flex-wrap rounded-xl border border-default bg-surface-soft p-1">
|
||
<button
|
||
v-for="tab in [{ key: 'all', label: 'chat.training.hr.tabs.allTraining' }, { key: 'lean', label: 'chat.training.hr.tabs.leanManagement' }]"
|
||
:key="tab.key"
|
||
class="flex items-center gap-2 rounded-lg px-6 py-2 text-sm font-medium transition"
|
||
:class="workspace.hrTrainingTab === tab.key ? 'bg-white text-brand-700 shadow-sm border border-brand-200' : 'text-secondary hover:text-primary'"
|
||
@click="workspace.hrTrainingTab = tab.key as 'all' | 'lean'"
|
||
>
|
||
{{ $t(tab.label) }}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<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.hrTrainingTab === 'lean' ? workspace.leanStats.total : 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(workspace.hrTrainingTab === 'lean' ? 'chat.training.lean.status.completed' : 'chat.training.hr.stats.passed') }}</div>
|
||
<div class="text-2xl font-semibold text-emerald-600">{{ workspace.hrTrainingTab === 'lean' ? workspace.leanStats.passed : 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(workspace.hrTrainingTab === 'lean' ? 'chat.training.lean.status.overdue' : 'chat.training.hr.stats.failed') }}</div>
|
||
<div class="text-2xl font-semibold text-amber-600">{{ workspace.hrTrainingTab === 'lean' ? workspace.leanStats.failed : 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.hrTrainingTab === 'lean' ? workspace.leanStats.inProgress : 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(workspace.hrTrainingTab === 'lean' ? 'chat.training.lean.dashboard.passRate' : 'chat.training.hr.stats.passRate') }}</div>
|
||
<div class="text-2xl font-semibold text-primary">{{ workspace.hrTrainingTab === 'lean' ? workspace.leanStats.passRate : workspace.stats.passRate }}%</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="workspace.hrTrainingTab === 'all'" 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>
|
||
|
||
<!-- 精益管理页签内容:仅当页签切到 lean 且当前用户可见时展示;看板保持单期任务,状态列区分已完成/已延期/进行中。 -->
|
||
<div v-if="workspace.hrTrainingTab === 'lean' && workspace.canViewLeanDashboard && workspace.leanDashboard.task" class="rounded-2xl border border-emerald-200 bg-emerald-50/40 p-4 shadow-sm">
|
||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||
<div>
|
||
<div class="flex items-center gap-2 text-base font-semibold text-primary">
|
||
<BookOpen class="h-4 w-4 text-emerald-600" />
|
||
{{ $t('chat.training.lean.dashboard.title') }}
|
||
</div>
|
||
<div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-secondary">
|
||
<span>{{ $t('chat.training.lean.dashboard.week', { week: workspace.leanDashboard.task.weekKey }) }}</span>
|
||
<span class="rounded-full bg-white px-2.5 py-1 font-medium text-emerald-700">{{ $t('chat.training.lean.dashboard.count', { count: workspace.leanRows.length }) }}</span>
|
||
<!-- 期次下拉:期号按周次升序区分第几期任务,切换后重拉对应期看板与精益统计。 -->
|
||
<select
|
||
v-if="workspace.leanDashboard.periods.length"
|
||
class="rounded-lg border border-default bg-white px-2 py-1 text-xs font-medium text-primary"
|
||
:value="workspace.leanDashboardTaskId ?? workspace.leanDashboard.task.id"
|
||
@change="workspace.selectLeanDashboardPeriod(Number(($event.target as HTMLSelectElement).value))"
|
||
>
|
||
<option v-for="period in workspace.leanDashboard.periods" :key="period.id" :value="period.id">{{ $t('chat.training.lean.dashboard.periodLabel', { index: period.index }) }}({{ period.weekKey }})</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="rounded-full bg-white px-3 py-1 text-xs font-medium text-emerald-700">{{ $t('chat.training.lean.dueAt', { time: workspace.leanDashboard.task.dueAt.slice(0, 16).replace('T', ' ') }) }}</div>
|
||
</div>
|
||
|
||
<!-- 用户复测要求:不再分"已完成/未完成"双列,合为单一明细表,仅通过状态列区分已完成/已延期/进行中。 -->
|
||
<div class="mt-4 overflow-hidden rounded-2xl border border-default bg-white">
|
||
<div class="overflow-x-auto">
|
||
<table class="w-full min-w-[900px] 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.lean.columns.employeeId') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.lean.columns.name') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.lean.columns.department') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.lean.columns.videoName') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.lean.columns.watchedAt') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.lean.columns.status') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.lean.columns.summary') }}</th>
|
||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.lean.columns.action') }}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr v-for="row in workspace.leanRows" :key="row.userId" class="odd:bg-white even:bg-surface-soft/30">
|
||
<td class="whitespace-nowrap border-b border-default px-3 py-2.5 text-secondary">{{ row.employeeId || '--' }}</td>
|
||
<td class="whitespace-nowrap border-b border-default px-3 py-2.5 font-medium text-primary">{{ row.name }}</td>
|
||
<td class="whitespace-nowrap border-b border-default px-3 py-2.5 text-secondary">{{ row.department || '--' }}</td>
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary"><div v-for="video in row.videos" :key="video.name" class="whitespace-nowrap">{{ video.name }}</div><span v-if="!row.videos.length">--</span></td>
|
||
<!-- [RULE] 观看时间仅展示到分钟(slice(0,16) 去掉秒),与产品要求一致。 -->
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary"><div v-for="video in row.videos" :key="`${video.name}-${video.watchedAt}`" class="whitespace-nowrap">{{ video.watchedAt ? video.watchedAt.slice(0, 16).replace('T', ' ') : '--' }}</div><span v-if="!row.videos.length">--</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="row.status === 'completed' ? 'bg-emerald-50 text-emerald-700' : row.status === 'overdue' ? 'bg-red-50 text-red-700' : 'bg-blue-50 text-blue-700'">{{ $t(`chat.training.lean.status.${row.status}`) }}</span></td>
|
||
<!-- [RULE] 总结列最多显示 15 个字:超出截断并显示省略号,点击弹框查看全部文案;无总结显示 "--"。
|
||
常显虚线下划线提示可点击(用户复测反馈点击无效,实为部署版本差异,此处强化可点性视觉)。 -->
|
||
<td class="border-b border-default px-3 py-2.5 text-secondary">
|
||
<button v-if="row.summaryText" type="button" class="max-w-56 cursor-pointer text-left whitespace-pre-wrap break-words underline decoration-dotted decoration-secondary/60 underline-offset-2 transition hover:decoration-solid hover:text-primary" :title="$t('chat.training.lean.summaryModal.viewHint')" @click="openSummaryModal(row.name, row.summaryText)">{{ truncateSummary(row.summaryText) }}</button>
|
||
<span v-else>--</span>
|
||
</td>
|
||
<!-- 仅未完成(进行中/已延期)提供提醒操作,已完成无需催办。 -->
|
||
<td class="border-b border-default px-3 py-2.5">
|
||
<button
|
||
v-if="row.status !== 'completed'"
|
||
type="button"
|
||
class="inline-flex whitespace-nowrap items-center gap-1.5 rounded-lg bg-amber-500 px-2.5 py-1.5 text-xs font-medium text-white transition hover:bg-amber-600 disabled:cursor-not-allowed disabled:opacity-60"
|
||
:disabled="workspace.leanReminderLoading[row.userId]"
|
||
@click="workspace.remindLeanTrainingMember(row.userId)"
|
||
>
|
||
<Bell class="h-3.5 w-3.5" />
|
||
{{ workspace.leanReminderLoading[row.userId] ? $t('chat.training.lean.reminder.sending') : $t('chat.training.lean.reminder.action') }}
|
||
</button>
|
||
<span v-else class="text-secondary">--</span>
|
||
</td>
|
||
</tr>
|
||
<tr v-if="!workspace.leanRows.length">
|
||
<td colspan="8" class="px-4 py-6 text-center text-sm text-muted">{{ $t('chat.training.lean.dashboard.empty') }}</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</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"
|
||
/>
|
||
|
||
<!-- 员工培训分享弹窗:复制链接 / 下载二维码,接收方登录后自动定位到对应培训模块。 -->
|
||
<TrainingShareModal
|
||
v-model:open="shareModalOpen"
|
||
:share-url="trainingShareUrl"
|
||
:training-name="trainingShareName"
|
||
/>
|
||
|
||
<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>
|
||
<!-- 总结详情弹框:看板总结列最多预览 15 字,点击后在此查看完整文案(点击遮罩或关闭按钮关闭)。 -->
|
||
<div v-if="summaryModal" class="fixed inset-0 z-[110] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="summaryModal = null">
|
||
<div class="w-full max-w-lg rounded-2xl bg-white p-5 shadow-2xl">
|
||
<div class="flex items-start justify-between gap-3">
|
||
<div>
|
||
<h3 class="text-base font-semibold text-primary">{{ $t('chat.training.lean.summaryModal.title') }}</h3>
|
||
<p class="mt-0.5 text-xs text-secondary">{{ summaryModal.name }}</p>
|
||
</div>
|
||
<button type="button" class="flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-secondary transition hover:bg-surface-soft hover:text-primary" :aria-label="$t('chat.training.lean.summaryModal.close')" @click="summaryModal = null">
|
||
<XCircle class="h-5 w-5" />
|
||
</button>
|
||
</div>
|
||
<div class="mt-4 max-h-96 overflow-y-auto whitespace-pre-wrap break-words rounded-xl bg-surface-soft/60 p-4 text-sm leading-relaxed text-secondary">{{ summaryModal.text }}</div>
|
||
</div>
|
||
</div>
|
||
</Teleport>
|
||
</template>
|
||
|
||
<style scoped>
|
||
/* 期次下拉自绘右置箭头:与全局 .select-field 同思路但尺寸紧凑(text-xs 头部场景)。
|
||
[FIX] 用户复测反馈箭头压住日期数字:appearance-none 移除原生箭头,箭头整体右移贴边
|
||
(距右缘 0.3rem),配合 pr-8 预留 2rem 空间,确保与文案完全无重叠。 */
|
||
.lean-period-select {
|
||
background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
|
||
background-position: calc(100% - 0.55rem) 50%, calc(100% - 0.3rem) 50%;
|
||
background-repeat: no-repeat;
|
||
background-size: 0.3rem 0.3rem, 0.3rem 0.3rem;
|
||
}
|
||
|
||
.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>
|