后端新增通用分页模块,为报销单、员工、预算、agent 资产等 端点统一接入分页参数和游标查询,优化 repository 层分页实 现,前端服务层适配分页响应结构,完善预算图表和全局样式, 优化侧边栏和企业选择器组件,引入 Element Plus 插件注册。
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
import { apiRequest } from './api.js'
|
|
|
|
function buildQuery(params = {}) {
|
|
const search = new URLSearchParams()
|
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
if (typeof value === 'undefined' || value === null || value === '') return
|
|
search.set(key === 'pageSize' ? 'page_size' : key, String(value))
|
|
})
|
|
const query = search.toString()
|
|
return query ? `?${query}` : ''
|
|
}
|
|
|
|
export function fetchBudgetSummary(params = {}) {
|
|
return apiRequest(`/budgets/summary${buildQuery(params)}`)
|
|
}
|
|
|
|
export function fetchBudgetAllocations(params = {}) {
|
|
return apiRequest(`/budgets/allocations${buildQuery(params)}`)
|
|
}
|
|
|
|
export function createBudgetAllocation(payload = {}) {
|
|
return apiRequest('/budgets/allocations', {
|
|
method: 'POST',
|
|
body: JSON.stringify(payload)
|
|
})
|
|
}
|
|
|
|
export function fetchBudgetTransactions(allocationId, params = {}) {
|
|
const encodedId = encodeURIComponent(String(allocationId || '').trim())
|
|
return apiRequest(`/budgets/allocations/${encodedId}/transactions${buildQuery(params)}`)
|
|
}
|