fix(aihr): load real practice records first
This commit is contained in:
@@ -24,6 +24,15 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-alert
|
||||
v-if="recordsFallback"
|
||||
class="data-warning"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
title="训练记录接口暂不可用,当前显示演示记录,不代表真实训练数据。"
|
||||
/>
|
||||
|
||||
<section class="flow-strip">
|
||||
<div v-for="step in flowSteps" :key="step.title" class="flow-step" :class="{ active: step.active, done: step.done }">
|
||||
<span>{{ step.index }}</span>
|
||||
@@ -322,6 +331,7 @@ import {
|
||||
type PracticePrepCardResponse,
|
||||
type PracticeScenarioResponse
|
||||
} from '@/api/aihr/practice';
|
||||
import { listPracticeReviews } from '@/api/aihr/mobile-admin';
|
||||
import { searchKnowledgeSop, type SopSearchResponse } from '@/api/aihr/sop';
|
||||
import { resolvePilotDateWindow } from './pilot-export';
|
||||
|
||||
@@ -476,6 +486,7 @@ const sopHelpLoading = ref(false);
|
||||
const sopHelpMessage = ref('');
|
||||
const conversation = ref<ChatTurn[]>([]);
|
||||
const records = ref([...baseRecords]);
|
||||
const recordsFallback = ref(true);
|
||||
const promptTemplates = ref<PromptTemplateResponse[]>([]);
|
||||
const promptLoading = ref(false);
|
||||
const promptSaving = ref(false);
|
||||
@@ -643,6 +654,24 @@ const loadScenarioOptions = async () => {
|
||||
await loadPrepCard();
|
||||
};
|
||||
|
||||
const loadRecentRecords = async () => {
|
||||
try {
|
||||
const { data } = await listPracticeReviews({ limit: 10 });
|
||||
records.value = (data || []).map((item) => ({
|
||||
time: item.time,
|
||||
trainee: item.trainee,
|
||||
scene: item.scene,
|
||||
score: item.score,
|
||||
status: item.status,
|
||||
summary: item.summary
|
||||
}));
|
||||
recordsFallback.value = false;
|
||||
} catch {
|
||||
records.value = [...baseRecords];
|
||||
recordsFallback.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const appendTurn = (role: ChatRole, text: string) => {
|
||||
const nameMap = { customer: 'AI 业主', trainee: '学员', coach: 'AI 教练' };
|
||||
conversation.value.push({ id: `${role}-${conversation.value.length}`, role, name: nameMap[role], text });
|
||||
@@ -669,7 +698,6 @@ const resetPractice = () => {
|
||||
calibrationReason.value = '管理端人工校准';
|
||||
calibrationMessage.value = '';
|
||||
conversation.value = [];
|
||||
records.value = [...baseRecords];
|
||||
};
|
||||
|
||||
const handleScenarioChange = () => {
|
||||
@@ -805,7 +833,7 @@ const finishScore = async () => {
|
||||
|
||||
scored.value = true;
|
||||
calibrationScore.value = Math.max(0, Math.min(100, Math.round(Number(displayTotal.value) || 0)));
|
||||
records.value = [nextRecord, ...baseRecords];
|
||||
records.value = [nextRecord, ...records.value];
|
||||
if (apiMode.value !== 'api') {
|
||||
ElMessage.success('考官评分已生成,并写入本地对练记录');
|
||||
}
|
||||
@@ -970,6 +998,7 @@ const togglePromptTemplate = async (template: PromptTemplateResponse) => {
|
||||
onMounted(() => {
|
||||
void loadScenarioOptions();
|
||||
void loadPromptTemplates();
|
||||
void loadRecentRecords();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user