feat(training): 完成员工培训闭环与管理配置
This commit is contained in:
1 parent
91758ef2b4
commit
95f3906779
37 files changed
+1766
-249
No files matched your search
@@ -70,6 +70,20 @@ const getMessageKey = (msg: ChatMessage, index: number) => (
|
||||
|| (typeof msg.chat_log_id === 'number' ? `chat-log:${msg.chat_log_id}` : '')
|
||||
|| `${msg.role}:${msg.run_id || 'none'}:${String(msg.content || '').slice(0, 40)}:${index}`
|
||||
);
|
||||
|
||||
/**
|
||||
* 标记“当前消息后面是否还存在新的 assistant 消息”。
|
||||
* 核心逻辑:培训题卡属于“最新一张 assistant 题卡”才能继续交互;
|
||||
* 用户作答后虽然会追加一条 user 消息,但这不应让上一张题卡立刻失活。
|
||||
*/
|
||||
const isLatestAssistantMessage = (items: ChatMessage[], index: number) => {
|
||||
const current = items[index];
|
||||
if (!current || current.role !== 'assistant') return false;
|
||||
for (let i = items.length - 1; i > index; i -= 1) {
|
||||
if (items[i]?.role === 'assistant') return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -98,6 +112,7 @@ const getMessageKey = (msg: ChatMessage, index: number) => (
|
||||
:show-chat-rating="showChatRating"
|
||||
:copied-index="copiedIndex"
|
||||
:is-shipping-notice-agent="isShippingNoticeAgent"
|
||||
:is-latest-assistant-message="isLatestAssistantMessage(messages, index)"
|
||||
:handlers="handlers"
|
||||
:leave-handlers="leaveHandlers"
|
||||
:shipping-handlers="shippingHandlers"
|
||||
|
||||
@@ -19,7 +19,7 @@ import TrainingWorkspacePanel from '@/features/chat/components/TrainingWorkspace
|
||||
import LedgerConfigPanel from '@/features/maintenance/components/LedgerConfigPanel.vue';
|
||||
import MaintenanceRecordManagerPanel from '@/features/maintenance/components/MaintenanceRecordManagerPanel.vue';
|
||||
import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
import { matchesTrainingAgent } from '@/features/chat/composables/useTrainingWorkspace';
|
||||
import { matchesTrainingAgent } from '@/features/chat/training/trainingWorkspace.utils';
|
||||
|
||||
const page = useChatPageContext();
|
||||
const isTrainingAgentPage = computed(() => matchesTrainingAgent(page.currentAgent));
|
||||
@@ -146,8 +146,11 @@ watch(() => page.currentAgentId, () => {
|
||||
<TrainingWorkspacePanel
|
||||
:current-agent="page.currentAgent"
|
||||
:current-user="page.currentUser"
|
||||
:agent-guides="page.agentGuides"
|
||||
:has-messages="page.messages.length > 0"
|
||||
:new-session-tick="page.viewId"
|
||||
:training="page.training"
|
||||
@open-guide="page.openGuideModal"
|
||||
@send-chat-prompt="page.handleSend($event)"
|
||||
@push-local-assistant-message="page.pushLocalAssistantMessage($event)"
|
||||
@update:expanded="isTrainingWorkspaceExpanded = $event"
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
import { computed, reactive, ref, watch, type ShallowUnwrapRef } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
BarChart3,
|
||||
BookOpen,
|
||||
CheckCircle2,
|
||||
ChevronDown,
|
||||
@@ -17,24 +16,26 @@ import {
|
||||
Download,
|
||||
PlayCircle,
|
||||
RefreshCcw,
|
||||
Send,
|
||||
ShieldCheck,
|
||||
Target,
|
||||
Users,
|
||||
XCircle,
|
||||
} from 'lucide-vue-next';
|
||||
import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWorkspace';
|
||||
import { resolveTrainingExamPdfGuide, type TrainingGuideLike } from '@/features/chat/training/trainingWorkspace.utils';
|
||||
|
||||
const props = defineProps<{
|
||||
currentAgent: Record<string, unknown> | null;
|
||||
currentUser: Record<string, unknown> | null;
|
||||
agentGuides: TrainingGuideLike[];
|
||||
hasMessages: boolean;
|
||||
newSessionTick: number;
|
||||
training: ShallowUnwrapRef<ReturnType<typeof useTrainingWorkspace>>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'send-chat-prompt': [prompt: string];
|
||||
'push-local-assistant-message': [content: string];
|
||||
'open-guide': [guideId?: number];
|
||||
'update:expanded': [expanded: boolean];
|
||||
}>();
|
||||
|
||||
@@ -94,23 +95,25 @@ const setWorkspaceExpanded = (expanded: boolean, manual = 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 || '';
|
||||
});
|
||||
|
||||
const trainingExamPdfGuide = computed(() => resolveTrainingExamPdfGuide(props.agentGuides));
|
||||
|
||||
// 默认进入 Chat 聊天页面(即收起工作区状态)
|
||||
const workspaceExpanded = ref(false);
|
||||
|
||||
const autoSyncInitialPrompt = () => {
|
||||
if (workspace.isTrainingAgent && workspace.isHydrated && !props.hasMessages) {
|
||||
emit('push-local-assistant-message', workspace.learnerChatPrompt);
|
||||
if (
|
||||
workspace.isTrainingAgent
|
||||
&& workspace.isHydrated
|
||||
&& !props.hasMessages
|
||||
&& workspace.shouldShowNewSessionReminder
|
||||
) {
|
||||
emit('push-local-assistant-message', workspace.newSessionReminderMessage);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -142,6 +145,14 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.newSessionTick,
|
||||
(tick, prevTick) => {
|
||||
if (!tick || tick === prevTick) return;
|
||||
autoSyncInitialPrompt();
|
||||
},
|
||||
);
|
||||
|
||||
const isCompactMode = computed(() => !workspaceExpanded.value);
|
||||
|
||||
const compactSummary = computed(() => {
|
||||
@@ -158,6 +169,14 @@ const compactSummary = computed(() => {
|
||||
}
|
||||
return workspace.isPassed ? t('chat.training.result.passTitle') : t('chat.training.result.failTitle');
|
||||
});
|
||||
|
||||
const trainingTitle = computed(() => String(t('chat.training.title') || '').trim());
|
||||
const ruleItems = computed(() => ([
|
||||
t('chat.training.rules.rule1', { total: workspace.totalQuestionCount }),
|
||||
t('chat.training.rules.rule2'),
|
||||
t('chat.training.rules.rule3', { passScore: workspace.passScore }),
|
||||
t('chat.training.rules.rule4'),
|
||||
]));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -177,8 +196,8 @@ const compactSummary = computed(() => {
|
||||
<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 v-if="trainingTitle" class="text-sm font-semibold text-primary md:text-base">
|
||||
{{ trainingTitle }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-1.5 flex flex-wrap gap-2">
|
||||
@@ -203,6 +222,15 @@ const compactSummary = computed(() => {
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||||
<button
|
||||
v-if="trainingExamPdfGuide"
|
||||
type="button"
|
||||
class="inline-flex h-9 items-center gap-2 rounded-xl border border-default bg-white px-3.5 text-xs font-medium leading-none text-secondary transition hover:bg-surface-soft"
|
||||
@click="emit('open-guide', Number(trainingExamPdfGuide.id))"
|
||||
>
|
||||
<BookOpen class="h-4 w-4 shrink-0" />
|
||||
<span class="leading-none">{{ $t('chat.training.actions.viewExamPdf') }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="workspace.stage === 'video'"
|
||||
type="button"
|
||||
@@ -212,23 +240,6 @@ const compactSummary = computed(() => {
|
||||
<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"
|
||||
@@ -276,8 +287,8 @@ const compactSummary = computed(() => {
|
||||
<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 v-if="trainingTitle" class="text-sm font-semibold text-primary md:text-base">
|
||||
{{ trainingTitle }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -304,21 +315,13 @@ const compactSummary = computed(() => {
|
||||
|
||||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||||
<button
|
||||
v-if="trainingExamPdfGuide"
|
||||
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)"
|
||||
class="inline-flex h-9 items-center gap-2 rounded-xl border border-default bg-white px-3.5 text-xs font-medium leading-none text-secondary transition hover:bg-surface-soft"
|
||||
@click="emit('open-guide', Number(trainingExamPdfGuide.id))"
|
||||
>
|
||||
<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') }}
|
||||
<BookOpen class="h-4 w-4 shrink-0" />
|
||||
<span class="leading-none">{{ $t('chat.training.actions.viewExamPdf') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@@ -409,6 +412,15 @@ const compactSummary = computed(() => {
|
||||
<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>
|
||||
<button
|
||||
v-if="trainingExamPdfGuide"
|
||||
type="button"
|
||||
class="inline-flex items-center justify-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="emit('open-guide', Number(trainingExamPdfGuide.id))"
|
||||
>
|
||||
<BookOpen class="h-4 w-4" />
|
||||
{{ $t('chat.training.actions.viewExamPdf') }}
|
||||
</button>
|
||||
</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" />
|
||||
@@ -427,14 +439,25 @@ const compactSummary = computed(() => {
|
||||
<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 class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="trainingExamPdfGuide"
|
||||
type="button"
|
||||
class="inline-flex items-center justify-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="emit('open-guide', Number(trainingExamPdfGuide.id))"
|
||||
>
|
||||
<BookOpen class="h-4 w-4" />
|
||||
{{ $t('chat.training.actions.viewExamPdf') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-brand-700"
|
||||
@click="workspace.startExam"
|
||||
>
|
||||
<Target class="h-4 w-4" />
|
||||
{{ $t('chat.training.summary.startExam') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 grid gap-3 md:grid-cols-2">
|
||||
@@ -475,7 +498,7 @@ const compactSummary = computed(() => {
|
||||
{{ $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') }}
|
||||
{{ $t('chat.training.exam.passLine', { passScore: workspace.passScore }) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -565,7 +588,7 @@ const compactSummary = computed(() => {
|
||||
{{ 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') }}
|
||||
{{ workspace.isPassed ? $t('chat.training.result.passDescription') : $t('chat.training.result.failDescription', { passScore: workspace.passScore }) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -606,14 +629,6 @@ const compactSummary = computed(() => {
|
||||
<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>
|
||||
@@ -643,21 +658,9 @@ const compactSummary = computed(() => {
|
||||
|
||||
<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">
|
||||
<li v-for="rule in ruleItems" :key="rule" class="flex gap-2">
|
||||
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
|
||||
<span>{{ $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>
|
||||
<span>{{ rule }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -667,32 +670,41 @@ const compactSummary = computed(() => {
|
||||
<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 class="flex items-center justify-center gap-2 text-center">
|
||||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.total') }}</div>
|
||||
<div class="text-2xl font-semibold text-primary">{{ workspace.stats.total }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="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 class="flex items-center justify-center gap-2 text-center">
|
||||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.passed') }}</div>
|
||||
<div class="text-2xl font-semibold text-emerald-600">{{ workspace.stats.passed }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="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 class="flex items-center justify-center gap-2 text-center">
|
||||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.failed') }}</div>
|
||||
<div class="text-2xl font-semibold text-amber-600">{{ workspace.stats.failed }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="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 class="flex items-center justify-center gap-2 text-center">
|
||||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.inProgress') }}</div>
|
||||
<div class="text-2xl font-semibold text-blue-600">{{ workspace.stats.inProgress }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="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 class="flex items-center justify-center gap-2 text-center">
|
||||
<div class="text-sm text-muted">{{ $t('chat.training.hr.stats.passRate') }}</div>
|
||||
<div class="text-2xl font-semibold text-primary">{{ workspace.stats.passRate }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="grid gap-3 xl:grid-cols-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>
|
||||
<div class="grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,1fr)_auto] xl:items-center">
|
||||
<label>
|
||||
<input
|
||||
v-model="workspace.hrKeyword"
|
||||
type="text"
|
||||
@@ -700,8 +712,7 @@ const compactSummary = computed(() => {
|
||||
: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>
|
||||
<label>
|
||||
<select
|
||||
v-model="workspace.hrStatusFilter"
|
||||
class="w-full rounded-xl border border-default bg-surface px-3 py-2.5 text-sm text-primary outline-none transition focus:border-brand-300"
|
||||
@@ -712,8 +723,7 @@ const compactSummary = computed(() => {
|
||||
<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>
|
||||
<label>
|
||||
<select
|
||||
v-model="workspace.hrDepartmentFilter"
|
||||
class="w-full rounded-xl border border-default bg-surface px-3 py-2.5 text-sm text-primary outline-none transition focus:border-brand-300"
|
||||
@@ -724,17 +734,7 @@ const compactSummary = computed(() => {
|
||||
</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>
|
||||
<div class="flex justify-center xl:justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-10 items-center gap-2 rounded-xl bg-brand-600 px-4 text-xs font-medium text-white transition hover:bg-brand-700 sm:text-sm"
|
||||
@@ -743,6 +743,7 @@ const compactSummary = computed(() => {
|
||||
<Download class="h-4 w-4" />
|
||||
{{ $t('chat.training.hr.actions.export') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ const {
|
||||
showChatRating,
|
||||
copiedIndex,
|
||||
isShippingNoticeAgent,
|
||||
isLatestAssistantMessage,
|
||||
handlers,
|
||||
leaveHandlers,
|
||||
shippingHandlers,
|
||||
@@ -60,6 +61,7 @@ const {
|
||||
showChatRating: boolean;
|
||||
copiedIndex: number | null;
|
||||
isShippingNoticeAgent: boolean;
|
||||
isLatestAssistantMessage: boolean;
|
||||
handlers: ChatMessageBubbleHandlers;
|
||||
leaveHandlers: LeaveMessageHandlers;
|
||||
shippingHandlers: ShippingMappingHandlers;
|
||||
@@ -93,20 +95,35 @@ const isTrainingVideoMessage = computed(() => {
|
||||
if (message.role !== 'assistant') return false;
|
||||
// 只要包含特定引导文案,就显示视频占位符,不限于最后一条消息
|
||||
const content = message.content || '';
|
||||
return content.includes('专属入职培训助手') || (content.includes('看视频') && content.includes('已看完'));
|
||||
return content.includes('专属入职培训助手')
|
||||
|| content.includes('onboarding training assistant')
|
||||
|| content.includes('ผู้ช่วยอบรมพนักงานใหม่')
|
||||
|| content.includes('入职培训视频')
|
||||
|| content.includes('training video');
|
||||
});
|
||||
|
||||
const isTrainingSummaryMessage = computed(() => {
|
||||
if (message.role !== 'assistant') return false;
|
||||
const content = message.content || '';
|
||||
return content.includes('完成视频学习') || content.includes('复盘重点知识') || content.includes('复盘知识点') || content.includes('总结重点知识');
|
||||
return content.includes('完成视频学习')
|
||||
|| content.includes('复盘重点知识')
|
||||
|| content.includes('复盘知识点')
|
||||
|| content.includes('总结重点知识')
|
||||
|| content.includes('核心知识点')
|
||||
|| content.includes('key knowledge points')
|
||||
|| content.includes('ประเด็นสำคัญ');
|
||||
});
|
||||
|
||||
const isTrainingResultMessage = computed(() => {
|
||||
if (message.role !== 'assistant') return false;
|
||||
// 只要是结果文案,就显示结算卡片,不限于最后一条消息
|
||||
const content = message.content || '';
|
||||
return content.includes('考试结束') || content.includes('顺利通过新人考核');
|
||||
return content.includes('考试结束')
|
||||
|| content.includes('顺利通过新人考核')
|
||||
|| content.includes('Exam finished')
|
||||
|| content.includes('passed the onboarding assessment')
|
||||
|| content.includes('สอบเสร็จแล้ว')
|
||||
|| content.includes('ผ่านการประเมินพนักงานใหม่');
|
||||
});
|
||||
|
||||
const retrieverResources = computed(() => handlers.getDisplayRetrieverResources(message));
|
||||
@@ -125,7 +142,7 @@ const showShippingActionsPanel = computed(() =>
|
||||
&& !!message.shipping_actions?.length
|
||||
&& message.type !== 'shipping-match-result',
|
||||
);
|
||||
const isLastMessage = computed(() => index === messageCount - 1);
|
||||
const isLastMessage = computed(() => index === messageCount - 1 || (message.role === 'assistant' && isLatestAssistantMessage));
|
||||
const isCopied = computed(() => copiedIndex === index);
|
||||
const renderedMarkdown = computed(() => (
|
||||
message.role === 'assistant' ? handlers.renderMarkdown(message.content) : ''
|
||||
@@ -614,19 +631,22 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
:current-question-index="trainingHandlers.getCurrentQuestionIndex()"
|
||||
:answered-count="trainingHandlers.getAnsweredCount()"
|
||||
:total-count="trainingHandlers.getTotalCount()"
|
||||
:pass-score="trainingHandlers.getPassScore()"
|
||||
:score="trainingHandlers.getScore()"
|
||||
:selected-option-id="trainingHandlers.getSelectedOptionId()"
|
||||
:answer-locked="trainingHandlers.getAnswerLocked()"
|
||||
:feedback-correct="trainingHandlers.getFeedbackCorrect()"
|
||||
:answer-label="trainingHandlers.getAnswerLabel()"
|
||||
:latest-exam-feedback="trainingHandlers.getLatestExamFeedback()"
|
||||
:is-thinking="isThinking"
|
||||
@select="trainingHandlers.onSelect"
|
||||
@next="trainingHandlers.onNext"
|
||||
/>
|
||||
<TrainingResultCard
|
||||
v-else-if="isTrainingResultMessage"
|
||||
:score="trainingHandlers.getScore()"
|
||||
:is-passed="trainingHandlers.getScore() >= 90"
|
||||
:score="trainingHandlers.getResultScore()"
|
||||
:is-passed="trainingHandlers.getResultPassed()"
|
||||
:pass-score="trainingHandlers.getPassScore()"
|
||||
:correct-count="trainingHandlers.getCorrectCount()"
|
||||
:wrong-count="trainingHandlers.getWrongCount()"
|
||||
:is-thinking="isThinking"
|
||||
|
||||
@@ -5,23 +5,27 @@
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { CheckCircle2, XCircle, ClipboardCheck } from 'lucide-vue-next';
|
||||
import type { TrainingQuestion } from '@/features/chat/training/training.types';
|
||||
import type { TrainingExamTransitionFeedback, TrainingQuestion } from '@/features/chat/training/training.types';
|
||||
|
||||
export interface TrainingHandlers {
|
||||
getQuestion: () => TrainingQuestion | null;
|
||||
getCurrentQuestionIndex: () => number;
|
||||
getAnsweredCount: () => number;
|
||||
getTotalCount: () => number;
|
||||
getPassScore: () => number;
|
||||
getScore: () => number;
|
||||
getSelectedOptionId: () => string;
|
||||
getAnswerLocked: () => boolean;
|
||||
getFeedbackCorrect: () => boolean;
|
||||
getAnswerLabel: () => string;
|
||||
getLatestExamFeedback: () => TrainingExamTransitionFeedback | null;
|
||||
onSelect: (optionId: string) => void;
|
||||
onNext: () => void;
|
||||
onPlayVideo: () => void;
|
||||
onStartExam: () => void;
|
||||
onRestartExam: () => void;
|
||||
getResultScore: () => number;
|
||||
getResultPassed: () => boolean;
|
||||
getCorrectCount: () => number;
|
||||
getWrongCount: () => number;
|
||||
getSummaryPoints: () => string[];
|
||||
@@ -33,11 +37,13 @@ const props = defineProps<{
|
||||
currentQuestionIndex: number;
|
||||
answeredCount: number;
|
||||
totalCount: number;
|
||||
passScore: number;
|
||||
score: number;
|
||||
selectedOptionId: string;
|
||||
answerLocked: boolean;
|
||||
feedbackCorrect: boolean;
|
||||
answerLabel: string;
|
||||
latestExamFeedback: TrainingExamTransitionFeedback | null;
|
||||
isThinking: boolean;
|
||||
}>();
|
||||
|
||||
@@ -46,7 +52,6 @@ const emit = defineEmits<{
|
||||
next: [];
|
||||
}>();
|
||||
|
||||
const passLine = 90;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -68,7 +73,42 @@ const passLine = 90;
|
||||
</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>
|
||||
<span class="text-slate-800 font-bold">{{ passScore }} 分</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 上一题反馈摘要:自动推进到下一题后,仍需把对错、解析和分数留在同一张题卡顶部 -->
|
||||
<div
|
||||
v-if="latestExamFeedback"
|
||||
class="rounded-2xl border p-4"
|
||||
:class="latestExamFeedback.correct ? 'border-emerald-100 bg-emerald-50/60' : 'border-red-100 bg-red-50/60'"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2 text-sm font-bold" :class="latestExamFeedback.correct ? 'text-emerald-700' : 'text-red-700'">
|
||||
<CheckCircle2 v-if="latestExamFeedback.correct" class="h-4 w-4" />
|
||||
<XCircle v-else class="h-4 w-4" />
|
||||
{{ latestExamFeedback.correct ? $t('chat.training.exam.correctFeedback') : $t('chat.training.exam.wrongFeedback') }}
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/70 px-3 py-1 text-xs font-semibold text-slate-600">
|
||||
{{ $t('chat.training.exam.currentScore', { score: latestExamFeedback.scoreAfterAnswer }) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 space-y-2 text-[13px] leading-6 text-slate-600">
|
||||
<div class="text-slate-500">{{ latestExamFeedback.questionPrompt }}</div>
|
||||
<div class="flex gap-2">
|
||||
<span class="font-medium" :class="latestExamFeedback.correct ? 'text-emerald-600' : 'text-red-600'">
|
||||
{{ $t('chat.training.exam.selectedAnswer', { answer: latestExamFeedback.selectedAnswerLabel || '--' }) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="!latestExamFeedback.correct" class="flex gap-2">
|
||||
<span class="text-emerald-600 font-medium">
|
||||
{{ $t('chat.training.exam.correctAnswer', { answer: latestExamFeedback.correctAnswerLabel || '--' }) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="pl-2 border-l-2 border-slate-200/60 text-slate-500/90">
|
||||
{{ latestExamFeedback.explanation }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ShieldCheck, XCircle, RotateCcw, CheckCircle2 } from 'lucide-vue-next';
|
||||
defineProps<{
|
||||
score: number;
|
||||
isPassed: boolean;
|
||||
passScore: number;
|
||||
correctCount: number;
|
||||
wrongCount: number;
|
||||
isThinking: boolean;
|
||||
@@ -65,7 +66,7 @@ const emit = defineEmits<{
|
||||
|
||||
<!-- 描述语 -->
|
||||
<div class="text-sm leading-relaxed text-slate-600">
|
||||
{{ isPassed ? $t('chat.training.result.passDescription') : $t('chat.training.result.failDescription') }}
|
||||
{{ isPassed ? $t('chat.training.result.passDescription') : $t('chat.training.result.failDescription', { passScore }) }}
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
|
||||
Reference in new issue
Block a user