feat(web): 新增前端编排器和报销单服务模块,封装对应的API调用方法

This commit is contained in:
caoxiaozhu
2026-05-14 15:42:47 +00:00
parent 910c959829
commit 056d6dbe22
2 changed files with 29 additions and 1 deletions

View File

@@ -7,13 +7,16 @@ export function runOrchestrator(payload) {
})
}
export function fetchLatestConversation(userId, sessionType = '') {
export function fetchLatestConversation(userId, sessionType = '', options = {}) {
const params = new URLSearchParams({
user_id: String(userId || '').trim()
})
if (String(sessionType || '').trim()) {
params.set('session_type', String(sessionType || '').trim())
}
if (options.preferRecoverable) {
params.set('prefer_recoverable', 'true')
}
return apiRequest(`/orchestrator/conversations/latest?${params.toString()}`)
}

View File

@@ -36,12 +36,37 @@ export function fetchExpenseClaimItemAttachmentMeta(claimId, itemId) {
return apiRequest(`/reimbursements/claims/${encodeURIComponent(String(claimId || '').trim())}/items/${encodeURIComponent(String(itemId || '').trim())}/attachment/meta`)
}
export function fetchExpenseClaimItemAttachmentPreview(claimId, itemId) {
return apiRequest(`/reimbursements/claims/${encodeURIComponent(String(claimId || '').trim())}/items/${encodeURIComponent(String(itemId || '').trim())}/attachment/preview`, {
responseType: 'blob'
})
}
export function fetchExpenseClaimItemAttachment(claimId, itemId) {
return apiRequest(`/reimbursements/claims/${encodeURIComponent(String(claimId || '').trim())}/items/${encodeURIComponent(String(itemId || '').trim())}/attachment`, {
responseType: 'blob'
})
}
export async function fetchExpenseClaimAttachmentAsset(pathOrUrl) {
const target = String(pathOrUrl || '').trim()
if (!target) {
throw new Error('预览地址为空。')
}
if (/^https?:\/\//i.test(target)) {
const response = await fetch(target)
if (!response.ok) {
throw new Error(`预览加载失败(${response.status})。`)
}
return response.blob()
}
return apiRequest(target, {
responseType: 'blob'
})
}
export function deleteExpenseClaimItemAttachment(claimId, itemId) {
return apiRequest(`/reimbursements/claims/${encodeURIComponent(String(claimId || '').trim())}/items/${encodeURIComponent(String(itemId || '').trim())}/attachment`, {
method: 'DELETE'