feat: 报销审批流重构与管家计划全链路贯通
- 重构报销状态注册表、审批流路由与平台风险标记 - 完善管家意图规划器与模型计划构建器全链路 - 新增 OCR Worker 脚本、数据库会话管理与通知状态 - 优化文档中心、日志视图、预算中心与员工管理交互 - 增强工作台摘要、图标资源与全局主题样式 - 补充审批路由、状态注册、OCR 服务与管家规划器测试覆盖
This commit is contained in:
@@ -1,16 +1,44 @@
|
||||
import { apiRequest } from './api.js'
|
||||
|
||||
const inflightOcrRequests = new Map()
|
||||
|
||||
function buildOcrRequestKey(files = []) {
|
||||
return files
|
||||
.map((file) => [
|
||||
String(file?.name || ''),
|
||||
String(file?.size || 0),
|
||||
String(file?.lastModified || 0),
|
||||
String(file?.receiptId || '')
|
||||
].join(':'))
|
||||
.join('|')
|
||||
}
|
||||
|
||||
export function recognizeOcrFiles(files, options = {}) {
|
||||
const requestKey = buildOcrRequestKey(files)
|
||||
if (requestKey && inflightOcrRequests.has(requestKey)) {
|
||||
return inflightOcrRequests.get(requestKey)
|
||||
}
|
||||
|
||||
const formData = new FormData()
|
||||
for (const file of files) {
|
||||
formData.append('files', file)
|
||||
formData.append('receipt_ids', String(file?.receiptId || ''))
|
||||
}
|
||||
|
||||
return apiRequest('/ocr/recognize', {
|
||||
const request = apiRequest('/ocr/recognize', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
contentType: null,
|
||||
...options
|
||||
})
|
||||
if (!requestKey) {
|
||||
return request
|
||||
}
|
||||
|
||||
inflightOcrRequests.set(requestKey, request)
|
||||
request.then(
|
||||
() => inflightOcrRequests.delete(requestKey),
|
||||
() => inflightOcrRequests.delete(requestKey)
|
||||
)
|
||||
return request
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user