303 lines
8.3 KiB
TypeScript
303 lines
8.3 KiB
TypeScript
import bxRequest from '@/utils/http/bx'
|
|
|
|
export type BxId = string | number
|
|
|
|
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
|
|
applyDate?: string
|
|
}) {
|
|
return bxRequest.get('/advances/', { params })
|
|
},
|
|
my(params: { page: number; pageSize: number; status?: string; keyword?: string; applyDate?: string }) {
|
|
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
|
|
applyDate?: string
|
|
}) {
|
|
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
|
|
applyDate?: string
|
|
}) {
|
|
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() {
|
|
return bxRequest.get('/reimburses/generate-title')
|
|
},
|
|
list(params: {
|
|
page: number
|
|
pageSize: number
|
|
status?: string
|
|
keyword?: string
|
|
expenseId?: BxId
|
|
applicantId?: BxId
|
|
applyDate?: string
|
|
}) {
|
|
return bxRequest.get('/reimburses/', { params })
|
|
},
|
|
my(params: { page: number; pageSize: number; status?: string; keyword?: string; applyDate?: string }) {
|
|
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
|
|
applyDate?: string
|
|
}) {
|
|
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
|
|
applyDate?: string
|
|
}) {
|
|
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`)
|
|
},
|
|
create(data: Record<string, any>) {
|
|
return bxRequest.post('/reimburses/', data)
|
|
},
|
|
update(id: BxId, data: Record<string, any>) {
|
|
return bxRequest.put(`/reimburses/${id}`, data)
|
|
},
|
|
submit(id: BxId) {
|
|
return bxRequest.post(`/reimburses/${id}/submit`)
|
|
},
|
|
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
|
|
applyDate?: string
|
|
}) {
|
|
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
|
|
applyDate?: string
|
|
}) {
|
|
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
|
|
}
|
|
})
|
|
},
|
|
exportAdvanceIssues(params: {
|
|
issueStatus?: string
|
|
keyword?: string
|
|
applicantId?: BxId
|
|
applyDate?: string
|
|
}) {
|
|
return bxRequest.get('/payments/advance-issues/export', {
|
|
params: {
|
|
issue_status: params.issueStatus,
|
|
keyword: params.keyword,
|
|
applicantId: params.applicantId,
|
|
applyDate: params.applyDate
|
|
},
|
|
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
|
|
applyDate?: string
|
|
}) {
|
|
return bxRequest.get('/payments/processed', { 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 }
|
|
})
|
|
}
|
|
}
|