Files
shanxia2.0/web-admin/src/api/bx/index.ts
T
zlwuandCursor 10c3c5470c chore: sync local PL/CRM/BX and migration work to new Gogs host
Bundle pending backend/web-admin feature updates, data-migration scripts,
and related docs so the V1.5 branch on the Tencent Cloud Gogs matches the
current workspace (excluding local secrets).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 09:19:21 +08:00

338 lines
10 KiB
TypeScript

import bxRequest from '@/utils/http/bx'
export type BxId = string | number
export type BxApplyDateFilter = {
applyDate?: string
applyDateFrom?: string
applyDateTo?: string
}
export const expenseItemApi = {
tree() {
return bxRequest.get('/expense-items/tree')
},
getById(id: BxId) {
return bxRequest.get(`/expense-items/${id}`)
},
create(data: Record<string, any>) {
return bxRequest.post('/expense-items/', data)
},
update(id: BxId, data: Record<string, any>) {
return bxRequest.put(`/expense-items/${id}`, data)
},
delete(id: BxId) {
return bxRequest.delete(`/expense-items/${id}`)
}
}
export const workflowApi = {
list(params: { page: number; pageSize: number }) {
return bxRequest.get('/workflows/', { params })
},
getByBizType(bizType: string) {
return bxRequest.get(`/workflows/biz/${bizType}`)
},
getById(id: BxId) {
return bxRequest.get(`/workflows/${id}`)
},
create(data: Record<string, any>) {
return bxRequest.post('/workflows/', data)
},
update(id: BxId, data: Record<string, any>) {
return bxRequest.put(`/workflows/${id}`, data)
},
saveNodes(id: BxId, nodes: Record<string, any>[]) {
return bxRequest.put(`/workflows/${id}/nodes`, nodes)
},
delete(id: BxId) {
return bxRequest.delete(`/workflows/${id}`)
}
}
export const advanceApi = {
list(params: {
page: number
pageSize: number
status?: string
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/advances/', { params })
},
my(params: { page: number; pageSize: number; status?: string; keyword?: string } & BxApplyDateFilter) {
return bxRequest.get('/advances/my', { params })
},
myStats() {
return bxRequest.get('/advances/my/stats')
},
statusCounts() {
return bxRequest.get('/advances/stats/status-counts')
},
pendingApproval(params: {
page: number
pageSize: number
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/advances/pending-approval', { params })
},
pendingApprovalStats() {
return bxRequest.get('/advances/pending-approval/stats')
},
approvedByMe(params: {
page: number
pageSize: number
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/advances/approved-by-me', { params })
},
getById(id: BxId) {
return bxRequest.get(`/advances/${id}`)
},
getApprovals(id: BxId) {
return bxRequest.get(`/advances/${id}/approvals`)
},
getApprovalHistory(id: BxId) {
return bxRequest.get(`/advances/${id}/approval-history`)
},
create(data: Record<string, any>) {
return bxRequest.post('/advances/', data)
},
update(id: BxId, data: Record<string, any>) {
return bxRequest.put(`/advances/${id}`, data)
},
submit(id: BxId) {
return bxRequest.post(`/advances/${id}/submit`)
},
approve(id: BxId, data: { approvalOpinion?: string }) {
return bxRequest.post(`/advances/${id}/approve`, data)
},
reject(id: BxId, data: { approvalOpinion?: string }) {
return bxRequest.post(`/advances/${id}/reject`, data)
},
delete(id: BxId) {
return bxRequest.delete(`/advances/${id}`)
}
}
export const reimburseApi = {
generateTitle(reimburseDate?: string, excludeApplyId?: BxId, applicantId?: BxId) {
const params: Record<string, string> = {}
if (reimburseDate) params.reimburseDate = reimburseDate
if (excludeApplyId) params.excludeApplyId = String(excludeApplyId)
if (applicantId) params.applicantId = String(applicantId)
return bxRequest.get('/reimburses/generate-title', { params })
},
list(params: {
page: number
pageSize: number
status?: string
keyword?: string
expenseId?: BxId
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/reimburses/', { params })
},
my(params: { page: number; pageSize: number; status?: string; keyword?: string } & BxApplyDateFilter) {
return bxRequest.get('/reimburses/my', { params })
},
myStats() {
return bxRequest.get('/reimburses/my/stats')
},
statusCounts() {
return bxRequest.get('/reimburses/stats/status-counts')
},
pendingApproval(params: {
page: number
pageSize: number
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/reimburses/pending-approval', { params })
},
pendingApprovalStats() {
return bxRequest.get('/reimburses/pending-approval/stats')
},
approvedByMe(params: {
page: number
pageSize: number
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/reimburses/approved-by-me', { params })
},
getById(id: BxId) {
return bxRequest.get(`/reimburses/${id}`)
},
getApprovals(id: BxId) {
return bxRequest.get(`/reimburses/${id}/approvals`)
},
getApprovalHistory(id: BxId) {
return bxRequest.get(`/reimburses/${id}/approval-history`)
},
/** body 可含 invoiceIds / invoiceLinks(勾选发票附件)关联发票夹(草稿保存时同步关联) */
create(data: Record<string, any>) {
return bxRequest.post('/reimburses/', data)
},
/** body 可含 invoiceIds / invoiceLinks(勾选发票附件)关联发票夹(草稿保存时同步关联) */
update(id: BxId, data: Record<string, any>) {
return bxRequest.put(`/reimburses/${id}`, data)
},
/** body 可含 invoiceIds / invoiceLinks;提交时同步关联并扣减发票余额 */
submit(id: BxId, data?: Record<string, any>) {
return bxRequest.post(`/reimburses/${id}/submit`, data)
},
withdraw(id: BxId) {
return bxRequest.post(`/reimburses/${id}/withdraw`)
},
approve(id: BxId, data: { approvalOpinion?: string }) {
return bxRequest.post(`/reimburses/${id}/approve`, data)
},
reject(id: BxId, data: { approvalOpinion?: string }) {
return bxRequest.post(`/reimburses/${id}/reject`, data)
},
delete(id: BxId) {
return bxRequest.delete(`/reimburses/${id}`)
}
}
export const paymentApi = {
financeStats() {
return bxRequest.get('/payments/stats')
},
advanceIssueStats() {
return bxRequest.get('/payments/advance-issues/stats')
},
pending(params: {
page: number
pageSize: number
bizType?: string
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/payments/pending', { params })
},
pay(id: BxId, data?: { payRemark?: string; actualAmount?: number }) {
return bxRequest.post(`/payments/${id}/pay`, data)
},
offset(id: BxId, data: { advanceId: BxId; offsetAmount: number; remark?: string }) {
return bxRequest.post(`/payments/${id}/offset`, data)
},
batchOffset(
id: BxId,
data: { items: Array<{ advanceId: BxId; offsetAmount: number }>; payAmount: number; remark?: string }
) {
return bxRequest.post(`/payments/${id}/batch-offset`, data)
},
advanceIssues(params: {
page: number
pageSize: number
issueStatus?: string
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/payments/advance-issues', {
params: {
page: params.page,
pageSize: params.pageSize,
issue_status: params.issueStatus,
keyword: params.keyword,
applicantId: params.applicantId,
applyDate: params.applyDate,
applyDateFrom: params.applyDateFrom,
applyDateTo: params.applyDateTo
}
})
},
exportAdvanceIssues(params: {
issueStatus?: string
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/payments/advance-issues/export', {
params: {
issue_status: params.issueStatus,
keyword: params.keyword,
applicantId: params.applicantId,
applyDate: params.applyDate,
applyDateFrom: params.applyDateFrom,
applyDateTo: params.applyDateTo
},
responseType: 'blob'
})
},
issueAdvance(advanceId: BxId, data: { issueRemark?: string; actualAmount?: number }) {
return bxRequest.post(`/payments/advance/${advanceId}/issue`, data)
},
advanceOffsetRecords(advanceId: BxId) {
return bxRequest.get(`/payments/advance/${advanceId}/offset-records`)
},
reimburseOffsetRecords(reimburseId: BxId) {
return bxRequest.get(`/payments/${reimburseId}/offset-records`)
},
processed(params: {
page: number
pageSize: number
bizType?: string
keyword?: string
applicantId?: BxId
} & BxApplyDateFilter) {
return bxRequest.get('/payments/processed', { params })
}
}
export const invoiceWalletApi = {
mineSummary(params?: { userId?: BxId }) {
return bxRequest.get('/invoice-wallets/mine/summary', { params })
},
list(params: { page: number; pageSize: number; keyword?: string }) {
return bxRequest.get('/invoice-wallets', { params })
}
}
export const invoiceApi = {
list(params: { page?: number; pageSize?: number; userId?: BxId }) {
return bxRequest.get('/invoices', { params })
},
/** FormData 字段:files(可多个), amount, remark?, targetUserId?(管理员代传) */
upload(formData: FormData) {
return bxRequest.post('/invoices', formData)
},
delete(id: BxId) {
return bxRequest.delete(`/invoices/${id}`)
},
ledgers(params?: { userId?: BxId }) {
return bxRequest.get('/invoice-ledgers', { params })
}
}
export const attachmentApi = {
upload(file: File, bizType: string = '', bizId: BxId = 0) {
const formData = new FormData()
formData.append('file', file)
return bxRequest.post('/attachments/upload', formData, {
headers: { 'Content-Type': 'multipart/form-data' },
params: { biz_type: bizType, biz_id: bizId }
})
},
download(id: BxId) {
return bxRequest.get(`/attachments/download/${id}`, { responseType: 'blob' })
},
preview(id: BxId) {
return bxRequest.get(`/attachments/preview/${id}`)
},
delete(id: BxId) {
return bxRequest.delete(`/attachments/${id}`)
},
listByBiz(bizType: string, bizId: BxId) {
return bxRequest.get('/attachments/list', { params: { biz_type: bizType, biz_id: bizId } })
},
bindBiz(ids: BxId[], bizType: string, bizId: BxId) {
return bxRequest.put('/attachments/bind-biz', null, {
params: { ids: ids.join(','), biz_type: bizType, biz_id: bizId }
})
}
}