- 回放对话时调用 API 获取对话详情 - 添加加载状态显示 - 添加空数据提示 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -283,8 +283,15 @@
|
||||
</div>
|
||||
|
||||
<!-- 对话记录 -->
|
||||
<div class="conversation-replay">
|
||||
<div class="conversation-list">
|
||||
<div class="conversation-replay" v-loading="replayLoading">
|
||||
<!-- 空状态提示 -->
|
||||
<el-empty
|
||||
v-if="!replayLoading && (!currentRecord.conversation || currentRecord.conversation.length === 0)"
|
||||
description="暂无对话记录"
|
||||
/>
|
||||
|
||||
<!-- 对话列表 -->
|
||||
<div class="conversation-list" v-else>
|
||||
<div
|
||||
v-for="(message, index) in currentRecord.conversation"
|
||||
:key="index"
|
||||
@@ -342,6 +349,7 @@ const total = ref(0)
|
||||
|
||||
// 弹窗状态
|
||||
const replayDialogVisible = ref(false)
|
||||
const replayLoading = ref(false)
|
||||
const currentRecord = ref<any>(null)
|
||||
|
||||
// 筛选表单
|
||||
@@ -608,9 +616,32 @@ const viewPracticeReport = (record: any) => {
|
||||
/**
|
||||
* 回放陪练对话
|
||||
*/
|
||||
const replayPractice = (record: any) => {
|
||||
currentRecord.value = record
|
||||
replayDialogVisible.value = true
|
||||
const replayPractice = async (record: any) => {
|
||||
try {
|
||||
// 先设置基本信息并打开弹窗
|
||||
currentRecord.value = { ...record, conversation: [] }
|
||||
replayDialogVisible.value = true
|
||||
replayLoading.value = true
|
||||
|
||||
// 调用 API 获取对话详情
|
||||
const response: any = await practiceApi.getPracticeReport(record.sessionId)
|
||||
|
||||
if (response.code === 200 && response.data?.analysis?.dialogue_review) {
|
||||
// 转换对话数据格式
|
||||
const dialogueReview = response.data.analysis.dialogue_review
|
||||
currentRecord.value.conversation = dialogueReview.map((item: any) => ({
|
||||
role: item.speaker === 'user' ? 'user' : 'ai',
|
||||
content: item.content,
|
||||
timestamp: item.time || '',
|
||||
feedback: item.comment || ''
|
||||
}))
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('获取对话详情失败:', error)
|
||||
ElMessage.error('获取对话详情失败,请稍后重试')
|
||||
} finally {
|
||||
replayLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user