feat(web): AI 工作台会话与文档卡片渲染增强

- aiConversationHtmlRenderer 识别单据记录类表格并渲染为卡片列表,新增删除申请单详情的禁用占位链接
- aiWorkbenchConversationStore 增加草稿删除后会话链接失效处理,避免点击已删除单据跳转
- aiApplicationPreviewActions 调整提交/草稿调用路径,PersonalWorkbenchAiMode 接入新的会话存储与渲染
- ConfirmDialog/TravelRequestDeleteDialog/useAppShell/AppShellRouteView 配套适配,同步更新相关前端测试
This commit is contained in:
caoxiaozhu
2026-06-20 21:44:16 +08:00
parent 81e990ab72
commit 0cda750ff0
19 changed files with 734 additions and 92 deletions

View File

@@ -3,6 +3,11 @@ import { readFileSync } from 'node:fs'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
import {
markAiWorkbenchConversationDraftDeleted,
loadAiWorkbenchConversationHistory,
saveAiWorkbenchConversation
} from '../src/utils/aiWorkbenchConversationStore.js'
import {
clearAssistantSessionSnapshotForDraftClaim,
readAssistantSessionSnapshot,
@@ -79,6 +84,42 @@ test('claim delete flow invalidates the matching financial assistant session', (
assert.match(createViewScript, /toast\('该草稿单据已删除,相关财务助手会话已清空。'\)/)
})
test('deleting an application draft marks AI workbench detail links as unavailable', () => {
installWindowStub()
const user = { username: 'zhangsan@example.com' }
saveAiWorkbenchConversation(user, {
id: 'conversation-application-draft',
title: '申请草稿',
messages: [
{
id: 'assistant-draft-saved',
role: 'assistant',
content: [
'### 申请草稿已保存',
'',
'| 单据类型 | 单据编号 | 单据状态 | 当前节点 | 操作 |',
'| --- | --- | --- | --- | --- |',
'| 出差申请 | AP-20260620-DRAFT | 草稿 | 待提交 | [查看](#ai-open-application-detail:claim_id%3Dclaim-draft-1%26claim_no%3DAP-20260620-DRAFT) |'
].join('\n')
}
]
})
const nextHistory = markAiWorkbenchConversationDraftDeleted(user, {
claimId: 'claim-draft-1',
claimNo: 'AP-20260620-DRAFT'
})
const conversation = nextHistory.find((item) => item.id === 'conversation-application-draft')
assert.ok(conversation)
assert.match(conversation.messages[0].content, /#ai-deleted-application-detail:/)
assert.doesNotMatch(conversation.messages[0].content, /#ai-open-application-detail:/)
assert.match(conversation.messages.at(-1).content, /用户已经删除了草稿单据 AP-20260620-DRAFT/)
assert.match(conversation.messages.at(-1).content, /草稿单据已经删除,请重新再次申请。/)
assert.equal(loadAiWorkbenchConversationHistory(user)[0].messages.length, 2)
})
test('saving a draft keeps the financial assistant open for continued work', () => {
const appShellScript = readFileSync(
fileURLToPath(new URL('../src/composables/useAppShell.js', import.meta.url)),