feat(员工培训): 完善新人入职培训聊天闭环交互

This commit is contained in:
runny committed 2026-06-30 13:25:17 +08:00
1 parent eb0466245b
commit 3f13bb5b46
19 files changed
+2975 -12

No files matched your search

@@ -174,9 +174,9 @@ watch(
</script>
<template>
<footer class="safe-bottom sticky bottom-0 z-20 bg-transparent p-3 md:p-6">
<footer class="safe-bottom z-20 shrink-0 bg-transparent p-2 md:p-3">
<div class="relative mx-auto max-w-4xl">
<div class="flex flex-col rounded-2xl bg-surface p-2 shadow-[0_0_15px_rgba(0,0,0,0.05)] transition-all">
<div class="flex flex-col rounded-2xl bg-surface p-1.5 shadow-[0_0_15px_rgba(0,0,0,0.05)] transition-all">
<div
v-if="isShippingNoticeAgent && shippingFocusTaskNo"
class="mb-2 flex items-center gap-2 rounded-xl bg-brand-500 px-3 py-2 text-xs font-medium text-white"
@@ -198,8 +198,8 @@ watch(
v-model="inputValue"
rows="1"
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : shippingFocusTaskNo ? $t('chat.shippingNoticeUi.focusInputPlaceholder', { taskId: shippingFocusTaskNo }) : $t('chat.askAnything')"
class="w-full resize-none border-none bg-transparent px-3 py-2 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
style="min-height: 44px; max-height: 220px;"
class="w-full resize-none border-none bg-transparent px-2.5 py-1.5 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
style="min-height: 40px; max-height: 220px;"
:disabled="isVoiceTranscribing"
spellcheck="false"
autocorrect="off"
@@ -253,7 +253,7 @@ watch(
<span>点发送开始处理</span>
</div>
<div class="mt-2 flex items-center justify-between px-2 pb-1">
<div class="mt-1.5 flex items-center justify-between px-1.5 pb-0.5">
<div class="flex items-center gap-3">
<button
type="button"
@@ -10,6 +10,7 @@ import ChatMessageBubble, { type ChatMessageBubbleHandlers } from './messages/Ch
import ToolRunProgressCard from './ToolRunProgressCard.vue';
import type { LeaveMessageHandlers } from './messages/LeaveMessageBlock.vue';
import type { ShippingMappingHandlers } from './messages/ShippingInventoryMappingMessage.vue';
import type { TrainingHandlers } from './messages/TrainingExamQuestionMessage.vue';
import type { ChatMessage } from '../types/chat.types';
import type { ToolRunProgress } from '../api/toolRunProgress.api';
@@ -31,6 +32,7 @@ const {
handlers: ChatMessageBubbleHandlers;
leaveHandlers: LeaveMessageHandlers;
shippingHandlers: ShippingMappingHandlers;
trainingHandlers: TrainingHandlers;
shouldRenderMessage: (msg: ChatMessage) => boolean;
shouldShowToolRunProgressAfterMessage: (msg: ChatMessage, index: number) => boolean;
getMessageRunProgress: (msg: ChatMessage) => ToolRunProgress | null;
@@ -39,6 +41,8 @@ const {
toolRunProgress: ToolRunProgress | null;
toolRunProgressTitle: string;
showScrollToBottom: boolean;
hideWelcomePanel?: boolean;
pinMessagesToBottom?: boolean;
/** 供父级滚动逻辑绑定 main 元素 */
scrollContainerHolder: { el: Ref<HTMLElement | null> };
}>();
@@ -74,9 +78,9 @@ const getMessageKey = (msg: ChatMessage, index: number) => (
class="flex-1 p-3 md:p-8"
:class="messages.length === 0 ? 'overflow-hidden md:overflow-y-auto' : 'overflow-y-auto scrollbar-thin'"
>
<div :class="messages.length === 0 ? 'h-full' : 'flex min-h-full flex-col justify-end'">
<div :class="messages.length === 0 ? 'h-full' : pinMessagesToBottom === false ? 'min-h-full' : 'flex min-h-full flex-col justify-end'">
<ChatWelcomePanel
v-if="messages.length === 0"
v-if="messages.length === 0 && !hideWelcomePanel"
:agent-name="agentName"
:suggested-questions-style="suggestedQuestionsStyle"
:styled-sections="styledSections"
@@ -97,6 +101,7 @@ const getMessageKey = (msg: ChatMessage, index: number) => (
:handlers="handlers"
:leave-handlers="leaveHandlers"
:shipping-handlers="shippingHandlers"
:training-handlers="trainingHandlers"
@copy="emit('copy', { message: msg, index })"
@edit="emit('edit', $event)"
@resend="emit('resend', $event)"
@@ -5,6 +5,7 @@
* 逻辑:本文件只做页面结构编排;发货批次进度样式与任务续办交互下沉到独立面板组件。
*/
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { Loader2 } from 'lucide-vue-next';
import ChatShell from '@/shared/layouts/ChatShell.vue';
import ChatSidebar from '@/features/chat/components/ChatSidebar.vue';
@@ -14,9 +15,19 @@ import ChatMobileHeader from '@/features/chat/components/ChatMobileHeader.vue';
import ChatBrowserPanel from '@/features/chat/components/ChatBrowserPanel.vue';
import ShippingBatchProgressPanel from '@/features/chat/components/ShippingBatchProgressPanel.vue';
import ShippingBatchWorkspaceDrawer from '@/features/chat/components/ShippingBatchWorkspaceDrawer.vue';
import TrainingWorkspacePanel from '@/features/chat/components/TrainingWorkspacePanel.vue';
import { useChatPageContext } from '@/features/chat/composables/chat.context';
import { matchesTrainingAgent } from '@/features/chat/composables/useTrainingWorkspace';
const page = useChatPageContext();
const isTrainingAgentPage = computed(() => matchesTrainingAgent(page.currentAgent));
const hideWelcomePanel = computed(() => isTrainingAgentPage.value);
const isTrainingWorkspaceExpanded = ref(false);
// 切换 Agent 时,重置工作区展开状态,确保每次进入都是收起状态(聊天优先)
watch(() => page.currentAgentId, () => {
isTrainingWorkspaceExpanded.value = false;
});
</script>
<template>
@@ -84,8 +95,18 @@ const page = useChatPageContext();
</div>
<template v-else>
<div class="flex min-h-0 flex-1">
<div class="flex min-h-0 flex-1 flex-col">
<div class="flex min-h-0 min-w-0 flex-1">
<div class="flex min-h-0 min-w-0 flex-1 flex-col">
<TrainingWorkspacePanel
:current-agent="page.currentAgent"
:current-user="page.currentUser"
:has-messages="page.messages.length > 0"
:training="page.training"
@send-chat-prompt="page.handleSend($event)"
@push-local-assistant-message="page.pushLocalAssistantMessage($event)"
@update:expanded="isTrainingWorkspaceExpanded = $event"
/>
<ShippingBatchProgressPanel
v-if="page.isShippingNoticeAgent && (page.shippingBatchSummary || page.activeShippingTaskDetail)"
:conversation-workspace="page.shippingConversationWorkspace"
@@ -99,6 +120,7 @@ const page = useChatPageContext();
/>
<ChatMessageList
v-show="!isTrainingWorkspaceExpanded"
:messages="page.messages"
:agent-name="page.currentAgent?.name || 'AI'"
:suggested-questions-style="page.suggestedQuestionsStyle"
@@ -112,6 +134,7 @@ const page = useChatPageContext();
:handlers="page.messageBubbleHandlers"
:leave-handlers="page.leaveMessageHandlers"
:shipping-handlers="page.shippingMappingHandlers"
:training-handlers="page.trainingHandlers"
:should-render-message="page.shouldRenderMessage"
:should-show-tool-run-progress-after-message="page.shouldShowToolRunProgressAfterMessage"
:get-message-run-progress="page.getMessageRunProgress"
@@ -120,6 +143,8 @@ const page = useChatPageContext();
:tool-run-progress="page.toolRunProgress"
:tool-run-progress-title="page.toolRunProgressTitle"
:show-scroll-to-bottom="page.showScrollToBottom"
:hide-welcome-panel="hideWelcomePanel"
:pin-messages-to-bottom="!isTrainingAgentPage"
:scroll-container-holder="page.scrollContainerHolder"
@copy="page.copyToClipboard($event.message, $event.index)"
@edit="page.input = $event"
@@ -131,6 +156,7 @@ const page = useChatPageContext();
/>
<ChatInputBar
v-show="!isTrainingWorkspaceExpanded"
:key="`${page.currentAgentId}-${page.conversationId || 'draft'}-${page.messages.length}`"
v-model="page.input"
v-model:selected-kb="page.selectedKb"
@@ -0,0 +1,821 @@
<script setup lang="ts">
/**
* features/chat/components/TrainingWorkspacePanel.vue
* 用途:在培训 Agent 的聊天页顶部提供“学员考试流 + HR 管理流”一体化工作区。
* 依赖:useTrainingWorkspace、lucide 图标、聊天页 currentAgent/currentUser。
* 逻辑:只在培训 Agent 下渲染;学员端负责前端交互闭环,HR 端负责本地筛选统计与 Excel 导出,并可把上下文同步回聊天区。
*/
import { computed, reactive, ref, watch, type ShallowUnwrapRef } from 'vue';
import { useI18n } from 'vue-i18n';
import {
BarChart3,
BookOpen,
CheckCircle2,
ChevronDown,
ChevronUp,
ClipboardCheck,
Download,
PlayCircle,
RefreshCcw,
Send,
ShieldCheck,
Target,
Users,
XCircle,
} from 'lucide-vue-next';
import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWorkspace';
const props = defineProps<{
currentAgent: Record<string, unknown> | null;
currentUser: Record<string, unknown> | null;
hasMessages: boolean;
training: ShallowUnwrapRef<ReturnType<typeof useTrainingWorkspace>>;
}>();
const emit = defineEmits<{
'send-chat-prompt': [prompt: string];
'push-local-assistant-message': [content: string];
'update:expanded': [expanded: boolean];
}>();
const { t } = useI18n();
const workspace = reactive(props.training);
// 将 workspace 内部控制弹窗的状态同步给组件本地变量(如果需要,或者直接用 workspace.showVideoModal)
const showVideoModal = computed({
get: () => workspace.showVideoModal,
set: (val) => { workspace.showVideoModal = val; }
});
const lastVideoTime = ref(0);
const stageStep = computed(() => {
if (workspace.stage === 'video') return 1;
if (workspace.stage === 'summary') return 2;
if (workspace.stage === 'exam') return 3;
return 4;
});
const stageItems = computed(() => ([
{ key: 'video', label: 'chat.training.steps.video', icon: PlayCircle },
{ key: 'summary', label: 'chat.training.steps.summary', icon: BookOpen },
{ key: 'exam', label: 'chat.training.steps.exam', icon: ClipboardCheck },
{ key: 'result', label: 'chat.training.steps.result', icon: ShieldCheck },
]));
const userExpandedOverride = ref(false);
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 = () => {
showVideoModal.value = false;
workspace.markVideoCompleted();
};
const setWorkspaceExpanded = (expanded: boolean, manual = false) => {
workspaceExpanded.value = expanded;
emit('update:expanded', expanded);
if (manual) {
userExpandedOverride.value = expanded;
} else if (!expanded) {
userExpandedOverride.value = false;
}
};
const sendPrompt = (prompt: string) => {
setWorkspaceExpanded(false);
emit('send-chat-prompt', prompt);
};
const currentAnswerLabel = computed(() => {
const question = workspace.currentQuestion;
if (!question) return '';
return question.options?.find((item) => item.id === workspace.selectedOptionId)?.label || '';
});
// 默认进入 Chat 聊天页面(即收起工作区状态)
const workspaceExpanded = ref(false);
const autoSyncInitialPrompt = () => {
if (workspace.isTrainingAgent && !props.hasMessages) {
emit('push-local-assistant-message', workspace.learnerChatPrompt);
}
};
// 监听 Agent 切换,重置所有本地交互状态,确保每次进入都是初始、收起且触发引导的状态
watch(
() => props.currentAgent?.id,
() => {
userExpandedOverride.value = false;
workspaceExpanded.value = false;
emit('update:expanded', false);
// 切换 Agent 后,如果是培训 Agent 且没有消息,立即触发引导
if (workspace.isTrainingAgent && !props.hasMessages) {
// 给予极短延迟确保其它状态同步完成
setTimeout(() => {
if (workspace.isTrainingAgent && !props.hasMessages) {
autoSyncInitialPrompt();
}
}, 300);
}
},
{ immediate: true }
);
watch(() => props.hasMessages, () => {
// 如果用户没有手动展开,且消息状态变化,我们保持在聊天模式(收起工作区)
if (!userExpandedOverride.value) {
workspaceExpanded.value = false;
emit('update:expanded', false);
}
});
const isCompactMode = computed(() => !workspaceExpanded.value);
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 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.answeredCount + 1,
total: workspace.totalQuestionCount,
});
}
return workspace.isPassed ? t('chat.training.result.passTitle') : t('chat.training.result.failTitle');
});
</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-2 bg-white/90 px-4 py-2.5 backdrop-blur-sm md:px-5"
>
<div class="flex flex-col gap-2 xl:flex-row xl:items-center xl:justify-between">
<div class="min-w-0">
<div class="flex flex-wrap items-center gap-2">
<div class="inline-flex items-center gap-2 rounded-full bg-brand-50 px-3 py-1 text-[11px] font-semibold text-brand-700">
<BookOpen class="h-3.5 w-3.5" />
{{ $t('chat.training.badge') }}
</div>
<div class="text-sm font-semibold text-primary md:text-base">
{{ $t('chat.training.title') }}
</div>
</div>
<div class="mt-1.5 flex flex-wrap gap-2">
<button
type="button"
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
:class="workspace.activeView === 'learner' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
@click="workspace.activeView = 'learner'"
>
{{ $t('chat.training.tabs.learner') }}
</button>
<button
v-if="workspace.isAdminViewer"
type="button"
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
:class="workspace.activeView === 'admin' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
@click="workspace.activeView = 'admin'"
>
{{ $t('chat.training.tabs.admin') }}
</button>
</div>
</div>
<div class="flex flex-wrap items-center justify-end gap-2">
<button
v-if="workspace.stage === 'video'"
type="button"
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-brand-200 bg-brand-50 px-3 py-2 text-xs font-medium text-brand-700 transition hover:bg-brand-100"
@click="showVideoModal = true"
>
<PlayCircle class="h-4 w-4" />
{{ $t('chat.training.steps.video') }}
</button>
<button
type="button"
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-default bg-white px-3 py-2 text-xs font-medium text-secondary transition hover:bg-surface-soft"
@click="sendPrompt(workspace.learnerChatPrompt)"
>
<Send class="h-4 w-4" />
{{ $t('chat.training.actions.syncLearnerToChat') }}
</button>
<button
v-if="workspace.isAdminViewer"
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="sendPrompt(workspace.managementChatPrompt)"
>
<BarChart3 class="h-4 w-4" />
{{ $t('chat.training.actions.syncHrToChat') }}
</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="setWorkspaceExpanded(true, true)"
>
<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-4 py-2.5 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>
<template v-else>
{{ $t('chat.training.progressPercent') }}: {{ workspace.learnerProgressPercent }}%
· {{ $t('chat.training.learnerCard.name') }}: {{ workspace.currentUserName }}
</template>
</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-2 bg-white/90 px-4 py-2.5 backdrop-blur-sm md:px-5">
<div class="flex flex-col gap-2 xl:flex-row xl:items-center xl:justify-between">
<div class="min-w-0">
<div class="flex flex-wrap items-center gap-2">
<div class="inline-flex items-center gap-2 rounded-full bg-brand-50 px-3 py-1 text-[11px] font-semibold text-brand-700">
<BookOpen class="h-3.5 w-3.5" />
{{ $t('chat.training.badge') }}
</div>
<div class="text-sm font-semibold text-primary md:text-base">
{{ $t('chat.training.title') }}
</div>
</div>
<div class="mt-1.5 flex flex-wrap gap-2">
<button
type="button"
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
:class="workspace.activeView === 'learner' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
@click="workspace.activeView = 'learner'"
>
{{ $t('chat.training.tabs.learner') }}
</button>
<button
v-if="workspace.isAdminViewer"
type="button"
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
:class="workspace.activeView === 'admin' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
@click="workspace.activeView = 'admin'"
>
{{ $t('chat.training.tabs.admin') }}
</button>
</div>
</div>
<div class="flex flex-wrap items-center justify-end gap-2">
<button
type="button"
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-default bg-white px-3 py-2 text-xs font-medium text-secondary transition hover:bg-surface-soft"
@click="sendPrompt(workspace.learnerChatPrompt)"
>
<Send class="h-4 w-4" />
{{ $t('chat.training.actions.syncLearnerToChat') }}
</button>
<button
v-if="workspace.isAdminViewer"
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="sendPrompt(workspace.managementChatPrompt)"
>
<BarChart3 class="h-4 w-4" />
{{ $t('chat.training.actions.syncHrToChat') }}
</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="setWorkspaceExpanded(false, true)"
>
<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-4 py-2.5 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>
<template v-else>
{{ $t('chat.training.progressPercent') }}: {{ workspace.learnerProgressPercent }}%
· {{ $t('chat.training.learnerCard.name') }}: {{ workspace.currentUserName }}
</template>
</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="grid gap-3 p-4 md:grid-cols-[minmax(0,1.25fr)_232px] md:p-5 lg:gap-4 lg:grid-cols-[minmax(0,1.4fr)_260px] 2xl:grid-cols-[minmax(0,1.55fr)_300px]">
<div class="min-w-0 space-y-4">
<div class="rounded-2xl border border-default bg-white p-4 shadow-sm">
<div class="flex flex-col gap-2.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 class="mt-1 text-xs leading-5 text-secondary md:text-sm">
{{ $t('chat.training.progressHint') }}
</div>
</div>
<div class="rounded-xl bg-surface-soft px-3 py-2 text-center">
<div class="text-xs text-muted">{{ $t('chat.training.progressPercent') }}</div>
<div class="text-lg font-semibold leading-none text-primary">{{ workspace.learnerProgressPercent }}%</div>
</div>
</div>
<div class="mt-3 grid grid-cols-2 gap-2 lg:grid-cols-4">
<div
v-for="(item, index) in stageItems"
:key="item.key"
class="rounded-xl border px-3 py-2.5 transition cursor-pointer hover:border-brand-300"
:class="stageStep >= index + 1 ? 'border-brand-200 bg-brand-50/70' : 'border-default bg-surface-soft/70'"
@click="workspace.stage = item.key as any"
>
<div class="flex items-center gap-2">
<div
class="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg"
:class="stageStep >= index + 1 ? 'bg-brand-600 text-white' : 'bg-white text-muted'"
>
<component :is="item.icon" class="h-4 w-4" />
</div>
<div class="min-w-0">
<div class="text-[11px] font-semibold uppercase tracking-[0.16em] text-muted">
{{ String(index + 1).padStart(2, '0') }}
</div>
<div class="whitespace-normal text-sm font-medium leading-5 text-primary">{{ $t(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 class="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
<div>
<h3 class="text-base font-semibold text-primary md:text-lg">{{ $t('chat.training.video.title') }}</h3>
<p class="mt-1 text-sm leading-6 text-secondary">{{ $t('chat.training.video.description') }}</p>
</div>
</div>
<div class="mt-3 relative group cursor-pointer overflow-hidden rounded-2xl border border-default bg-slate-900 shadow-lg aspect-video flex items-center justify-center" @click="showVideoModal = true">
<img src="https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=Professional%20corporate%20training%20video%20cover%2C%20high-quality%2C%20modern%20office%20background%2C%20play%20button%20overlay&image_size=landscape_16_9" class="absolute inset-0 w-full h-full object-cover opacity-60 group-hover:scale-105 transition-transform duration-500" />
<div class="relative z-10 flex flex-col items-center gap-3">
<div class="h-16 w-16 flex items-center justify-center rounded-full bg-white/20 backdrop-blur-md border border-white/30 group-hover:bg-brand-600 group-hover:border-brand-500 transition-all duration-300">
<PlayCircle class="h-8 w-8 text-white fill-white/20" />
</div>
<span class="text-white font-medium drop-shadow-md">{{ $t('chat.training.video.playerTitle') }}</span>
</div>
</div>
</div>
<div v-else-if="workspace.stage === 'summary'" class="rounded-2xl border border-default bg-white p-4 shadow-sm">
<div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
<div>
<h3 class="text-base font-semibold text-primary md:text-lg">{{ $t('chat.training.summary.title') }}</h3>
<p class="mt-1 text-sm leading-6 text-secondary">{{ $t('chat.training.summary.description') }}</p>
</div>
<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 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="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="text-xs font-semibold uppercase tracking-[0.18em] text-brand-600">
{{ $t('chat.training.exam.title') }}
</div>
<h3 class="mt-1 text-lg font-semibold text-primary">
{{ $t('chat.training.exam.questionCounter', { current: workspace.answeredCount + 1, total: workspace.totalQuestionCount }) }}
</h3>
</div>
<div class="flex flex-wrap gap-2 text-sm text-secondary">
<div class="rounded-xl bg-surface-soft px-3 py-1.5">
{{ $t('chat.training.exam.currentScore', { score: workspace.score }) }}
</div>
<div class="rounded-xl bg-surface-soft px-3 py-1.5">
{{ $t('chat.training.exam.passLine') }}
</div>
</div>
</div>
<div class="mt-4 rounded-2xl border border-brand-100 bg-brand-50/40 p-3.5">
<div class="text-base font-semibold leading-7 text-primary">
{{ workspace.currentQuestion.prompt }}
</div>
</div>
<div class="mt-3 grid gap-2.5">
<button
v-for="option in workspace.currentQuestion.options"
:key="option.id"
type="button"
class="rounded-2xl border px-4 py-2.5 text-left text-sm 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',
]"
:disabled="workspace.answerLocked"
@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-4 rounded-2xl border p-3.5"
:class="workspace.currentFeedbackCorrect ? 'border-emerald-200 bg-emerald-50/70' : 'border-red-200 bg-red-50/70'"
>
<div class="flex items-center gap-2 text-sm font-semibold" :class="workspace.currentFeedbackCorrect ? 'text-emerald-700' : 'text-red-700'">
<CheckCircle2 v-if="workspace.currentFeedbackCorrect" class="h-4 w-4" />
<XCircle v-else class="h-4 w-4" />
{{ workspace.currentFeedbackCorrect ? $t('chat.training.exam.correctFeedback') : $t('chat.training.exam.wrongFeedback') }}
</div>
<div class="mt-2 text-sm leading-6 text-secondary">
{{ $t('chat.training.exam.selectedAnswer', { answer: currentAnswerLabel || '--' }) }}
</div>
<div class="mt-1 text-sm leading-6 text-secondary">
{{ $t('chat.training.exam.correctAnswer', { answer: workspace.currentQuestion.options?.find((item) => item.id === workspace.currentQuestion?.answer)?.label || '--' }) }}
</div>
<div class="mt-2 text-sm leading-6 text-secondary">
{{ workspace.currentQuestion.explanation }}
</div>
<div class="mt-3">
<button
type="button"
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-brand-700"
@click="workspace.moveToNextQuestion"
>
<ClipboardCheck class="h-4 w-4" />
{{
workspace.answeredCount >= workspace.totalQuestionCount
? $t('chat.training.exam.finishExam')
: $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') }}
</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>
<button
type="button"
class="inline-flex items-center gap-2 rounded-xl border border-default bg-white px-4 py-2.5 text-sm font-medium text-secondary transition hover:bg-surface-soft"
@click="sendPrompt(workspace.learnerChatPrompt)"
>
<Send class="h-4 w-4" />
{{ $t('chat.training.result.sendToChat') }}
</button>
</div>
</div>
</div>
<div class="min-w-0 md:sticky md:top-4 md:self-start">
<div class="rounded-2xl border border-default bg-white p-3 shadow-sm">
<div class="flex items-center gap-2">
<Users class="h-4 w-4 text-brand-600" />
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.learnerCard.title') }}</div>
</div>
<div class="mt-2.5 grid gap-1.5 text-sm text-secondary">
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2">
<span>{{ $t('chat.training.learnerCard.name') }}</span>
<span class="font-medium text-primary">{{ workspace.currentUserName }}</span>
</div>
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2">
<span>{{ $t('chat.training.learnerCard.employeeId') }}</span>
<span class="font-medium text-primary">{{ workspace.currentUserEmployeeId }}</span>
</div>
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2">
<span>{{ $t('chat.training.learnerCard.department') }}</span>
<span class="font-medium text-primary">{{ workspace.currentUserDepartment }}</span>
</div>
</div>
<div class="my-3 h-px bg-slate-100" />
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.rules.title') }}</div>
<ul class="mt-2 grid gap-1 text-xs leading-5 text-secondary">
<li class="flex gap-2">
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
<span>{{ $t('chat.training.rules.rule1') }}</span>
</li>
<li class="flex gap-2">
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
<span>{{ $t('chat.training.rules.rule2') }}</span>
</li>
<li class="flex gap-2">
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
<span>{{ $t('chat.training.rules.rule3') }}</span>
</li>
<li class="flex gap-2">
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
<span>{{ $t('chat.training.rules.rule4') }}</span>
</li>
</ul>
</div>
</div>
</div>
<div v-else-if="!isCompactMode" class="space-y-4 p-4 md:p-5">
<div class="grid gap-3 sm:grid-cols-2 xl:grid-cols-5">
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.total') }}</div>
<div class="mt-1.5 text-xl font-semibold text-primary">{{ workspace.stats.total }}</div>
</div>
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.passed') }}</div>
<div class="mt-1.5 text-xl font-semibold text-emerald-600">{{ workspace.stats.passed }}</div>
</div>
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.failed') }}</div>
<div class="mt-1.5 text-xl font-semibold text-amber-600">{{ workspace.stats.failed }}</div>
</div>
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.inProgress') }}</div>
<div class="mt-1.5 text-xl font-semibold text-blue-600">{{ workspace.stats.inProgress }}</div>
</div>
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.passRate') }}</div>
<div class="mt-1.5 text-xl font-semibold text-primary">{{ workspace.stats.passRate }}%</div>
</div>
</div>
<div class="rounded-2xl border border-default bg-white p-4 shadow-sm">
<div class="flex flex-col gap-3">
<div class="grid gap-3 xl:grid-cols-3">
<label class="space-y-1.5">
<span class="text-xs font-semibold uppercase tracking-[0.14em] text-muted">{{ $t('chat.training.hr.filters.keywordLabel') }}</span>
<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 class="space-y-1.5">
<span class="text-xs font-semibold uppercase tracking-[0.14em] text-muted">{{ $t('chat.training.hr.filters.statusLabel') }}</span>
<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 class="space-y-1.5">
<span class="text-xs font-semibold uppercase tracking-[0.14em] text-muted">{{ $t('chat.training.hr.filters.departmentLabel') }}</span>
<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>
<div class="flex flex-wrap items-center justify-end gap-2">
<button
type="button"
class="inline-flex h-10 items-center gap-2 rounded-xl border border-default bg-white px-4 text-xs font-medium text-secondary transition hover:bg-surface-soft sm:text-sm"
@click="sendPrompt(workspace.managementChatPrompt)"
>
<Send class="h-4 w-4" />
{{ $t('chat.training.hr.actions.askAgent') }}
</button>
<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 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.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.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">{{ 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">
<span
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
:class="record.status === 'passed'
? 'bg-emerald-50 text-emerald-700'
: record.status === 'failed'
? 'bg-amber-50 text-amber-700'
: 'bg-blue-50 text-blue-700'"
>
{{ $t(`chat.training.hr.status.${record.status}`) }}
</span>
</td>
</tr>
<tr v-if="workspace.filteredRecords.length === 0">
<td colspan="8" class="px-4 py-6 text-center text-sm text-muted">
{{ $t('chat.training.hr.empty') }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<Teleport to="body">
<div v-if="showVideoModal" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="showVideoModal = false">
<div class="relative w-full max-w-4xl overflow-hidden rounded-3xl bg-black shadow-2xl">
<button @click="showVideoModal = false" class="absolute top-4 right-4 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20 transition backdrop-blur-md">
<XCircle class="h-6 w-6" />
</button>
<div class="aspect-video bg-black">
<video
ref="videoPlayer"
controls
autoplay
class="h-full w-full"
@timeupdate="handleVideoTimeUpdate"
@seeking="handleVideoSeeking"
@ended="handleVideoEnded"
>
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</div>
</div>
</Teleport>
</template>
@@ -11,6 +11,10 @@ import LeaveMessageBlock, { type LeaveMessageHandlers } from './LeaveMessageBloc
import ShippingInventoryMappingMessage, { type ShippingMappingHandlers } from './ShippingInventoryMappingMessage.vue';
import ShippingMatchResultCard from './ShippingMatchResultCard.vue';
import ShippingParseReviewMessage, { type ShippingParseReviewHandlers } from './ShippingParseReviewMessage.vue';
import TrainingExamQuestionMessage, { type TrainingHandlers } from './TrainingExamQuestionMessage.vue';
import TrainingVideoMessage from './TrainingVideoMessage.vue';
import TrainingSummaryMessage from './TrainingSummaryMessage.vue';
import TrainingResultCard from './TrainingResultCard.vue';
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../../types/chat.types';
import type { ShippingInventoryMappingFormPayload, ShippingMatchResultPayload } from '../../types/shipping.types';
@@ -57,6 +61,7 @@ const {
handlers: ChatMessageBubbleHandlers;
leaveHandlers: LeaveMessageHandlers;
shippingHandlers: ShippingMappingHandlers;
trainingHandlers: TrainingHandlers;
}>();
const emit = defineEmits<{
@@ -73,6 +78,35 @@ const isLeaveMessage = computed(() =>
|| message.type === 'leave-result',
);
const isTrainingExamMessage = computed(() => {
if (message.role !== 'assistant') return false;
// 必须是最后一条助手消息,且包含题目特征文字(确保只在当前正在进行的题目上显示交互组件)
if (!isLastMessage.value) return false;
const content = message.content || '';
return content.includes('正在进行新人培训考试')
|| (content.includes('第') && content.includes('题') && (content.includes('共') || content.includes('/')));
});
const isTrainingVideoMessage = computed(() => {
if (message.role !== 'assistant') return false;
// 只要包含特定引导文案,就显示视频占位符,不限于最后一条消息
const content = message.content || '';
return content.includes('专属入职培训助手') || (content.includes('看视频') && content.includes('已看完'));
});
const isTrainingSummaryMessage = computed(() => {
if (message.role !== 'assistant') return false;
const content = message.content || '';
return content.includes('完成视频学习') || content.includes('复盘重点知识') || content.includes('复盘知识点') || content.includes('总结重点知识');
});
const isTrainingResultMessage = computed(() => {
if (message.role !== 'assistant') return false;
// 只要是结果文案,就显示结算卡片,不限于最后一条消息
const content = message.content || '';
return content.includes('考试结束') || content.includes('顺利通过新人考核');
});
const retrieverResources = computed(() => handlers.getDisplayRetrieverResources(message));
const sourceLinks = computed(() => handlers.getSourceLinks(retrieverResources.value));
@@ -480,13 +514,51 @@ function handleInlineDownload(file: InlineDownloadFile): void {
:action-button-class="handlers.shippingActionButtonClass"
:on-action-click="(action) => handlers.onShippingActionClick(message, action)"
/>
<TrainingExamQuestionMessage
v-else-if="isTrainingExamMessage && trainingHandlers.getQuestion()"
:question="trainingHandlers.getQuestion()!"
:current-question-index="trainingHandlers.getCurrentQuestionIndex()"
:answered-count="trainingHandlers.getAnsweredCount()"
:total-count="trainingHandlers.getTotalCount()"
:score="trainingHandlers.getScore()"
:selected-option-id="trainingHandlers.getSelectedOptionId()"
:answer-locked="trainingHandlers.getAnswerLocked()"
:feedback-correct="trainingHandlers.getFeedbackCorrect()"
:answer-label="trainingHandlers.getAnswerLabel()"
:is-thinking="isThinking"
@select="trainingHandlers.onSelect"
@next="trainingHandlers.onNext"
/>
<TrainingResultCard
v-else-if="isTrainingResultMessage"
:score="trainingHandlers.getScore()"
:is-passed="trainingHandlers.getScore() >= 90"
:correct-count="trainingHandlers.getCorrectCount()"
:wrong-count="trainingHandlers.getWrongCount()"
:is-thinking="isThinking"
@restart="trainingHandlers.onRestartExam"
/>
<div
v-else-if="renderedMarkdown"
class="chat-markdown prose prose-sm max-w-none leading-7 text-primary prose-a:text-blue-600 prose-p:my-1 prose-li:my-0.5 prose-ol:my-2 prose-ul:my-2 prose-headings:my-2 prose-hr:my-3 prose-code:rounded prose-code:bg-slate-100 prose-code:px-1 prose-code:text-blue-700 prose-pre:my-3 prose-pre:border prose-pre:border-slate-700 prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-th:border prose-th:border-slate-200 prose-th:bg-slate-50 prose-th:px-3 prose-th:py-2 prose-th:text-left prose-td:border prose-td:border-slate-200 prose-td:px-3 prose-td:py-2"
@click="handlers.onMarkdownClick"
ref="markdownContainer"
class="markdown-body chat-markdown min-w-0 break-words text-sm leading-relaxed"
v-html="renderedMarkdown"
/>
<TrainingVideoMessage
v-if="isTrainingVideoMessage"
:is-thinking="isThinking"
@play="trainingHandlers.onPlayVideo"
/>
<TrainingSummaryMessage
v-if="isTrainingSummaryMessage"
:summary-points="trainingHandlers.getSummaryPoints()"
:summary-checklist="trainingHandlers.getSummaryChecklist()"
:is-thinking="isThinking"
@start-exam="trainingHandlers.onStartExam"
/>
<div v-if="actionableInlineFileEntries.length > 0" class="mt-4">
<div class="flex flex-wrap gap-2">
<button
@@ -0,0 +1,151 @@
/**
* features/chat/components/messages/TrainingExamQuestionMessage.vue
* 用途:在聊天气泡中渲染交互式答题选择器,支持单选题与判断题。
* 逻辑:由 ChatMessageBubble 内部调用;展示当前题目内容、选项,并在答题后展示即时反馈与“下一题”操作。
*/
<script setup lang="ts">
import { CheckCircle2, XCircle, ClipboardCheck } from 'lucide-vue-next';
import type { TrainingQuestion } from '@/features/chat/training/training.types';
export interface TrainingHandlers {
getQuestion: () => TrainingQuestion | null;
getCurrentQuestionIndex: () => number;
getAnsweredCount: () => number;
getTotalCount: () => number;
getScore: () => number;
getSelectedOptionId: () => string;
getAnswerLocked: () => boolean;
getFeedbackCorrect: () => boolean;
getAnswerLabel: () => string;
onSelect: (optionId: string) => void;
onNext: () => void;
onPlayVideo: () => void;
onStartExam: () => void;
onRestartExam: () => void;
getCorrectCount: () => number;
getWrongCount: () => number;
getSummaryPoints: () => string[];
getSummaryChecklist: () => string[];
}
const props = defineProps<{
question: TrainingQuestion;
currentQuestionIndex: number;
answeredCount: number;
totalCount: number;
score: number;
selectedOptionId: string;
answerLocked: boolean;
feedbackCorrect: boolean;
answerLabel: string;
isThinking: boolean;
}>();
const emit = defineEmits<{
select: [optionId: string];
next: [];
}>();
const passLine = 90;
</script>
<template>
<div class="my-2 flex flex-col gap-4 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm ring-1 ring-brand-50/50">
<!-- 头部进度与分数 -->
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<div>
<div class="text-[11px] font-bold uppercase tracking-[0.15em] text-brand-600/80">
第三步:逐题考试
</div>
<h3 class="mt-1 text-lg font-bold text-slate-800">
第 {{ currentQuestionIndex + 1 }} / {{ totalCount }} 题
</h3>
</div>
<div class="flex flex-wrap gap-2 text-[13px]">
<div class="rounded-lg bg-slate-50 px-3 py-1.5 font-medium text-slate-600 border border-slate-100 flex items-center gap-2">
<span>当前分数:</span>
<span class="text-slate-800 font-bold">{{ score }} 分</span>
</div>
<div class="rounded-lg bg-slate-50 px-3 py-1.5 font-medium text-slate-600 border border-slate-100 flex items-center gap-2">
<span>及格线:</span>
<span class="text-slate-800 font-bold">{{ passLine }} 分</span>
</div>
</div>
</div>
<!-- 题目正文 -->
<div class="rounded-xl bg-brand-50/30 p-4 border border-brand-100/50">
<div class="text-[15px] font-bold leading-7 text-slate-800">
{{ question.prompt }}
</div>
</div>
<!-- 选项列表 -->
<div class="grid gap-2.5">
<button
v-for="option in question.options"
:key="option.id"
type="button"
class="group relative flex items-center justify-between rounded-2xl border px-5 py-3.5 text-left text-[14px] transition-all duration-200"
:class="[
selectedOptionId === option.id
? answerLocked
? option.id === question.answer
? 'border-emerald-300 bg-emerald-50 text-emerald-700 ring-4 ring-emerald-500/5'
: 'border-red-300 bg-red-50 text-red-700 ring-4 ring-red-500/5'
: 'border-brand-300 bg-brand-50 text-brand-700 ring-4 ring-brand-500/5'
: answerLocked && option.id === question.answer
? 'border-emerald-200 bg-emerald-50/50 text-emerald-600'
: 'border-slate-200 bg-white text-slate-600 hover:border-brand-200 hover:bg-brand-50/30 hover:text-brand-700',
]"
:disabled="answerLocked || isThinking"
@click="emit('select', option.id)"
>
<span class="font-medium">{{ option.label }}</span>
<CheckCircle2
v-if="answerLocked && option.id === question.answer"
class="h-5 w-5 shrink-0 text-emerald-500"
/>
</button>
</div>
<!-- 答题反馈 -->
<div
v-if="answerLocked"
class="mt-1 animate-in fade-in slide-in-from-top-2 duration-300 rounded-2xl border p-4"
:class="feedbackCorrect ? 'border-emerald-100 bg-emerald-50/60' : 'border-red-100 bg-red-50/60'"
>
<div class="flex items-center gap-2 text-sm font-bold" :class="feedbackCorrect ? 'text-emerald-700' : 'text-red-700'">
<CheckCircle2 v-if="feedbackCorrect" class="h-4 w-4" />
<XCircle v-else class="h-4 w-4" />
{{ feedbackCorrect ? '回答正确,继续下一题' : '回答错误' }}
</div>
<div class="mt-3 space-y-2 text-[13px] leading-6 text-slate-600">
<div class="flex gap-2">
<span class="font-medium text-slate-500 shrink-0">你的答案:</span>
<span class="font-medium" :class="feedbackCorrect ? 'text-emerald-600' : 'text-red-600'">{{ answerLabel || '--' }}</span>
</div>
<div v-if="!feedbackCorrect" class="flex gap-2">
<span class="font-medium text-slate-500 shrink-0">正确答案:</span>
<span class="text-emerald-600 font-medium">{{ question.options?.find(o => o.id === question.answer)?.label || '--' }}</span>
</div>
<div class="mt-2 pl-2 border-l-2 border-slate-200/60 text-slate-500/90">
{{ question.explanation }}
</div>
</div>
<div class="mt-4">
<button
type="button"
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-5 py-2.5 text-[14px] font-bold text-white shadow-lg shadow-brand-500/20 transition-all hover:bg-brand-700 hover:-translate-y-0.5 active:translate-y-0 disabled:opacity-50 disabled:translate-y-0"
:disabled="isThinking"
@click="emit('next')"
>
<ClipboardCheck class="h-4 w-4" />
{{ answeredCount >= totalCount - 1 ? '完成考试并查看结果' : '下一题' }}
</button>
</div>
</div>
</div>
</template>
@@ -0,0 +1,88 @@
/**
* features/chat/components/messages/TrainingResultCard.vue
* 用途:在聊天气泡中渲染考试结算结果。
*/
<script setup lang="ts">
import { ShieldCheck, XCircle, RotateCcw, CheckCircle2 } from 'lucide-vue-next';
defineProps<{
score: number;
isPassed: boolean;
correctCount: number;
wrongCount: number;
isThinking: boolean;
}>();
const emit = defineEmits<{
restart: [];
}>();
</script>
<template>
<div class="my-2 flex flex-col gap-5 rounded-2xl border border-brand-100 bg-white p-5 shadow-sm ring-1 ring-brand-50/50">
<!-- 状态头部 -->
<div class="flex items-center justify-between">
<div class="flex items-center gap-2.5">
<div
class="flex h-10 w-10 items-center justify-center rounded-xl"
:class="isPassed ? 'bg-emerald-100 text-emerald-600' : 'bg-red-100 text-red-600'"
>
<ShieldCheck v-if="isPassed" class="h-6 w-6" />
<XCircle v-else class="h-6 w-6" />
</div>
<div>
<div class="text-[11px] font-bold uppercase tracking-[0.15em] text-slate-500">
第四步:结算结果
</div>
<h3 class="text-lg font-bold text-slate-800">
{{ isPassed ? '恭喜,你已通过考核!' : '很遗憾,考试未通过' }}
</h3>
</div>
</div>
<div
class="rounded-full px-3 py-1 text-xs font-bold uppercase"
:class="isPassed ? 'bg-emerald-50 text-emerald-700 border border-emerald-100' : 'bg-red-50 text-red-700 border border-red-100'"
>
{{ isPassed ? 'PASSED' : 'FAILED' }}
</div>
</div>
<!-- 分数展示 -->
<div class="grid grid-cols-3 gap-3">
<div class="rounded-2xl bg-slate-50 p-4 border border-slate-100 text-center">
<div class="text-[11px] font-bold text-slate-400 uppercase">{{ $t('chat.training.result.scoreLabel') }}</div>
<div class="mt-1 text-2xl font-black text-brand-600">{{ score }}</div>
</div>
<div class="rounded-2xl bg-emerald-50/50 p-4 border border-emerald-100/50 text-center">
<div class="text-[11px] font-bold text-emerald-500 uppercase">{{ $t('chat.training.result.correctCount') }}</div>
<div class="mt-1 text-2xl font-black text-emerald-600">{{ correctCount }}</div>
</div>
<div class="rounded-2xl bg-red-50/50 p-4 border border-red-100/50 text-center">
<div class="text-[11px] font-bold text-red-400 uppercase">答错</div>
<div class="mt-1 text-2xl font-black text-red-500">{{ wrongCount }}</div>
</div>
</div>
<!-- 描述语 -->
<div class="text-sm leading-relaxed text-slate-600">
{{ isPassed ? $t('chat.training.result.passDescription') : $t('chat.training.result.failDescription') }}
</div>
<!-- 操作 -->
<div v-if="!isPassed" class="pt-2">
<button
type="button"
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-slate-800 px-5 py-3 text-sm font-bold text-white transition-all hover:bg-slate-900 active:scale-[0.98] disabled:opacity-50"
:disabled="isThinking"
@click="emit('restart')"
>
<RotateCcw class="h-4 w-4" />
重新考试
</button>
</div>
<div v-else class="flex items-center gap-2 text-emerald-600 font-medium text-sm">
<CheckCircle2 class="h-4 w-4" />
成绩已同步至 HR 管理系统
</div>
</div>
</template>
@@ -0,0 +1,87 @@
/**
* features/chat/components/messages/TrainingSummaryMessage.vue
* 用途:在聊天气泡中渲染“知识点复盘”卡片。
* 逻辑:展示重点知识和考前必知,并提供“开始考试”按钮。
*/
<script setup lang="ts">
import { BookOpen, CheckCircle2, ClipboardCheck } from 'lucide-vue-next';
defineProps<{
summaryPoints: string[];
summaryChecklist: string[];
isThinking: boolean;
}>();
const emit = defineEmits<{
startExam: [];
}>();
</script>
<template>
<div class="my-2 flex flex-col gap-4 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm ring-1 ring-brand-50/50">
<!-- 头部 -->
<div class="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between">
<div class="flex items-center gap-2">
<div class="flex h-8 w-8 items-center justify-center rounded-lg bg-brand-50 text-brand-600">
<BookOpen class="h-5 w-5" />
</div>
<div>
<h3 class="text-base font-bold text-slate-800">
{{ $t('chat.training.summary.title') }}
</h3>
<p class="text-[12px] text-slate-500">
{{ $t('chat.training.summary.description') }}
</p>
</div>
</div>
<button
type="button"
class="mt-2 inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2 text-[13px] font-bold text-white shadow-md shadow-brand-500/20 transition-all hover:bg-brand-700 sm:mt-0"
:disabled="isThinking"
@click="emit('startExam')"
>
<ClipboardCheck class="h-4 w-4" />
{{ $t('chat.training.summary.startExam') }}
</button>
</div>
<!-- 内容网格 -->
<div class="grid gap-4 md:grid-cols-2">
<!-- 重点知识 -->
<div class="rounded-xl bg-brand-50/30 p-4 border border-brand-100/50">
<h4 class="mb-3 flex items-center gap-2 text-[14px] font-bold text-brand-700">
<div class="h-1.5 w-1.5 rounded-full bg-brand-500"></div>
{{ $t('chat.training.summary.keyPoints') }}
</h4>
<ul class="space-y-2.5">
<li
v-for="(point, i) in summaryPoints"
:key="i"
class="flex gap-2 text-[13px] leading-6 text-slate-600"
>
<span class="text-brand-400 font-bold">•</span>
<span>{{ point }}</span>
</li>
</ul>
</div>
<!-- 考前必知 -->
<div class="rounded-xl bg-slate-50/50 p-4 border border-slate-100">
<h4 class="mb-3 flex items-center gap-2 text-[14px] font-bold text-slate-700">
<div class="h-1.5 w-1.5 rounded-full bg-slate-400"></div>
{{ $t('chat.training.summary.mustKnow') }}
</h4>
<ul class="space-y-2.5">
<li
v-for="(item, i) in summaryChecklist"
:key="i"
class="flex gap-2 text-[13px] leading-6 text-slate-600"
>
<CheckCircle2 class="mt-1 h-3.5 w-3.5 shrink-0 text-emerald-500/80" />
<span>{{ item }}</span>
</li>
</ul>
</div>
</div>
</div>
</template>
@@ -0,0 +1,37 @@
/**
* features/chat/components/messages/TrainingVideoMessage.vue
* 用途:在聊天气泡中渲染培训视频占位符。
* 逻辑:点击占位符触发视频播放弹窗(复用工作区逻辑)。
*/
<script setup lang="ts">
import { PlayCircle } from 'lucide-vue-next';
defineProps<{
isThinking: boolean;
}>();
const emit = defineEmits<{
play: [];
}>();
</script>
<template>
<div class="my-1.5 flex flex-col gap-3 rounded-2xl border border-brand-100 bg-white p-3 shadow-sm ring-1 ring-brand-50/30">
<div
class="relative group cursor-pointer overflow-hidden rounded-xl border border-default bg-slate-900 shadow-sm aspect-video flex items-center justify-center"
:class="{ 'opacity-50 pointer-events-none': isThinking }"
@click="emit('play')"
>
<img
src="https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=Professional%20corporate%20training%20video%20cover%2C%20high-quality%2C%20modern%20office%20background%2C%20play%20button%20overlay&image_size=landscape_16_9"
class="absolute inset-0 w-full h-full object-cover opacity-60 group-hover:scale-105 transition-transform duration-500"
/>
<div class="relative z-10 flex flex-col items-center gap-2">
<div class="h-12 w-12 flex items-center justify-center rounded-full bg-white/20 backdrop-blur-md border border-white/30 group-hover:bg-brand-600 group-hover:border-brand-500 transition-all duration-300">
<PlayCircle class="h-6 w-6 text-white fill-white/20" />
</div>
<span class="text-white text-xs font-medium drop-shadow-md">点击播放视频</span>
</div>
</div>
</div>
</template>
@@ -18,6 +18,9 @@ export type AgentSuggestedQuestionItem = {
const DEFAULT_KB = '企业知识库';
const ERP_KB = 'ERP知识库';
const ERP_KB_ENABLED_AGENT_NAMES = new Set(['固资管理']);
const TRAINING_AGENT_NAME_PATTERN = /(培训|考试|入职)/;
const isTrainingAgentName = (name: string) => TRAINING_AGENT_NAME_PATTERN.test(name);
const DEFAULT_AGENT_DESCRIPTIONS: Record<string, string> = {
人事规章: '我是你的7x24小时专属HR政策助手。无需手动检索文档,只需用日常说话的方式提问,我能从公司最新、最全的规章制度中,为你精准提取并总结答案。',
@@ -48,6 +51,15 @@ const DEFAULT_AGENT_SUGGESTED_QUESTIONS: Record<string, { style: 'plain' | 'styl
},
};
const TRAINING_AGENT_DESCRIPTION = '我是你的新人培训助手,会在同一个聊天页面内带你完成视频学习、知识点复盘、逐题考试和结果复盘。';
const TRAINING_AGENT_QUESTIONS: AgentSuggestedQuestionItem[] = [
{ question: '开始新人培训', group: '培训流程' },
{ question: '我已看完视频,请总结知识点', group: '培训流程' },
{ question: '开始考试', group: '培训流程' },
{ question: '导出本月培训成绩', group: 'HR 管理' },
];
const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestionItem[] => {
if (!Array.isArray(value)) return [];
return value
@@ -118,6 +130,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
const agentDescription = computed(() => {
const text = String(currentAgent.value?.description || '').trim();
if (!text && isTrainingAgentName(currentAgentName.value)) return TRAINING_AGENT_DESCRIPTION;
return text || DEFAULT_AGENT_DESCRIPTIONS[currentAgentName.value] || '';
});
@@ -125,6 +138,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
const style = String(currentAgent.value?.extra_config?.suggested_questions_style || '').trim().toLowerCase();
if (style === 'styled') return 'styled';
if (style === 'plain') return 'plain';
if (isTrainingAgentName(currentAgentName.value)) return 'styled';
return DEFAULT_AGENT_SUGGESTED_QUESTIONS[currentAgentName.value]?.style || 'plain';
});
@@ -133,6 +147,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
currentAgent.value?.suggested_questions ?? currentAgent.value?.extra_config?.suggested_questions,
);
if (configured.length > 0) return configured;
if (isTrainingAgentName(currentAgentName.value)) return TRAINING_AGENT_QUESTIONS;
return DEFAULT_AGENT_SUGGESTED_QUESTIONS[currentAgentName.value]?.questions || [];
});
@@ -2,7 +2,7 @@
* features/chat/composables/useChatPage.ts
* 对话页主编排:组合 SSE、Agent、附件、请假/出货、路由同步与 page/* 子模块。
*/
import { computed, markRaw, ref, watch } from 'vue';
import { computed, markRaw, nextTick, ref, watch } from 'vue';
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
@@ -26,6 +26,7 @@ import { useChatSessions } from './useChatSessions';
import { useChatShipping } from './useChatShipping';
import { useChatSourceFiles } from './useChatSourceFiles';
import { useChatStore } from '../stores/chat.store';
import { useTrainingWorkspace, matchesTrainingAgent } from './useTrainingWorkspace';
import {
createChatPageConversationApi,
createChatPageLocalMessageApi,
@@ -34,6 +35,7 @@ import {
createLeaveMessageHandlers,
createShippingMappingHandlers,
createShippingPickerRefHolder,
createTrainingHandlers,
useChatPageDialogs,
useChatPageUser,
useChatPageVoice,
@@ -212,6 +214,34 @@ export function useChatPage() {
currentAgentId,
});
const pushLocalAssistantMessage = async (content: string) => {
const msgText = String(content || '').trim();
if (!msgText) return;
const isFirstMessage = messages.value.length === 0;
const isTraining = matchesTrainingAgent(agent.currentAgent.value);
// 如果是培训 Agent 的首条消息(欢迎语),强制重置滚动贴底状态,防止自动滚到底部
if (isFirstMessage && isTraining) {
scroll.isNearBottom.value = false;
}
const assistantMsg: ChatMessage = {
role: 'assistant',
type: 'text',
content: msgText,
local_id: newLocalMessageId('local-assistant'),
local_only: true,
};
messages.value.push(assistantMsg);
await saveLocalMessageToBackend(assistantMsg);
// 再次确保滚到顶部展示欢迎语
if (isFirstMessage && isTraining) {
await nextTick();
scroll.scrollToTop();
}
};
const presetQuestion = computed(() => {
const q = route.query.preset;
return typeof q === 'string' ? q : '';
@@ -286,6 +316,27 @@ export function useChatPage() {
t,
});
const pushLocalUserMessage = async (content: string) => {
const msgText = String(content || '').trim();
if (!msgText) return;
const userMsg: ChatMessage = {
role: 'user',
type: 'text',
content: msgText,
local_id: newLocalMessageId('local-user'),
local_only: true,
};
messages.value.push(userMsg);
await saveLocalMessageToBackend(userMsg);
};
const training = useTrainingWorkspace({
currentAgent: computed(() => agent.currentAgent.value),
currentUser: computed(() => currentUser.value),
pushLocalAssistantMessage,
pushLocalUserMessage,
});
const markdown = createChatPageMarkdownApi({
messages,
isThinking,
@@ -361,6 +412,7 @@ export function useChatPage() {
const leaveMessageHandlers = createLeaveMessageHandlers(leave);
const shippingMappingHandlers = createShippingMappingHandlers(shipping);
const trainingHandlers = createTrainingHandlers(training);
const shippingPickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingInventoryPickerRef));
const shippingNoticePickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingNoticePickerRef));
@@ -452,9 +504,11 @@ export function useChatPage() {
isVoiceRecording: voice.isVoiceRecording,
isVoiceTranscribing: voice.isVoiceTranscribing,
handleVoiceFeatureClick: voice.handleVoiceFeatureClick,
training,
...leave,
leaveMessageHandlers,
shippingMappingHandlers,
trainingHandlers,
shippingPickerRefHolder,
shippingNoticePickerRefHolder,
shouldShowThinkingBubble: markdown.shouldShowThinkingBubble,
@@ -462,6 +516,7 @@ export function useChatPage() {
shouldRenderMessage: markdown.shouldRenderMessage,
canSendMessage: sendApi.canSendMessage,
handleSend: sendApi.handleSend,
pushLocalAssistantMessage,
copyToClipboard: sendApi.copyToClipboard,
regenerate: sendApi.regenerate,
handleOpenFeedback: dialogs.handleOpenFeedback,
@@ -66,6 +66,17 @@ export function useChatScroll(options: UseChatScrollOptions) {
});
};
const scrollToTop = async () => {
await nextTick();
const el = container.value;
if (!el) return;
el.scrollTo({
top: 0,
behavior: 'auto',
});
isNearBottom.value = false;
};
const scrollToUserQuestion = async () => {
if (scrollToBottomFrame !== null) {
window.cancelAnimationFrame(scrollToBottomFrame);
@@ -139,6 +150,7 @@ export function useChatScroll(options: UseChatScrollOptions) {
showScrollToBottom,
scrollToBottom,
scrollToBottomSmooth,
scrollToTop,
scrollToUserQuestion,
scheduleScrollToBottom,
setupThinkingScrollWatch,
@@ -0,0 +1,458 @@
/**
* features/chat/composables/useTrainingWorkspace.ts
* 用途:封装新人培训 Agent 的前端工作区状态,包括学员考试流、HR 统计筛选与 Excel 导出。
* 依赖:Vue reactivity、vue-i18n、xlsx,以及 training.types。
* 逻辑:仅在培训 Agent 下启用;学员端按“视频 -> 知识点 -> 一题一答 -> 结算”推进,HR 端复用同页查看统计与导出。
*/
import { computed, ref, watch, type ComputedRef } from 'vue';
import { useI18n } from 'vue-i18n';
import * as XLSX from 'xlsx';
import type {
TrainingAnswerRecord,
TrainingQuestion,
TrainingQuestionOption,
TrainingRecord,
TrainingRecordStatus,
TrainingStage,
TrainingWorkspaceView,
} from '@/features/chat/training/training.types';
type TrainingAgentLike = {
name?: string | null;
extra_config?: Record<string, unknown> | null;
} | null | undefined;
type TrainingUserLike = {
role?: string | null;
username?: string | null;
real_name?: string | null;
employee_id?: string | null;
department?: string | null;
} | null | undefined;
export interface UseTrainingWorkspaceOptions {
currentAgent: ComputedRef<TrainingAgentLike>;
currentUser: ComputedRef<TrainingUserLike>;
pushLocalAssistantMessage?: (content: string) => Promise<void>;
pushLocalUserMessage?: (content: string) => Promise<void>;
}
const TRAINING_AGENT_NAME_PATTERN = /(培训|考试|入职)/;
/**
* 判断当前 Agent 是否应启用“培训工作区”。
* AI 触发时机:当需要把培训 UI 只挂在指定 Agent 上时使用,优先读 extra_config 显式开关,避免误伤其他聊天场景。
*/
export function matchesTrainingAgent(agent: TrainingAgentLike): boolean {
const extraConfig = agent?.extra_config || {};
const explicitFlags = [
extraConfig.training_workspace_enabled,
extraConfig.training_mode,
extraConfig.training_agent,
];
if (explicitFlags.some((value) => value === true || value === 'true')) {
return true;
}
const name = String(agent?.name || '').trim();
return TRAINING_AGENT_NAME_PATTERN.test(name);
}
const formatDate = (value: Date) => value.toISOString().slice(0, 10);
const buildInitialRecords = (): TrainingRecord[] => [
{
id: 'r-001',
name: '蔡晓晴',
employeeId: 'HX10031',
department: '人事部',
joinDate: '2026-06-03',
completionDate: '2026-06-05',
score: 95,
attempts: 1,
status: 'passed',
},
{
id: 'r-002',
name: '刘成',
employeeId: 'HX10052',
department: '制造部',
joinDate: '2026-06-08',
completionDate: '2026-06-10',
score: 90,
attempts: 2,
status: 'passed',
},
{
id: 'r-003',
name: '张艳',
employeeId: 'HX10061',
department: '品质部',
joinDate: '2026-06-09',
completionDate: null,
score: 80,
attempts: 1,
status: 'failed',
},
{
id: 'r-004',
name: '陈立',
employeeId: 'HX10077',
department: '仓储部',
joinDate: '2026-06-12',
completionDate: '2026-06-14',
score: 100,
attempts: 1,
status: 'passed',
},
{
id: 'r-005',
name: '吴佳',
employeeId: 'HX10082',
department: '业务部',
joinDate: '2026-06-13',
completionDate: null,
score: null,
attempts: 0,
status: 'in_progress',
},
{
id: 'r-006',
name: '王腾',
employeeId: 'HX10088',
department: '工程部',
joinDate: '2026-06-15',
completionDate: '2026-06-18',
score: 95,
attempts: 3,
status: 'passed',
},
];
export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
const { currentAgent, currentUser, pushLocalAssistantMessage, pushLocalUserMessage } = options;
const { t, tm } = useI18n();
const isTrainingAgent = computed(() => matchesTrainingAgent(currentAgent.value));
const isAdminViewer = computed(() => currentUser.value?.role === 'admin');
const activeView = ref<TrainingWorkspaceView>('learner');
const stage = ref<TrainingStage>('video');
const currentQuestionIndex = ref(0);
const score = ref(0);
const attemptCount = ref(0);
const selectedOptionId = ref('');
const answerLocked = ref(false);
const currentFeedbackCorrect = ref(false);
const answerRecords = ref<TrainingAnswerRecord[]>([]);
const completionDate = ref<string | null>(null);
const hrKeyword = ref('');
const hrStatusFilter = ref<'all' | TrainingRecordStatus>('all');
const hrDepartmentFilter = ref('all');
const records = ref<TrainingRecord[]>(buildInitialRecords());
watch(isTrainingAgent, (enabled) => {
if (!enabled) {
activeView.value = 'learner';
}
});
const summaryPoints = computed(() => {
const raw = tm('chat.training.summaryPoints');
return Array.isArray(raw) ? raw.map((item) => String(item)) : [];
});
const summaryChecklist = computed(() => {
const raw = tm('chat.training.summaryChecklist');
return Array.isArray(raw) ? raw.map((item) => String(item)) : [];
});
const rawQuestionBank = computed(() => {
const raw = tm('chat.training.questionBank');
return Array.isArray(raw) ? raw as Array<Record<string, unknown>> : [];
});
const booleanOptions = computed<TrainingQuestionOption[]>(() => {
const raw = tm('chat.training.booleanOptions');
if (!Array.isArray(raw)) return [];
return raw.map((item) => ({
id: String((item as Record<string, unknown>).id || ''),
label: String((item as Record<string, unknown>).label || ''),
}));
});
const questionBank = computed<TrainingQuestion[]>(() => rawQuestionBank.value.map((item) => {
const type = String(item.type || 'single') as TrainingQuestion['type'];
const rawOptions = Array.isArray(item.options) ? item.options : [];
const options = type === 'boolean'
? booleanOptions.value
: rawOptions.map((option) => ({
id: String((option as Record<string, unknown>).id || ''),
label: String((option as Record<string, unknown>).label || ''),
}));
return {
id: String(item.id || ''),
type,
prompt: String(item.prompt || ''),
answer: String(item.answer || ''),
explanation: String(item.explanation || ''),
options,
};
}));
const currentQuestion = computed(() => questionBank.value[currentQuestionIndex.value] || null);
const totalQuestionCount = computed(() => questionBank.value.length);
const answeredCount = computed(() => answerRecords.value.length);
const correctCount = computed(() => answerRecords.value.filter((item) => item.correct).length);
const wrongCount = computed(() => answerRecords.value.filter((item) => !item.correct).length);
const isPassed = computed(() => score.value >= 90);
const learnerProgressPercent = computed(() => {
if (stage.value === 'video') return 25;
if (stage.value === 'summary') return 50;
if (stage.value === 'result') return 100;
const base = 50;
const examProgress = totalQuestionCount.value > 0
? Math.round((answeredCount.value / totalQuestionCount.value) * 50)
: 0;
return Math.min(100, base + examProgress);
});
const currentUserName = computed(() => (
String(currentUser.value?.real_name || '').trim()
|| String(currentUser.value?.username || '').trim()
|| t('chat.training.defaultLearnerName')
));
const currentUserEmployeeId = computed(() => String(currentUser.value?.employee_id || '').trim() || '--');
const currentUserDepartment = computed(() => String(currentUser.value?.department || '').trim() || t('chat.training.unknownDepartment'));
const departmentOptions = computed(() => {
const values = Array.from(new Set(records.value.map((item) => item.department))).sort((a, b) => a.localeCompare(b));
return values;
});
const filteredRecords = computed(() => {
const keyword = hrKeyword.value.trim().toLowerCase();
return records.value.filter((item) => {
const matchesKeyword = !keyword
|| item.name.toLowerCase().includes(keyword)
|| item.employeeId.toLowerCase().includes(keyword);
const matchesStatus = hrStatusFilter.value === 'all' || item.status === hrStatusFilter.value;
const matchesDepartment = hrDepartmentFilter.value === 'all' || item.department === hrDepartmentFilter.value;
return matchesKeyword && matchesStatus && matchesDepartment;
});
});
const stats = computed(() => {
const total = records.value.length;
const passed = records.value.filter((item) => item.status === 'passed').length;
const failed = records.value.filter((item) => item.status === 'failed').length;
const inProgress = records.value.filter((item) => item.status === 'in_progress').length;
const averageScoreSource = records.value.filter((item) => typeof item.score === 'number');
const averageScore = averageScoreSource.length > 0
? Math.round(averageScoreSource.reduce((sum, item) => sum + Number(item.score || 0), 0) / averageScoreSource.length)
: 0;
return {
total,
passed,
failed,
inProgress,
passRate: total > 0 ? Math.round((passed / total) * 100) : 0,
averageScore,
};
});
/**
* 重置考试状态,为首次开考或再次补考共用。
* AI 触发时机:当前端需要严格模拟“未通过必须重考”的培训流程时使用,确保上一轮答题状态不会污染下一轮。
*/
const resetExamState = () => {
currentQuestionIndex.value = 0;
score.value = 0;
selectedOptionId.value = '';
answerLocked.value = false;
currentFeedbackCorrect.value = false;
answerRecords.value = [];
completionDate.value = null;
};
const markVideoCompleted = () => {
stage.value = 'summary';
// 立即推入本地助手消息(复盘卡片)
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
};
const startExam = () => {
stage.value = 'exam';
attemptCount.value += 1;
resetExamState();
// 立即推入第一题的消息引导
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
};
const selectAnswer = (optionId: string) => {
if (answerLocked.value || !currentQuestion.value) return;
selectedOptionId.value = optionId;
const isCorrect = optionId === currentQuestion.value.answer;
currentFeedbackCorrect.value = isCorrect;
if (isCorrect) {
score.value += 5;
}
answerRecords.value.push({
questionId: currentQuestion.value.id,
selectedOptionId: optionId,
correct: isCorrect,
});
answerLocked.value = true;
// 推入用户选择的答案到聊天流
const label = currentQuestion.value.options?.find(o => o.id === optionId)?.label || optionId;
void pushLocalUserMessage?.(label);
};
/**
* 进入下一题或结束考试。
* AI 触发时机:当用户答完一题后,前端必须只推进一题并即时结算,保证“一题一答一反馈”的 HR 规则被严格执行。
*/
const moveToNextQuestion = () => {
if (!answerLocked.value) return;
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
stage.value = 'result';
completionDate.value = formatDate(new Date());
upsertCurrentUserRecord();
// 推入结果消息
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
return;
}
currentQuestionIndex.value += 1;
selectedOptionId.value = '';
answerLocked.value = false;
currentFeedbackCorrect.value = false;
// 推入下一题消息
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
};
const restartExam = () => {
stage.value = 'summary';
resetExamState();
// 重新推回复盘卡片
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
};
const upsertCurrentUserRecord = () => {
const recordIndex = records.value.findIndex((item) => item.employeeId === currentUserEmployeeId.value);
const existingRecord = recordIndex >= 0 ? records.value[recordIndex] : null;
const nextRecord: TrainingRecord = {
id: existingRecord?.id || `r-${Date.now()}`,
name: currentUserName.value,
employeeId: currentUserEmployeeId.value,
department: currentUserDepartment.value,
joinDate: existingRecord?.joinDate || formatDate(new Date()),
completionDate: isPassed.value ? completionDate.value : null,
score: score.value,
attempts: attemptCount.value,
status: isPassed.value ? 'passed' : 'failed',
};
if (recordIndex >= 0) {
records.value.splice(recordIndex, 1, nextRecord);
} else {
records.value.unshift(nextRecord);
}
};
const exportRecords = () => {
const rows = filteredRecords.value.map((item) => ({
[t('chat.training.hr.columns.joinDate')]: item.joinDate,
[t('chat.training.hr.columns.completionDate')]: item.completionDate || '--',
[t('chat.training.hr.columns.department')]: item.department,
[t('chat.training.hr.columns.name')]: item.name,
[t('chat.training.hr.columns.employeeId')]: item.employeeId,
[t('chat.training.hr.columns.score')]: item.score ?? '--',
[t('chat.training.hr.columns.attempts')]: item.attempts,
[t('chat.training.hr.columns.status')]: t(`chat.training.hr.status.${item.status}`),
}));
const worksheet = XLSX.utils.json_to_sheet(rows);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'training');
XLSX.writeFile(workbook, `training_records_${new Date().toISOString().slice(0, 10)}.xlsx`);
};
const managementChatPrompt = computed(() => {
const parts = [
t('chat.training.chatPrompts.hrSummaryPrefix'),
`${t('chat.training.hr.filters.keywordLabel')}: ${hrKeyword.value || t('chat.training.hr.filters.noLimit')}`,
`${t('chat.training.hr.filters.statusLabel')}: ${hrStatusFilter.value === 'all' ? t('chat.training.hr.filters.allStatuses') : t(`chat.training.hr.status.${hrStatusFilter.value}`)}`,
`${t('chat.training.hr.filters.departmentLabel')}: ${hrDepartmentFilter.value === 'all' ? t('chat.training.hr.filters.allDepartments') : hrDepartmentFilter.value}`,
`${t('chat.training.hr.stats.passRate')}: ${stats.value.passRate}%`,
];
return parts.join(';');
});
const learnerChatPrompt = computed(() => {
// 阶段 1:破冰与视频导学
if (stage.value === 'video') {
return `👋 欢迎加入公司!我是你的专属入职培训助手。今天的培训分为三个步骤:看视频 ➡️ 知识点复习 ➡️ 随堂测试(90分及格)。\n\n▶️ 请先点击观看 [入职培训视频]。观看完毕后,请回复【已看完】。`;
}
// 阶段 2:知识点串讲
if (stage.value === 'summary') {
return `${t('chat.training.chatPrompts.afterVideo')}\n\n参考知识点:\n${summaryPoints.value.map((p, i) => `${i + 1}. ${p}`).join('\n')}`;
}
// 阶段 4:结算
if (stage.value === 'result') {
return isPassed.value
? t('chat.training.chatPrompts.afterPass', { score: score.value })
: t('chat.training.chatPrompts.afterFail', { score: score.value });
}
// 阶段 3:互动测试
return t('chat.training.chatPrompts.examInProgress', {
index: currentQuestionIndex.value + 1,
total: totalQuestionCount.value,
question: currentQuestion.value?.prompt || '',
});
});
const showVideoModal = ref(false);
return {
isTrainingAgent,
isAdminViewer,
activeView,
stage,
currentQuestionIndex,
currentQuestion,
totalQuestionCount,
answeredCount,
score,
attemptCount,
selectedOptionId,
answerLocked,
currentFeedbackCorrect,
answerRecords,
completionDate,
summaryPoints,
summaryChecklist,
learnerProgressPercent,
correctCount,
wrongCount,
isPassed,
currentUserName,
currentUserEmployeeId,
currentUserDepartment,
hrKeyword,
hrStatusFilter,
hrDepartmentFilter,
departmentOptions,
filteredRecords,
stats,
learnerChatPrompt,
managementChatPrompt,
markVideoCompleted,
startExam,
selectAnswer,
moveToNextQuestion,
restartExam,
exportRecords,
showVideoModal,
};
}
@@ -3,8 +3,10 @@
*/
import type { LeaveMessageHandlers } from '../components/messages/LeaveMessageBlock.vue';
import type { ShippingMappingHandlers } from '../components/messages/ShippingInventoryMappingMessage.vue';
import type { TrainingHandlers } from '../components/messages/TrainingExamQuestionMessage.vue';
import type { useChatLeave } from '../composables/useChatLeave';
import type { useChatShipping } from '../composables/useChatShipping';
import type { useTrainingWorkspace } from '../composables/useTrainingWorkspace';
import type { Ref } from 'vue';
type LeaveHandlerSource = Pick<
@@ -41,6 +43,8 @@ type ShippingHandlerSource = Pick<
| 'removeShippingParseReviewLine'
>;
type TrainingHandlerSource = ReturnType<typeof useTrainingWorkspace>;
/** 请假消息块 handlers(LeaveMessageBlock) */
export function createLeaveMessageHandlers(leave: LeaveHandlerSource): LeaveMessageHandlers {
return {
@@ -81,6 +85,38 @@ export function createShippingMappingHandlers(shipping: ShippingHandlerSource):
};
}
/** 培训答题块 handlers(TrainingExamQuestionMessage) */
export function createTrainingHandlers(workspace: TrainingHandlerSource): TrainingHandlers {
return {
getQuestion: () => workspace.currentQuestion.value,
getCurrentQuestionIndex: () => workspace.currentQuestionIndex.value,
getAnsweredCount: () => workspace.answeredCount.value,
getTotalCount: () => workspace.totalQuestionCount.value,
getScore: () => workspace.score.value,
getSelectedOptionId: () => workspace.selectedOptionId.value,
getAnswerLocked: () => workspace.answerLocked.value,
getFeedbackCorrect: () => workspace.currentFeedbackCorrect.value,
getAnswerLabel: () => {
const q = workspace.currentQuestion.value;
if (!q) return '';
return q.options?.find((o) => o.id === workspace.selectedOptionId.value)?.label || '';
},
onSelect: workspace.selectAnswer,
onNext: workspace.moveToNextQuestion,
onPlayVideo: () => {
// 通过 DOM 事件或状态传递触发视频播放,这里我们直接让 workspace 标记视频模态框展示
// 注意:这里需要确保 TrainingWorkspacePanel 监听了对应的状态
workspace.showVideoModal.value = true;
},
onStartExam: workspace.startExam,
onRestartExam: workspace.restartExam,
getCorrectCount: () => workspace.correctCount.value,
getWrongCount: () => workspace.wrongCount.value,
getSummaryPoints: () => workspace.summaryPoints.value,
getSummaryChecklist: () => workspace.summaryChecklist.value,
};
}
/** 隐藏 file input ref 包裹,避免 template 自动解包 Ref */
export function createShippingPickerRefHolder(pickerRef: Ref<HTMLInputElement | null>) {
return { pickerRef };
@@ -0,0 +1,46 @@
/**
* features/chat/training/training.types.ts
* 用途:定义入职培训聊天工作区的题库、考试进度、HR 统计记录等共享类型。
* 依赖:被 useTrainingWorkspace 与 TrainingWorkspacePanel 共同引用。
* 逻辑:统一约束“学员考试流”和“HR 管理流”的前端数据结构,避免组件内散落匿名对象。
*/
export type TrainingStage = 'video' | 'summary' | 'exam' | 'result';
export type TrainingWorkspaceView = 'learner' | 'admin';
export type TrainingQuestionType = 'single' | 'boolean';
export interface TrainingQuestionOption {
id: string;
label: string;
}
export interface TrainingQuestion {
id: string;
type: TrainingQuestionType;
prompt: string;
answer: string;
explanation: string;
options?: TrainingQuestionOption[];
}
export interface TrainingAnswerRecord {
questionId: string;
selectedOptionId: string;
correct: boolean;
}
export type TrainingRecordStatus = 'passed' | 'failed' | 'in_progress';
export interface TrainingRecord {
id: string;
name: string;
employeeId: string;
department: string;
joinDate: string;
completionDate: string | null;
score: number | null;
attempts: number;
status: TrainingRecordStatus;
}
+244
View File
@@ -449,5 +449,249 @@
"range": "Showing {start}-{end} of {total}",
"empty": "No matching data"
}
},
"training": {
"badge": "Onboarding Training Workspace",
"title": "Onboarding Training Agent",
"subtitle": "Complete video learning, knowledge review, one-question-at-a-time testing, and HR reporting in the same chat page.",
"tabs": {
"learner": "Learner",
"admin": "HR Admin"
},
"actions": {
"syncLearnerToChat": "Sync learner context to chat",
"syncHrToChat": "Sync HR filters to chat",
"expandWorkspace": "Expand workspace",
"collapseWorkspace": "Collapse workspace"
},
"steps": {
"video": "Watch Video",
"summary": "Review Key Points",
"exam": "Take Exam",
"result": "View Result"
},
"progressLabel": "Training Progress",
"progressHint": "The employee is considered complete only after finishing the video, summary review, and exam steps.",
"progressPercent": "Completion",
"stepNo": "Step {value}",
"defaultLearnerName": "Current learner",
"unknownDepartment": "Department pending",
"video": {
"title": "Step 1: Watch the training video",
"description": "Employees first complete the onboarding video, then move on to the knowledge review and exam.",
"completeAction": "I finished watching the video",
"playerTitle": "Video player slot",
"playerHint": "This area can later connect to an enterprise video URL or internal player. The frontend container and completion action are already prepared."
},
"summary": {
"title": "Step 2: Review the key points",
"description": "Based on the HR exam paper, the system summarizes the most important points before the employee starts the test.",
"startExam": "Start Exam",
"keyPoints": "Key points",
"mustKnow": "Must know before the exam"
},
"exam": {
"title": "Step 3: One-question-at-a-time exam",
"questionCounter": "Question {current} / {total}",
"currentScore": "Current score: {score}",
"passLine": "Pass line: 90 points",
"correctFeedback": "Correct. Move on to the next question.",
"wrongFeedback": "Incorrect. The correct answer is now shown.",
"selectedAnswer": "Your answer: {answer}",
"correctAnswer": "Correct answer: {answer}",
"nextQuestion": "Next Question",
"finishExam": "Finish Exam"
},
"result": {
"passedTag": "Passed",
"failedTag": "Retake required",
"passTitle": "Congratulations, you passed the onboarding exam",
"failTitle": "This attempt did not meet the requirement",
"passDescription": "The frontend pass-state interaction is complete. Once the backend is connected, it can write training records and the completion date.",
"failDescription": "According to HR rules, any score below 90 requires a full retake until the learner passes.",
"scoreLabel": "Final score",
"attemptsLabel": "Attempts",
"correctCount": "Correct answers",
"wrongCount": "Wrong answers",
"completionDate": "Completion date",
"retryExam": "Retake Exam",
"sendToChat": "Send review to chat"
},
"learnerCard": {
"title": "Current learner",
"name": "Name",
"employeeId": "Employee ID",
"department": "Department"
},
"rules": {
"title": "Exam rules",
"rule1": "There are 20 questions, 5 points each, with a full score of 100.",
"rule2": "The system enforces one question, one answer, one feedback. Wrong answers show the correct answer immediately.",
"rule3": "Any score below 90 is treated as failed and requires a retake.",
"rule4": "HR can view statistics and export Excel from the same chat page."
},
"hr": {
"stats": {
"total": "Participants",
"passed": "Passed",
"failed": "Failed",
"inProgress": "In progress",
"passRate": "Pass rate"
},
"filters": {
"keywordLabel": "Name / ID",
"keywordPlaceholder": "Filter by name or employee ID",
"statusLabel": "Status",
"departmentLabel": "Department",
"allStatuses": "All statuses",
"allDepartments": "All departments",
"noLimit": "No limit"
},
"columns": {
"joinDate": "Join date",
"completionDate": "Completion date",
"department": "Department",
"name": "Name",
"employeeId": "Employee ID",
"score": "Score",
"attempts": "Attempts",
"status": "Status"
},
"status": {
"passed": "Passed",
"failed": "Failed",
"in_progress": "In progress"
},
"actions": {
"askAgent": "Ask agent for analysis",
"export": "Export Excel"
},
"empty": "No training records match the current filters."
},
"chatPrompts": {
"hrSummaryPrefix": "Based on the current filters, summarize the onboarding training data and list the exceptions.",
"afterVideo": "I finished the onboarding training video. Please summarize the key knowledge points based on the exam scope.",
"afterSummary": "I finished reviewing the knowledge points. Please switch to exam mode and ask the first question.",
"afterPass": "I passed the onboarding training exam with a score of {score}. Please help me generate a short completion summary.",
"afterFail": "I scored {score} in the onboarding training exam and did not pass. Please summarize the weak points and prepare a retake reminder.",
"examInProgress": "I am taking the onboarding training exam and am currently on question {index}/{total}. Please stay in proctor mode and continue."
},
"summaryPoints": [
"Salary is paid on the 15th of each month, and attendance or leave requests must go through OA.",
"The cafeteria uses the Zhongmi meal-ordering system, and missed punches require an OA correction process.",
"5S stands for sort, set in order, shine, standardize, and sustain.",
"In case of fire, call 119 immediately and use a fire extinguisher from the upwind side.",
"QC080000 is the hazardous substance process management standard, and RoHS focuses on environmental requirements for electronic products."
],
"summaryChecklist": [
"Only the current question is shown during the exam to avoid exposing the whole answer set at once.",
"A wrong answer must immediately show the correct answer and a short explanation.",
"Only scores of 90 or above count as passing.",
"The admin view must be able to export join date, completion date, department, name, employee ID, and score."
],
"booleanOptions": [
{ "id": "true", "label": "True" },
{ "id": "false", "label": "False" }
],
"questionBank": [
{
"id": "q1",
"type": "single",
"prompt": "On which day of the month is salary paid?",
"answer": "c",
"explanation": "According to the onboarding exam, salary is paid on the 15th of each month.",
"options": [
{ "id": "a", "label": "A. 8th" },
{ "id": "b", "label": "B. 9th" },
{ "id": "c", "label": "C. 15th" },
{ "id": "d", "label": "D. 27th" }
]
},
{
"id": "q2",
"type": "single",
"prompt": "Which system is used for cafeteria meal ordering?",
"answer": "b",
"explanation": "The company cafeteria uses the Zhongmi meal-ordering system, not OA or ERP.",
"options": [
{ "id": "a", "label": "A. OA" },
{ "id": "b", "label": "B. Zhongmi ordering system" },
{ "id": "c", "label": "C. ERP" }
]
},
{
"id": "q3",
"type": "single",
"prompt": "Which of the following are company products?",
"answer": "abcd",
"explanation": "All four options listed in the exam belong to the company product scope.",
"options": [
{ "id": "abcd", "label": "A/B/C/D All of the above" },
{ "id": "ab", "label": "A/B" },
{ "id": "cd", "label": "C/D" },
{ "id": "a", "label": "A only" }
]
},
{
"id": "q4",
"type": "single",
"prompt": "Which OA form should be used for leave?",
"answer": "c",
"explanation": "Leave must use the OA leave application form.",
"options": [
{ "id": "a", "label": "A. Overtime request" },
{ "id": "b", "label": "B. Contact form" },
{ "id": "c", "label": "C. Leave application" },
{ "id": "d", "label": "D. Employee request form" }
]
},
{
"id": "q5",
"type": "single",
"prompt": "What is QC080000?",
"answer": "a",
"explanation": "QC080000 is the hazardous substance process management certification standard.",
"options": [
{ "id": "a", "label": "A. Hazardous substance process management standard" },
{ "id": "b", "label": "B. Occupational health and safety management system" },
{ "id": "c", "label": "C. Environmental management system" }
]
},
{
"id": "q6",
"type": "single",
"prompt": "What does 5S refer to?",
"answer": "a",
"explanation": "The standard 5S terms are sort, set in order, shine, standardize, and sustain.",
"options": [
{ "id": "a", "label": "A. Sort, set in order, shine, standardize, sustain" },
{ "id": "b", "label": "B. Sort, set in order, clean up, standardize, sustain" }
]
},
{
"id": "q7",
"type": "single",
"prompt": "Where should you stand when using a fire extinguisher?",
"answer": "a",
"explanation": "You should stand on the upwind side when using a fire extinguisher.",
"options": [
{ "id": "a", "label": "A. Upwind side" },
{ "id": "b", "label": "B. Downwind side" }
]
},
{ "id": "q8", "type": "boolean", "prompt": "Normal attendance requires clock-in, and overtime must be applied for in advance.", "answer": "true", "explanation": "Both attendance and overtime follow the company attendance policy." },
{ "id": "q9", "type": "boolean", "prompt": "If you forget to clock in, you need an OA correction request.", "answer": "true", "explanation": "Missed punches must be corrected through the OA process." },
{ "id": "q10", "type": "boolean", "prompt": "Monthly salary is calculated from the 21st of the previous month to the 20th of the current month.", "answer": "true", "explanation": "The exam explicitly defines this payroll calculation cycle." },
{ "id": "q11", "type": "boolean", "prompt": "Cafeteria meals require advance booking, and face recognition can be used for dining.", "answer": "true", "explanation": "Advance booking and face-recognition dining are both supported." },
{ "id": "q12", "type": "boolean", "prompt": "In the event of fire or explosion, you should immediately call 119.", "answer": "true", "explanation": "Calling the fire emergency number is the first step in this scenario." },
{ "id": "q13", "type": "boolean", "prompt": "Dormitory residents must maintain fire awareness and must not install wires privately or use high-power appliances.", "answer": "true", "explanation": "This is a mandatory dormitory fire-safety rule." },
{ "id": "q14", "type": "boolean", "prompt": "Following safety production regulations is a safety obligation of employees.", "answer": "true", "explanation": "Safety compliance is both a rule and an employee obligation." },
{ "id": "q15", "type": "boolean", "prompt": "Employee badges may be lent to others freely.", "answer": "false", "explanation": "A badge is a personal identity credential and may not be lent out." },
{ "id": "q16", "type": "boolean", "prompt": "RoHS mainly regulates materials and processes in electrical and electronic products to better protect human health and the environment.", "answer": "true", "explanation": "RoHS focuses on restricting hazardous substances and improving environmental protection." },
{ "id": "q17", "type": "boolean", "prompt": "Our company's HSF policy is: green design, eco-friendly purchasing; resource conservation, green output.", "answer": "true", "explanation": "This is the HSF policy statement provided in the exam." },
{ "id": "q18", "type": "boolean", "prompt": "EHS stands for Environment, Health, and Safety.", "answer": "true", "explanation": "EHS is the standard abbreviation for environment, health, and safety." },
{ "id": "q19", "type": "boolean", "prompt": "External documents do not need to be controlled or managed by the organization.", "answer": "false", "explanation": "External documents also need controlled management." },
{ "id": "q20", "type": "boolean", "prompt": "Product-related requirements should include legal and regulatory requirements as well as customer requirements.", "answer": "true", "explanation": "Product requirements must cover both regulations and customer requirements." }
]
}
}
+244
View File
@@ -449,5 +449,249 @@
"range": "แสดง {start}-{end} จากทั้งหมด {total}",
"empty": "ไม่พบข้อมูลที่ตรงเงื่อนไข"
}
},
"training": {
"badge": "พื้นที่อบรมพนักงานใหม่",
"title": "Onboarding Training Agent",
"subtitle": "ทำวิดีโอเรียนรู้ ทบทวนความรู้ สอบทีละข้อ และดูสถิติ HR ได้ในหน้าแชตเดียวกัน",
"tabs": {
"learner": "ผู้เรียน",
"admin": "HR Admin"
},
"actions": {
"syncLearnerToChat": "ส่งบริบทผู้เรียนเข้าแชต",
"syncHrToChat": "ส่งตัวกรอง HR เข้าแชต",
"expandWorkspace": "ขยายพื้นที่ทำงาน",
"collapseWorkspace": "ย่อพื้นที่ทำงาน"
},
"steps": {
"video": "ดูวิดีโอ",
"summary": "ทบทวนความรู้",
"exam": "ทำข้อสอบ",
"result": "ผลลัพธ์"
},
"progressLabel": "ความคืบหน้า",
"progressHint": "ต้องดูวิดีโอ ทบทวนความรู้ และทำข้อสอบครบ จึงจะถือว่าจบการอบรม",
"progressPercent": "เปอร์เซ็นต์เสร็จสิ้น",
"stepNo": "ขั้นตอน {value}",
"defaultLearnerName": "ผู้เรียนปัจจุบัน",
"unknownDepartment": "ยังไม่ได้ระบุแผนก",
"video": {
"title": "ขั้นตอน 1: ดูวิดีโออบรม",
"description": "พนักงานใหม่ต้องดูวิดีโออบรมก่อน แล้วจึงเข้าสู่การทบทวนความรู้และการสอบ",
"completeAction": "ฉันดูวิดีโอเสร็จแล้ว",
"playerTitle": "ตำแหน่งตัวเล่นวิดีโอ",
"playerHint": "ส่วนนี้สามารถเชื่อมต่อกับลิงก์วิดีโอภายในบริษัทหรือเครื่องเล่นภายในได้ในภายหลัง"
},
"summary": {
"title": "ขั้นตอน 2: ทบทวนประเด็นสำคัญ",
"description": "ระบบสรุปประเด็นที่มักออกสอบจากชุดข้อสอบของ HR เพื่อช่วยให้พนักงานทบทวนก่อนสอบ",
"startExam": "เริ่มสอบ",
"keyPoints": "ประเด็นสำคัญ",
"mustKnow": "สิ่งที่ต้องรู้ก่อนสอบ"
},
"exam": {
"title": "ขั้นตอน 3: สอบทีละข้อ",
"questionCounter": "ข้อ {current} / {total}",
"currentScore": "คะแนนปัจจุบัน: {score}",
"passLine": "ผ่านเมื่อได้ 90 คะแนน",
"correctFeedback": "ตอบถูก ไปข้อถัดไปได้",
"wrongFeedback": "ตอบผิด ระบบแสดงคำตอบที่ถูกต้องแล้ว",
"selectedAnswer": "คำตอบของคุณ: {answer}",
"correctAnswer": "คำตอบที่ถูกต้อง: {answer}",
"nextQuestion": "ข้อถัดไป",
"finishExam": "จบการสอบ"
},
"result": {
"passedTag": "ผ่านแล้ว",
"failedTag": "ต้องสอบใหม่",
"passTitle": "ยินดีด้วย คุณผ่านการสอบอบรมพนักงานใหม่แล้ว",
"failTitle": "การสอบครั้งนี้ยังไม่ผ่านเกณฑ์",
"passDescription": "ฝั่งหน้าเว็บรองรับสถานะผ่านแล้ว และสามารถเชื่อมต่อหลังบ้านเพื่อบันทึกผลได้ในขั้นถัดไป",
"failDescription": "ตามกฎของ HR หากได้ต่ำกว่า 90 คะแนน ต้องสอบใหม่จนกว่าจะผ่าน",
"scoreLabel": "คะแนนสุดท้าย",
"attemptsLabel": "จำนวนครั้งที่สอบ",
"correctCount": "จำนวนข้อที่ถูก",
"wrongCount": "จำนวนข้อที่ผิด",
"completionDate": "วันที่เสร็จสิ้น",
"retryExam": "สอบใหม่",
"sendToChat": "ส่งผลทบทวนเข้าแชต"
},
"learnerCard": {
"title": "ผู้เรียนปัจจุบัน",
"name": "ชื่อ",
"employeeId": "รหัสพนักงาน",
"department": "แผนก"
},
"rules": {
"title": "กติกาการสอบ",
"rule1": "มีทั้งหมด 20 ข้อ ข้อละ 5 คะแนน เต็ม 100 คะแนน",
"rule2": "ระบบทำงานแบบหนึ่งข้อหนึ่งคำตอบหนึ่งฟีดแบ็ก และจะแสดงคำตอบที่ถูกเมื่อผู้ใช้ตอบผิด",
"rule3": "หากได้ต่ำกว่า 90 คะแนน ถือว่าไม่ผ่านและต้องสอบใหม่",
"rule4": "HR สามารถดูสถิติและส่งออก Excel ได้จากหน้าแชตเดียวกัน"
},
"hr": {
"stats": {
"total": "จำนวนผู้เข้าอบรม",
"passed": "ผ่านแล้ว",
"failed": "ไม่ผ่าน",
"inProgress": "กำลังดำเนินการ",
"passRate": "อัตราการผ่าน"
},
"filters": {
"keywordLabel": "ชื่อ / รหัสพนักงาน",
"keywordPlaceholder": "กรองตามชื่อหรือรหัสพนักงาน",
"statusLabel": "สถานะ",
"departmentLabel": "แผนก",
"allStatuses": "ทุกสถานะ",
"allDepartments": "ทุกแผนก",
"noLimit": "ไม่จำกัด"
},
"columns": {
"joinDate": "วันที่เริ่มงาน",
"completionDate": "วันที่เสร็จสิ้น",
"department": "แผนก",
"name": "ชื่อ",
"employeeId": "รหัสพนักงาน",
"score": "คะแนน",
"attempts": "จำนวนครั้ง",
"status": "สถานะ"
},
"status": {
"passed": "ผ่านแล้ว",
"failed": "ไม่ผ่าน",
"in_progress": "กำลังดำเนินการ"
},
"actions": {
"askAgent": "ให้ Agent วิเคราะห์",
"export": "ส่งออก Excel"
},
"empty": "ไม่พบข้อมูลการอบรมตามตัวกรองปัจจุบัน"
},
"chatPrompts": {
"hrSummaryPrefix": "โปรดสรุปข้อมูลการอบรมพนักงานใหม่จากตัวกรองปัจจุบันและระบุรายชื่อที่มีความเสี่ยง",
"afterVideo": "ฉันดูวิดีโออบรมพนักงานใหม่เสร็จแล้ว โปรดสรุปประเด็นสำคัญตามขอบเขตข้อสอบ",
"afterSummary": "ฉันทบทวนความรู้เสร็จแล้ว โปรดเริ่มโหมดสอบและถามข้อแรก",
"afterPass": "ฉันผ่านการสอบอบรมพนักงานใหม่ด้วยคะแนน {score} โปรดช่วยสรุปการอบรมให้สั้น ๆ",
"afterFail": "ฉันได้คะแนน {score} ในการสอบอบรมพนักงานใหม่และยังไม่ผ่าน โปรดสรุปจุดอ่อนและเตือนให้สอบใหม่",
"examInProgress": "ฉันกำลังสอบอบรมพนักงานใหม่ ตอนนี้อยู่ที่ข้อ {index}/{total} โปรดทำหน้าที่เป็นผู้คุมสอบและถามต่อ"
},
"summaryPoints": [
"เงินเดือนจ่ายทุกวันที่ 15 ของเดือน และการลาหรือการลงเวลาต้องทำผ่าน OA",
"โรงอาหารใช้ระบบสั่งอาหาร Zhongmi และการลืมลงเวลาต้องแก้ผ่าน OA",
"5S ประกอบด้วยการสะสาง สะดวก สะอาด สุขลักษณะ และสร้างนิสัย",
"เมื่อเกิดไฟไหม้ต้องโทร 119 ทันที และใช้ถังดับเพลิงจากด้านเหนือลม",
"QC080000 คือมาตรฐานการจัดการกระบวนการสารอันตราย และ RoHS เน้นข้อกำหนดด้านสิ่งแวดล้อมของผลิตภัณฑ์อิเล็กทรอนิกส์"
],
"summaryChecklist": [
"ระหว่างสอบ ระบบจะแสดงเฉพาะคำถามปัจจุบันเท่านั้น",
"หากตอบผิด ระบบต้องแสดงคำตอบที่ถูกและคำอธิบายสั้น ๆ ทันที",
"ต้องได้ 90 คะแนนขึ้นไปจึงจะถือว่าผ่าน",
"ฝั่งจัดการต้องส่งออกวันที่เริ่มงาน วันที่เสร็จสิ้น แผนก ชื่อ รหัสพนักงาน และคะแนนได้"
],
"booleanOptions": [
{ "id": "true", "label": "ถูก" },
{ "id": "false", "label": "ผิด" }
],
"questionBank": [
{
"id": "q1",
"type": "single",
"prompt": "เงินเดือนจ่ายในวันที่เท่าไรของเดือน?",
"answer": "c",
"explanation": "ตามข้อสอบอบรมพนักงานใหม่ เงินเดือนจ่ายในวันที่ 15 ของทุกเดือน",
"options": [
{ "id": "a", "label": "A. วันที่ 8" },
{ "id": "b", "label": "B. วันที่ 9" },
{ "id": "c", "label": "C. วันที่ 15" },
{ "id": "d", "label": "D. วันที่ 27" }
]
},
{
"id": "q2",
"type": "single",
"prompt": "ระบบที่ใช้สั่งอาหารในโรงอาหารคืออะไร?",
"answer": "b",
"explanation": "โรงอาหารของบริษัทใช้ระบบสั่งอาหาร Zhongmi",
"options": [
{ "id": "a", "label": "A. OA" },
{ "id": "b", "label": "B. ระบบสั่งอาหาร Zhongmi" },
{ "id": "c", "label": "C. ERP" }
]
},
{
"id": "q3",
"type": "single",
"prompt": "ข้อใดคือผลิตภัณฑ์ของบริษัท?",
"answer": "abcd",
"explanation": "ตัวเลือกทั้งสี่ข้อเป็นกลุ่มผลิตภัณฑ์ของบริษัทตามข้อสอบ",
"options": [
{ "id": "abcd", "label": "A/B/C/D ทั้งหมด" },
{ "id": "ab", "label": "A/B" },
{ "id": "cd", "label": "C/D" },
{ "id": "a", "label": "เฉพาะ A" }
]
},
{
"id": "q4",
"type": "single",
"prompt": "หากต้องการลา ต้องเปิดเอกสาร OA แบบใด?",
"answer": "c",
"explanation": "การลาต้องใช้แบบฟอร์มใบลาของ OA",
"options": [
{ "id": "a", "label": "A. ใบขอโอที" },
{ "id": "b", "label": "B. ใบติดต่อ" },
{ "id": "c", "label": "C. ใบลางาน" },
{ "id": "d", "label": "D. ใบคำขอพนักงาน" }
]
},
{
"id": "q5",
"type": "single",
"prompt": "QC080000 คืออะไร?",
"answer": "a",
"explanation": "QC080000 คือมาตรฐานการจัดการกระบวนการสารอันตราย",
"options": [
{ "id": "a", "label": "A. มาตรฐานการจัดการสารอันตราย" },
{ "id": "b", "label": "B. ระบบอาชีวอนามัยและความปลอดภัย" },
{ "id": "c", "label": "C. ระบบการจัดการสิ่งแวดล้อม" }
]
},
{
"id": "q6",
"type": "single",
"prompt": "5S หมายถึงอะไร?",
"answer": "a",
"explanation": "5S หมายถึงสะสาง สะดวก สะอาด สุขลักษณะ และสร้างนิสัย",
"options": [
{ "id": "a", "label": "A. สะสาง สะดวก สะอาด สุขลักษณะ สร้างนิสัย" },
{ "id": "b", "label": "B. สะสาง สะดวก ทำความสะอาด สุขลักษณะ สร้างนิสัย" }
]
},
{
"id": "q7",
"type": "single",
"prompt": "ควรยืนด้านใดเมื่อใช้ถังดับเพลิง?",
"answer": "a",
"explanation": "ต้องยืนด้านเหนือลมเมื่อใช้ถังดับเพลิง",
"options": [
{ "id": "a", "label": "A. ด้านเหนือลม" },
{ "id": "b", "label": "B. ด้านใต้ลม" }
]
},
{ "id": "q8", "type": "boolean", "prompt": "การเข้างานปกติต้องลงเวลา และการทำโอทีต้องยื่นคำขอล่วงหน้า", "answer": "true", "explanation": "การเข้างานและโอทีต้องปฏิบัติตามกฎการลงเวลาของบริษัท" },
{ "id": "q9", "type": "boolean", "prompt": "หากลืมลงเวลา ต้องยื่นคำขอแก้ไขผ่าน OA", "answer": "true", "explanation": "การลืมลงเวลาต้องแก้ไขผ่านกระบวนการ OA" },
{ "id": "q10", "type": "boolean", "prompt": "เงินเดือนคำนวณตั้งแต่วันที่ 21 ของเดือนก่อนถึงวันที่ 20 ของเดือนปัจจุบัน", "answer": "true", "explanation": "ข้อสอบระบุรอบการคำนวณเงินเดือนนี้ไว้อย่างชัดเจน" },
{ "id": "q11", "type": "boolean", "prompt": "การรับประทานอาหารในโรงอาหารต้องจองล่วงหน้า และสามารถใช้การสแกนใบหน้าได้", "answer": "true", "explanation": "โรงอาหารรองรับทั้งการจองล่วงหน้าและการสแกนใบหน้า" },
{ "id": "q12", "type": "boolean", "prompt": "เมื่อเกิดไฟไหม้หรือระเบิด ควรโทร 119 ทันที", "answer": "true", "explanation": "การแจ้งหน่วยดับเพลิงเป็นขั้นตอนแรกที่ถูกต้อง" },
{ "id": "q13", "type": "boolean", "prompt": "ผู้พักอาศัยในหอพักต้องระวังเรื่องไฟ และห้ามต่อสายไฟเองหรือใช้เครื่องใช้ไฟฟ้ากำลังสูง", "answer": "true", "explanation": "นี่คือข้อบังคับด้านความปลอดภัยจากอัคคีภัยในหอพัก" },
{ "id": "q14", "type": "boolean", "prompt": "การปฏิบัติตามกฎความปลอดภัยในการผลิตเป็นหน้าที่ของพนักงาน", "answer": "true", "explanation": "การปฏิบัติตามกฎความปลอดภัยเป็นทั้งข้อกำหนดและหน้าที่ของพนักงาน" },
{ "id": "q15", "type": "boolean", "prompt": "บัตรพนักงานสามารถให้ผู้อื่นยืมใช้ได้อย่างอิสระ", "answer": "false", "explanation": "บัตรพนักงานเป็นเอกสารยืนยันตัวตนส่วนบุคคล ห้ามให้ยืม" },
{ "id": "q16", "type": "boolean", "prompt": "RoHS ใช้กำหนดมาตรฐานวัสดุและกระบวนการของผลิตภัณฑ์ไฟฟ้าและอิเล็กทรอนิกส์เพื่อปกป้องสุขภาพและสิ่งแวดล้อม", "answer": "true", "explanation": "เป้าหมายหลักของ RoHS คือการจำกัดสารอันตรายและลดความเสี่ยงต่อสิ่งแวดล้อม" },
{ "id": "q17", "type": "boolean", "prompt": "นโยบาย HSF ของบริษัทคือ ออกแบบสีเขียว จัดซื้อเป็นมิตรต่อสิ่งแวดล้อม ประหยัดทรัพยากร และผลิตอย่างเป็นมิตรต่อสิ่งแวดล้อม", "answer": "true", "explanation": "นี่คือข้อความนโยบาย HSF ตามที่ระบุในข้อสอบ" },
{ "id": "q18", "type": "boolean", "prompt": "EHS หมายถึง Environment, Health, Safety", "answer": "true", "explanation": "EHS เป็นตัวย่อมาตรฐานของสิ่งแวดล้อม สุขภาพ และความปลอดภัย" },
{ "id": "q19", "type": "boolean", "prompt": "เอกสารจากภายนอกไม่จำเป็นต้องถูกควบคุมหรือจัดการโดยองค์กร", "answer": "false", "explanation": "เอกสารจากภายนอกก็ต้องมีการควบคุมเช่นกัน" },
{ "id": "q20", "type": "boolean", "prompt": "ข้อกำหนดที่เกี่ยวข้องกับผลิตภัณฑ์ควรรวมถึงข้อกำหนดตามกฎหมายและข้อกำหนดของลูกค้า", "answer": "true", "explanation": "ข้อกำหนดของผลิตภัณฑ์ต้องครอบคลุมทั้งกฎหมายและความต้องการของลูกค้า" }
]
}
}
+322
View File
@@ -449,5 +449,327 @@
"range": "显示第 {start}-{end} 条,共 {total} 条",
"empty": "暂无符合条件的数据"
}
},
"training": {
"badge": "新人培训工作区",
"title": "新人入职培训 Agent",
"subtitle": "在同一个 Chat 页面内完成视频学习、知识点复盘、逐题考试以及 HR 管理统计。",
"tabs": {
"learner": "学员端",
"admin": "HR 管理"
},
"actions": {
"syncLearnerToChat": "同步学员上下文到聊天",
"syncHrToChat": "同步 HR 筛选到聊天",
"expandWorkspace": "展开工作区",
"collapseWorkspace": "收起工作区"
},
"steps": {
"video": "观看视频",
"summary": "复盘知识点",
"exam": "逐题考试",
"result": "结算结果"
},
"progressLabel": "培训进度",
"progressHint": "按 HR 要求完成视频、知识点、考试三个环节后才能视为完成。",
"progressPercent": "完成度",
"stepNo": "步骤 {value}",
"defaultLearnerName": "当前学员",
"unknownDepartment": "待补充部门",
"video": {
"title": "第一步:观看培训视频",
"description": "员工先完成入职培训视频学习,再进入知识点复盘和考试环节。",
"completeAction": "我已完成视频学习",
"playerTitle": "视频播放位",
"playerHint": "这里可接入企业视频链接或内部播放器。当前前端已预留完整容器与学习完成按钮。"
},
"summary": {
"title": "第二步:知识点复盘",
"description": "根据 HR 提供的试卷,系统先提炼考试重点,帮助员工在答题前完成记忆强化。",
"startExam": "开始考试",
"keyPoints": "重点知识",
"mustKnow": "考前必知"
},
"exam": {
"title": "第三步:逐题考试",
"questionCounter": "第 {current} / {total} 题",
"currentScore": "当前分数:{score} 分",
"passLine": "及格线:90 分",
"correctFeedback": "回答正确,继续下一题",
"wrongFeedback": "回答错误,已显示正确答案",
"selectedAnswer": "你的答案:{answer}",
"correctAnswer": "正确答案:{answer}",
"nextQuestion": "下一题",
"finishExam": "完成考试"
},
"result": {
"passedTag": "已通过",
"failedTag": "需补考",
"passTitle": "恭喜,你已通过新人培训考试",
"failTitle": "本次考试未达标,需要重新考试",
"passDescription": "前端已完成通过态交互,后续接入后端后可直接回写培训记录与完成日期。",
"failDescription": "按照 HR 规则,未达到 90 分必须重新考试,直到最终通过为止。",
"scoreLabel": "最终得分",
"attemptsLabel": "考试次数",
"correctCount": "答对题数",
"wrongCount": "答错题数",
"completionDate": "完成日期",
"retryExam": "重新考试",
"sendToChat": "发送复盘到聊天"
},
"learnerCard": {
"title": "当前学员",
"name": "姓名",
"employeeId": "工号",
"department": "部门"
},
"rules": {
"title": "考试规则",
"rule1": "共 20 题,每题 5 分,满分 100 分。",
"rule2": "系统按“一题一答一反馈”执行,答错立即展示正确答案。",
"rule3": "低于 90 分判定为未通过,必须重新考试。",
"rule4": "HR 管理端可在同一聊天页查看统计并导出 Excel。"
},
"hr": {
"stats": {
"total": "参训人数",
"passed": "已通过",
"failed": "未通过",
"inProgress": "进行中",
"passRate": "通过率"
},
"filters": {
"keywordLabel": "姓名 / 工号",
"keywordPlaceholder": "输入姓名或工号筛选",
"statusLabel": "状态",
"departmentLabel": "部门",
"allStatuses": "全部状态",
"allDepartments": "全部部门",
"noLimit": "不限"
},
"columns": {
"joinDate": "入职日期",
"completionDate": "完成日期",
"department": "部门",
"name": "姓名",
"employeeId": "工号",
"score": "分数",
"attempts": "考试次数",
"status": "状态"
},
"status": {
"passed": "已通过",
"failed": "未通过",
"in_progress": "进行中"
},
"actions": {
"askAgent": "让 Agent 生成分析",
"export": "导出 Excel"
},
"empty": "当前筛选条件下暂无培训记录。"
},
"chatPrompts": {
"hrSummaryPrefix": "请基于当前筛选条件,帮我总结新人培训数据并给出异常名单。",
"afterVideo": "我已完成新人培训视频,请结合考试范围帮我总结重点知识。",
"afterSummary": "我已完成知识点复盘,请切换到考试模式并开始第一题。",
"afterPass": "我已经通过新人培训考试,得分 {score} 分,请帮我生成一段培训完成总结。",
"afterFail": "我本次新人培训考试得分 {score} 分,未达到及格线,请帮我总结错题重点并安排重考提醒。",
"examInProgress": "我正在进行新人培训考试,目前做到第 {index}/{total} 题。题目是:{question}。请保持考官模式,评价我的表现并引导我继续。"
},
"summaryPoints": [
"工资每月 15 号发放,考勤与请假均需要走 OA 流程。",
"餐厅订餐使用中米新订餐系统,忘记刷卡需走 OA 补刷卡流程。",
"5S 包括整理、整顿、清扫、清洁和素养,属于现场管理基础要求。",
"发生火灾时要第一时间拨打 119,并使用灭火器站在上风口操作。",
"QC080000 对应有害物质过程管理体系,RoHS 关注电子电气产品环保要求。"
],
"summaryChecklist": [
"答题时系统只展示当前题目,避免一次性泄露完整答案。",
"答错题目必须立即看到标准答案和简短解析。",
"考试结束后只有分数达到 90 分才算通过。",
"管理端需要能导出入职日期、完成日期、部门、姓名、工号和分数。"
],
"booleanOptions": [
{ "id": "true", "label": "正确" },
{ "id": "false", "label": "错误" }
],
"questionBank": [
{
"id": "q1",
"type": "single",
"prompt": "工资每月几号发放?",
"answer": "a",
"explanation": "根据新人培训试卷答案,工资固定在每月 8 号发放。",
"options": [
{ "id": "a", "label": "A. 8号" },
{ "id": "b", "label": "B. 9号" },
{ "id": "c", "label": "C. 15号" },
{ "id": "d", "label": "D. 27号" }
]
},
{
"id": "q2",
"type": "single",
"prompt": "餐厅订餐的系统是?",
"answer": "b",
"explanation": "公司餐厅订餐使用中米新订餐系统,不是 OA 或 ERP。",
"options": [
{ "id": "a", "label": "A. OA" },
{ "id": "b", "label": "B. 中米新订餐系统" },
{ "id": "c", "label": "C. ERP" }
]
},
{
"id": "q3",
"type": "single",
"prompt": "公司的产品有?",
"answer": "abcd",
"explanation": "试卷给出的四个选项都是公司产品范畴,前端以组合选项形式展示为全选。",
"options": [
{ "id": "abcd", "label": "A/B/C/D 全部都是" },
{ "id": "ab", "label": "A/B" },
{ "id": "cd", "label": "C/D" },
{ "id": "a", "label": "仅 A" }
]
},
{
"id": "q4",
"type": "single",
"prompt": "请假需要开什么 OA 单?",
"answer": "c",
"explanation": "请假必须发起 OA 请假申请单,不能使用加班申请单或联络单。",
"options": [
{ "id": "a", "label": "A. 加班申请单" },
{ "id": "b", "label": "B. 联络单" },
{ "id": "c", "label": "C. 请假申请单" },
{ "id": "d", "label": "D. 员工需求单" }
]
},
{
"id": "q5",
"type": "single",
"prompt": "QC080000 是什么?",
"answer": "a",
"explanation": "QC080000 对应有害物质过程管理体系认证标准。",
"options": [
{ "id": "a", "label": "A. 有害物质过程管理体系认证标准" },
{ "id": "b", "label": "B. 职业健康安全管理体系" },
{ "id": "c", "label": "C. 环境管理体系" }
]
},
{
"id": "q6",
"type": "single",
"prompt": "5S 指的是?",
"answer": "a",
"explanation": "5S 标准表述为整理、整顿、清扫、清洁和素养。",
"options": [
{ "id": "a", "label": "A. 整理、整顿、清扫、清洁和素养" },
{ "id": "b", "label": "B. 整理、整顿、打扫、清洁和素养" }
]
},
{
"id": "q7",
"type": "single",
"prompt": "使用灭火器应站在火源的哪里?",
"answer": "a",
"explanation": "使用灭火器要站在上风口,避免烟雾和火势倒灌。",
"options": [
{ "id": "a", "label": "A. 上风口" },
{ "id": "b", "label": "B. 下风口" }
]
},
{
"id": "q8",
"type": "boolean",
"prompt": "正常出勤必须打卡,加班需要提前申请提报。",
"answer": "true",
"explanation": "出勤和加班都需要遵循公司考勤制度,这是基础要求。"
},
{
"id": "q9",
"type": "boolean",
"prompt": "忘记刷卡需要 OA 开补刷卡单。",
"answer": "true",
"explanation": "漏打卡需要通过 OA 补刷卡流程修正考勤记录。"
},
{
"id": "q10",
"type": "boolean",
"prompt": "每月工资从上月 21 日至本月 20 日为止计算。",
"answer": "true",
"explanation": "试卷中明确了工资核算周期的起止时间。"
},
{
"id": "q11",
"type": "boolean",
"prompt": "餐厅用餐需提前预定,可以直接刷脸用餐。",
"answer": "true",
"explanation": "公司餐厅支持提前预定并刷脸用餐。"
},
{
"id": "q12",
"type": "boolean",
"prompt": "发生火灾、爆炸事故时,应立即拨打 119。",
"answer": "true",
"explanation": "火灾事故首先要联系消防,119 是基本应急要求。"
},
{
"id": "q13",
"type": "boolean",
"prompt": "住宿人员应保持高度防火意识,不准私拉乱接电线和使用高功率电器。",
"answer": "true",
"explanation": "宿舍防火是红线要求,私拉电线和使用大功率电器都被禁止。"
},
{
"id": "q14",
"type": "boolean",
"prompt": "遵守安全生产规章制度是从业人员应履行的安全生产义务。",
"answer": "true",
"explanation": "安全制度不仅是要求,也是员工必须履行的义务。"
},
{
"id": "q15",
"type": "boolean",
"prompt": "工牌可以随意借由他人使用。",
"answer": "false",
"explanation": "工牌属于个人身份凭证,严禁外借。"
},
{
"id": "q16",
"type": "boolean",
"prompt": "RoHS 主要用于规范电子电气产品的材料及工艺标准,使之更加有利于人体健康及环境保护。",
"answer": "true",
"explanation": "RoHS 的核心目标就是限制有害物质、降低环境与人体风险。"
},
{
"id": "q17",
"type": "boolean",
"prompt": "我们公司的 HSF 方针是:绿色设计,环保采购;节约资源,绿色产出。",
"answer": "true",
"explanation": "这是试卷给出的公司 HSF 方针原文。"
},
{
"id": "q18",
"type": "boolean",
"prompt": "EHS(Environment、Health、Safety)指环境健康安全。",
"answer": "true",
"explanation": "EHS 是环境、健康、安全三个维度的统一简称。"
},
{
"id": "q19",
"type": "boolean",
"prompt": "对于外来文件,组织不需对其进行控制与管理。",
"answer": "false",
"explanation": "外来文件同样需要受控管理,确保版本和使用正确。"
},
{
"id": "q20",
"type": "boolean",
"prompt": "与产品有关的要求应包括有关法律法规规定的要求及顾客的要求等。",
"answer": "true",
"explanation": "产品要求必须同时覆盖法规和客户要求,这是质量体系基础。"
}
]
}
}
+244
View File
@@ -449,5 +449,249 @@
"range": "顯示第 {start}-{end} 條,共 {total} 條",
"empty": "暫無符合條件的資料"
}
},
"training": {
"badge": "新人培訓工作區",
"title": "新人入職培訓 Agent",
"subtitle": "在同一個 Chat 頁面內完成影片學習、知識點複盤、逐題考試與 HR 管理統計。",
"tabs": {
"learner": "學員端",
"admin": "HR 管理"
},
"actions": {
"syncLearnerToChat": "同步學員上下文到聊天",
"syncHrToChat": "同步 HR 篩選到聊天",
"expandWorkspace": "展開工作區",
"collapseWorkspace": "收起工作區"
},
"steps": {
"video": "觀看影片",
"summary": "複盤知識點",
"exam": "逐題考試",
"result": "結算結果"
},
"progressLabel": "培訓進度",
"progressHint": "需依 HR 要求完成影片、知識點、考試三個環節後才算完成。",
"progressPercent": "完成度",
"stepNo": "步驟 {value}",
"defaultLearnerName": "當前學員",
"unknownDepartment": "待補充部門",
"video": {
"title": "第一步:觀看培訓影片",
"description": "員工先完成入職培訓影片學習,再進入知識點複盤與考試環節。",
"completeAction": "我已完成影片學習",
"playerTitle": "影片播放區",
"playerHint": "此處可接入企業影片連結或內部播放器。當前前端已預留完整容器與完成按鈕。"
},
"summary": {
"title": "第二步:知識點複盤",
"description": "根據 HR 提供的試卷,系統先提煉考試重點,幫助員工在答題前完成記憶強化。",
"startExam": "開始考試",
"keyPoints": "重點知識",
"mustKnow": "考前必知"
},
"exam": {
"title": "第三步:逐題考試",
"questionCounter": "第 {current} / {total} 題",
"currentScore": "當前分數:{score} 分",
"passLine": "及格線:90 分",
"correctFeedback": "回答正確,繼續下一題",
"wrongFeedback": "回答錯誤,已顯示正確答案",
"selectedAnswer": "你的答案:{answer}",
"correctAnswer": "正確答案:{answer}",
"nextQuestion": "下一題",
"finishExam": "完成考試"
},
"result": {
"passedTag": "已通過",
"failedTag": "需補考",
"passTitle": "恭喜,你已通過新人培訓考試",
"failTitle": "本次考試未達標,需要重新考試",
"passDescription": "前端已完成通過態互動,後續接入後端後可直接回寫培訓記錄與完成日期。",
"failDescription": "依照 HR 規則,低於 90 分必須重新考試,直到最終通過。",
"scoreLabel": "最終得分",
"attemptsLabel": "考試次數",
"correctCount": "答對題數",
"wrongCount": "答錯題數",
"completionDate": "完成日期",
"retryExam": "重新考試",
"sendToChat": "發送複盤到聊天"
},
"learnerCard": {
"title": "當前學員",
"name": "姓名",
"employeeId": "工號",
"department": "部門"
},
"rules": {
"title": "考試規則",
"rule1": "共 20 題,每題 5 分,滿分 100 分。",
"rule2": "系統依「一題一答一回饋」執行,答錯立即顯示正確答案。",
"rule3": "低於 90 分視為未通過,必須重新考試。",
"rule4": "HR 管理端可在同一聊天頁查看統計並匯出 Excel。"
},
"hr": {
"stats": {
"total": "參訓人數",
"passed": "已通過",
"failed": "未通過",
"inProgress": "進行中",
"passRate": "通過率"
},
"filters": {
"keywordLabel": "姓名 / 工號",
"keywordPlaceholder": "輸入姓名或工號篩選",
"statusLabel": "狀態",
"departmentLabel": "部門",
"allStatuses": "全部狀態",
"allDepartments": "全部部門",
"noLimit": "不限"
},
"columns": {
"joinDate": "入職日期",
"completionDate": "完成日期",
"department": "部門",
"name": "姓名",
"employeeId": "工號",
"score": "分數",
"attempts": "考試次數",
"status": "狀態"
},
"status": {
"passed": "已通過",
"failed": "未通過",
"in_progress": "進行中"
},
"actions": {
"askAgent": "讓 Agent 生成分析",
"export": "匯出 Excel"
},
"empty": "當前篩選條件下暫無培訓記錄。"
},
"chatPrompts": {
"hrSummaryPrefix": "請根據當前篩選條件,幫我總結新人培訓數據並列出異常名單。",
"afterVideo": "我已完成新人培訓影片,請結合考試範圍幫我總結重點知識。",
"afterSummary": "我已完成知識點複盤,請切換到考試模式並開始第一題。",
"afterPass": "我已通過新人培訓考試,得分 {score} 分,請幫我生成一段培訓完成總結。",
"afterFail": "我本次新人培訓考試得分 {score} 分,未達及格線,請幫我總結錯題重點並安排重考提醒。",
"examInProgress": "我正在進行新人培訓考試,目前做到第 {index}/{total} 題,請保持考官模式繼續出題。"
},
"summaryPoints": [
"工資每月 15 號發放,考勤與請假均需走 OA 流程。",
"餐廳訂餐使用中米新訂餐系統,忘記刷卡需走 OA 補刷卡流程。",
"5S 包括整理、整頓、清掃、清潔和素養,是現場管理基礎要求。",
"發生火災時要第一時間撥打 119,並在上風口使用滅火器。",
"QC080000 對應有害物質過程管理體系,RoHS 關注電子電氣產品環保要求。"
],
"summaryChecklist": [
"答題時系統只展示當前題目,避免一次性洩露完整答案。",
"答錯題目必須立即看到標準答案與簡短解析。",
"考試結束後只有分數達到 90 分才算通過。",
"管理端需要能匯出入職日期、完成日期、部門、姓名、工號和分數。"
],
"booleanOptions": [
{ "id": "true", "label": "正確" },
{ "id": "false", "label": "錯誤" }
],
"questionBank": [
{
"id": "q1",
"type": "single",
"prompt": "工資每月幾號發放?",
"answer": "c",
"explanation": "根據新人培訓試卷,工資固定在每月 15 號發放。",
"options": [
{ "id": "a", "label": "A. 8號" },
{ "id": "b", "label": "B. 9號" },
{ "id": "c", "label": "C. 15號" },
{ "id": "d", "label": "D. 27號" }
]
},
{
"id": "q2",
"type": "single",
"prompt": "餐廳訂餐的系統是?",
"answer": "b",
"explanation": "公司餐廳訂餐使用中米新訂餐系統,不是 OA 或 ERP。",
"options": [
{ "id": "a", "label": "A. OA" },
{ "id": "b", "label": "B. 中米新訂餐系統" },
{ "id": "c", "label": "C. ERP" }
]
},
{
"id": "q3",
"type": "single",
"prompt": "公司的產品有?",
"answer": "abcd",
"explanation": "試卷給出的四個選項都屬於公司產品範疇,前端以組合選項呈現為全選。",
"options": [
{ "id": "abcd", "label": "A/B/C/D 全部都是" },
{ "id": "ab", "label": "A/B" },
{ "id": "cd", "label": "C/D" },
{ "id": "a", "label": "僅 A" }
]
},
{
"id": "q4",
"type": "single",
"prompt": "請假需要開什麼 OA 單?",
"answer": "c",
"explanation": "請假必須發起 OA 請假申請單,不能使用加班申請單或聯絡單。",
"options": [
{ "id": "a", "label": "A. 加班申請單" },
{ "id": "b", "label": "B. 聯絡單" },
{ "id": "c", "label": "C. 請假申請單" },
{ "id": "d", "label": "D. 員工需求單" }
]
},
{
"id": "q5",
"type": "single",
"prompt": "QC080000 是什麼?",
"answer": "a",
"explanation": "QC080000 對應有害物質過程管理體系認證標準。",
"options": [
{ "id": "a", "label": "A. 有害物質過程管理體系認證標準" },
{ "id": "b", "label": "B. 職業健康安全管理體系" },
{ "id": "c", "label": "C. 環境管理體系" }
]
},
{
"id": "q6",
"type": "single",
"prompt": "5S 指的是?",
"answer": "a",
"explanation": "5S 標準表述為整理、整頓、清掃、清潔和素養。",
"options": [
{ "id": "a", "label": "A. 整理、整頓、清掃、清潔和素養" },
{ "id": "b", "label": "B. 整理、整頓、打掃、清潔和素養" }
]
},
{
"id": "q7",
"type": "single",
"prompt": "使用滅火器應站在火源的哪裡?",
"answer": "a",
"explanation": "使用滅火器要站在上風口,避免煙霧與火勢倒灌。",
"options": [
{ "id": "a", "label": "A. 上風口" },
{ "id": "b", "label": "B. 下風口" }
]
},
{ "id": "q8", "type": "boolean", "prompt": "正常出勤必須打卡,加班需要提前申請提報。", "answer": "true", "explanation": "出勤與加班都需要遵循公司考勤制度。" },
{ "id": "q9", "type": "boolean", "prompt": "忘記刷卡需要 OA 開補刷卡單。", "answer": "true", "explanation": "漏打卡需要透過 OA 補刷卡流程修正考勤記錄。" },
{ "id": "q10", "type": "boolean", "prompt": "每月工資從上月 21 日至本月 20 日為止計算。", "answer": "true", "explanation": "試卷中明確了工資核算週期的起止時間。" },
{ "id": "q11", "type": "boolean", "prompt": "餐廳用餐需提前預定,可以直接刷臉用餐。", "answer": "true", "explanation": "公司餐廳支援提前預定並刷臉用餐。" },
{ "id": "q12", "type": "boolean", "prompt": "發生火災、爆炸事故時,應立即撥打 119。", "answer": "true", "explanation": "火災事故首先要聯絡消防,119 是基本應急要求。" },
{ "id": "q13", "type": "boolean", "prompt": "住宿人員應保持高度防火意識,不准私拉亂接電線和使用高功率電器。", "answer": "true", "explanation": "宿舍防火是紅線要求,私拉電線和使用大功率電器都被禁止。" },
{ "id": "q14", "type": "boolean", "prompt": "遵守安全生產規章制度是從業人員應履行的安全生產義務。", "answer": "true", "explanation": "安全制度不僅是要求,也是員工必須履行的義務。" },
{ "id": "q15", "type": "boolean", "prompt": "工牌可以隨意借由他人使用。", "answer": "false", "explanation": "工牌屬於個人身份憑證,嚴禁外借。" },
{ "id": "q16", "type": "boolean", "prompt": "RoHS 主要用於規範電子電氣產品的材料及工藝標準,使之更加有利於人體健康及環境保護。", "answer": "true", "explanation": "RoHS 的核心目標就是限制有害物質、降低環境與人體風險。" },
{ "id": "q17", "type": "boolean", "prompt": "我們公司的 HSF 方針是:綠色設計,環保採購;節約資源,綠色產出。", "answer": "true", "explanation": "這是試卷給出的公司 HSF 方針原文。" },
{ "id": "q18", "type": "boolean", "prompt": "EHS(Environment、Health、Safety)指環境健康安全。", "answer": "true", "explanation": "EHS 是環境、健康、安全三個維度的統一簡稱。" },
{ "id": "q19", "type": "boolean", "prompt": "對於外來文件,組織不需對其進行控制與管理。", "answer": "false", "explanation": "外來文件同樣需要受控管理,確保版本與使用正確。" },
{ "id": "q20", "type": "boolean", "prompt": "與產品有關的要求應包括有關法律法規規定的要求及顧客的要求等。", "answer": "true", "explanation": "產品要求必須同時覆蓋法規和客戶要求,這是品質體系基礎。" }
]
}
}