feat: 新增预算助手报告组件并优化报销交互细节

新增预算助手报告视图模型和组件,优化报销洞察面板和消息项
样式细节,完善预算中心页面布局和文档中心视图,增强报销创
建会话管理和提交编排器,调整 Vite 构建配置,补充单元测试。
This commit is contained in:
caoxiaozhu
2026-05-27 12:27:17 +08:00
parent b1a9c8a194
commit 7d32eae74e
23 changed files with 1197 additions and 464 deletions

View File

@@ -2,7 +2,7 @@ import { buildSuggestedActionKey } from '../../utils/suggestedActionKey.js'
import { normalizeExpenseQueryPayload } from './travelReimbursementExpenseQueryModel.js'
import { buildAgentInsight, buildReviewFilePreviewsFromReviewPayload } from './travelReimbursementAttachmentModel.js'
import { resolveExpenseTypeLabel } from './travelReimbursementReviewModel.js'
import { isBudgetMonitorUser, isExecutiveUser } from '../../utils/accessControl.js'
import { isBudgetMonitorUser, isExecutiveUser, isPlatformAdminUser } from '../../utils/accessControl.js'
import {
GUIDED_ACTION_OPEN_TRAVEL_CALCULATOR,
GUIDED_ACTION_START_APPLICATION,
@@ -58,7 +58,7 @@ export const ASSISTANT_SESSION_MODE_OPTIONS = [
]
export function canUseBudgetAssistantSession(user = null) {
return Boolean(isBudgetMonitorUser(user) || isExecutiveUser(user))
return Boolean(isPlatformAdminUser(user) || isBudgetMonitorUser(user) || isExecutiveUser(user))
}
function canUseAssistantSessionType(sessionType, user = null) {
@@ -102,6 +102,7 @@ export const SOURCE_LABELS = {
workbench: '来自个人工作台',
topbar: '来自发起报销',
application: '来自发起申请',
budget: '来自预算中心',
detail: '来自智能录入',
upload: '来自附件上传',
requests: '来自报销列表'
@@ -111,6 +112,7 @@ export const SCENARIO_LABELS = {
expense: '报销',
accounts_receivable: '应收',
accounts_payable: '应付',
budget: '预算',
knowledge: '知识',
unknown: '通用'
}
@@ -230,6 +232,24 @@ export const APPROVAL_WELCOME_QUICK_ACTIONS = [
}
]
export const BUDGET_WELCOME_QUICK_ACTIONS = [
{
label: '预算编制查询',
prompt: '帮我查询当前部门本季度预算编制情况,重点看差旅、通信、招待费和办公用品。',
icon: 'mdi mdi-calculator-variant-outline'
},
{
label: '阈值风险检查',
prompt: '帮我检查当前预算的提醒阈值、告警阈值和风险阈值设置是否合理,并指出需要关注的费用类型。',
icon: 'mdi mdi-alert-decagram-outline'
},
{
label: '预算调整建议',
prompt: '请根据已发生、已占用和剩余预算,帮我整理下一轮预算调整建议。',
icon: 'mdi mdi-chart-box-plus-outline'
}
]
export const HOT_KNOWLEDGE_QUESTIONS = [
'差旅住宿标准按什么规则执行?',
'酒店超标后如何申请例外报销?',
@@ -287,6 +307,7 @@ export function createMessage(role, text, attachments = [], extras = {}) {
riskFlags: [],
pendingAttachmentAssociation: null,
applicationPreview: null,
budgetReport: null,
...extras
}
}
@@ -557,6 +578,10 @@ export function buildWelcomeQuickActions(sessionType, user, entrySource, linkedR
return APPROVAL_WELCOME_QUICK_ACTIONS
}
if (normalizedSessionType === SESSION_TYPE_BUDGET) {
return BUDGET_WELCOME_QUICK_ACTIONS
}
return EXPENSE_WELCOME_QUICK_ACTIONS
}
@@ -601,6 +626,18 @@ export function buildWelcomeMessage(entrySource, linkedRequest, sessionType = SE
].join('\n')
}
if (normalizedSessionType === SESSION_TYPE_BUDGET) {
return [
`${greeting}!今日是 **${ctx.dateLine}**。`,
'',
'**欢迎来到个人财务中心 · 预算编制助手。** 我可以帮您查询预算编制情况、整理费用类型预算、检查提醒/告警/风险阈值,并保持预算对话独立记录。',
'',
'业务范围:预算编制查询、部门预算检查、费用类型额度梳理、预算占用说明和阈值风险分析。报销发起、审核动作和制度问答请切换到对应助手。',
'',
'您可以直接输入预算问题,或点击下方快捷操作快速开始。'
].join('\n')
}
if (entrySource === 'detail' && linkedRequest?.id) {
return [
`${greeting}!今日是 **${ctx.dateLine}**。`,
@@ -659,6 +696,17 @@ export function buildWelcomeInsight(entrySource, linkedRequest, sessionType = SE
}
}
if (normalizedSessionType === SESSION_TYPE_BUDGET) {
return {
intent: 'welcome',
metricLabel: '当前助手',
metricValue: '预算编制助手',
title: '预算编制助手',
summary: `${ctx.honorific},这里会单独保存预算相关对话,适合查询预算编制、预算占用和阈值风险。`,
agent: null
}
}
return {
intent: 'welcome',
metricLabel: '当前助手',
@@ -837,6 +885,7 @@ export function serializeSessionMessages(messages) {
riskFlags: Array.isArray(message.riskFlags) ? message.riskFlags : [],
pendingAttachmentAssociation: message.pendingAttachmentAssociation || null,
applicationPreview: message.applicationPreview || null,
budgetReport: message.budgetReport || null,
assistantName: message.assistantName || '',
isWelcome: Boolean(message.isWelcome),
welcomeQuickActions: Array.isArray(message.welcomeQuickActions) ? message.welcomeQuickActions : []
@@ -857,6 +906,7 @@ export function hasMeaningfulSessionMessages(messages) {
|| message.reviewPayload
|| message.queryPayload
|| message.draftPayload
|| message.budgetReport
)
})
}