|
|
@@ -1,122 +1,85 @@
|
|
|
-import client from './client'
|
|
|
+import bxClient from './bxClient'
|
|
|
|
|
|
-export const authApi = {
|
|
|
- login: (data: { username: string; password: string }) =>
|
|
|
- client.post('/auth/login', data),
|
|
|
- register: (data: { username: string; password: string; realName: string }) =>
|
|
|
- client.post('/auth/register', data),
|
|
|
- me: () => client.get('/auth/me'),
|
|
|
-}
|
|
|
-
|
|
|
-export const userApi = {
|
|
|
- list: (params?: Record<string, any>) => client.get('/users/', { params }),
|
|
|
- dropdown: () => client.get('/users/dropdown'),
|
|
|
- getById: (id: number) => client.get(`/users/${id}`),
|
|
|
- create: (data: Record<string, any>) => client.post('/users/', data),
|
|
|
- update: (id: number, data: Record<string, any>) => client.put(`/users/${id}`, data),
|
|
|
- delete: (id: number) => client.delete(`/users/${id}`),
|
|
|
- resetPassword: (id: number) => client.put(`/users/${id}/reset-password`),
|
|
|
-}
|
|
|
-
|
|
|
-export const roleApi = {
|
|
|
- list: (params?: Record<string, any>) => client.get('/roles/', { params }),
|
|
|
- getById: (id: number) => client.get(`/roles/${id}`),
|
|
|
- create: (data: Record<string, any>) => client.post('/roles/', data),
|
|
|
- update: (id: number, data: Record<string, any>) => client.put(`/roles/${id}`, data),
|
|
|
- delete: (id: number) => client.delete(`/roles/${id}`),
|
|
|
- getUsers: (roleId: number) => client.get(`/roles/${roleId}/users`),
|
|
|
- assignUsers: (id: number, userIds: number[]) =>
|
|
|
- client.put(`/roles/${id}/users`, { userIds }),
|
|
|
- assignMenus: (id: number, menuIds: number[]) =>
|
|
|
- client.put(`/roles/${id}/menus`, { menuIds }),
|
|
|
-}
|
|
|
-
|
|
|
-export const menuApi = {
|
|
|
- mine: () => client.get('/menus/mine'),
|
|
|
- tree: () => client.get('/menus/tree'),
|
|
|
- getByRole: (roleId: number) => client.get(`/menus/role/${roleId}`),
|
|
|
- getById: (id: number) => client.get(`/menus/${id}`),
|
|
|
- create: (data: Record<string, any>) => client.post('/menus/', data),
|
|
|
- update: (id: number, data: Record<string, any>) => client.put(`/menus/${id}`, data),
|
|
|
- delete: (id: number) => client.delete(`/menus/${id}`),
|
|
|
-}
|
|
|
+export type BxId = string | number
|
|
|
|
|
|
export const expenseItemApi = {
|
|
|
- tree: () => client.get('/expense-items/tree'),
|
|
|
- getById: (id: number) => client.get(`/expense-items/${id}`),
|
|
|
- create: (data: Record<string, any>) => client.post('/expense-items/', data),
|
|
|
- update: (id: number, data: Record<string, any>) => client.put(`/expense-items/${id}`, data),
|
|
|
- delete: (id: number) => client.delete(`/expense-items/${id}`),
|
|
|
+ tree: () => bxClient.get('/expense-items/tree'),
|
|
|
+ getById: (id: BxId) => bxClient.get(`/expense-items/${id}`),
|
|
|
+ create: (data: Record<string, any>) => bxClient.post('/expense-items/', data),
|
|
|
+ update: (id: BxId, data: Record<string, any>) => bxClient.put(`/expense-items/${id}`, data),
|
|
|
+ delete: (id: BxId) => bxClient.delete(`/expense-items/${id}`),
|
|
|
}
|
|
|
|
|
|
export const workflowApi = {
|
|
|
- list: (params?: Record<string, any>) => client.get('/workflows/', { params }),
|
|
|
- getByBizType: (bizType: string) => client.get(`/workflows/biz/${bizType}`),
|
|
|
- getById: (id: number) => client.get(`/workflows/${id}`),
|
|
|
- create: (data: Record<string, any>) => client.post('/workflows/', data),
|
|
|
- update: (id: number, data: Record<string, any>) => client.put(`/workflows/${id}`, data),
|
|
|
- saveNodes: (id: number, nodes: Record<string, any>[]) =>
|
|
|
- client.put(`/workflows/${id}/nodes`, nodes),
|
|
|
- delete: (id: number) => client.delete(`/workflows/${id}`),
|
|
|
+ list: (params?: Record<string, any>) => bxClient.get('/workflows/', { params }),
|
|
|
+ getByBizType: (bizType: string) => bxClient.get(`/workflows/biz/${bizType}`),
|
|
|
+ getById: (id: BxId) => bxClient.get(`/workflows/${id}`),
|
|
|
+ create: (data: Record<string, any>) => bxClient.post('/workflows/', data),
|
|
|
+ update: (id: BxId, data: Record<string, any>) => bxClient.put(`/workflows/${id}`, data),
|
|
|
+ saveNodes: (id: BxId, nodes: Record<string, any>[]) =>
|
|
|
+ bxClient.put(`/workflows/${id}/nodes`, nodes),
|
|
|
+ delete: (id: BxId) => bxClient.delete(`/workflows/${id}`),
|
|
|
}
|
|
|
|
|
|
export const advanceApi = {
|
|
|
- list: (params?: Record<string, any>) => client.get('/advances/', { params }),
|
|
|
- my: (params?: Record<string, any>) => client.get('/advances/my', { params }),
|
|
|
- myStats: () => client.get('/advances/my/stats'),
|
|
|
+ list: (params?: Record<string, any>) => bxClient.get('/advances/', { params }),
|
|
|
+ my: (params?: Record<string, any>) => bxClient.get('/advances/my', { params }),
|
|
|
+ myStats: () => bxClient.get('/advances/my/stats'),
|
|
|
pendingApproval: (params?: Record<string, any>) =>
|
|
|
- client.get('/advances/pending-approval', { params }),
|
|
|
+ bxClient.get('/advances/pending-approval', { params }),
|
|
|
approvedByMe: (params?: Record<string, any>) =>
|
|
|
- client.get('/advances/approved-by-me', { params }),
|
|
|
- getById: (id: number) => client.get(`/advances/${id}`),
|
|
|
- getApprovals: (id: number) => client.get(`/advances/${id}/approvals`),
|
|
|
- create: (data: Record<string, any>) => client.post('/advances/', data),
|
|
|
- update: (id: number, data: Record<string, any>) => client.put(`/advances/${id}`, data),
|
|
|
- submit: (id: number) => client.post(`/advances/${id}/submit`),
|
|
|
- approve: (id: number, data: { approvalOpinion?: string }) =>
|
|
|
- client.post(`/advances/${id}/approve`, data),
|
|
|
- reject: (id: number, data: { approvalOpinion?: string }) =>
|
|
|
- client.post(`/advances/${id}/reject`, data),
|
|
|
- delete: (id: number) => client.delete(`/advances/${id}`),
|
|
|
+ bxClient.get('/advances/approved-by-me', { params }),
|
|
|
+ getById: (id: BxId) => bxClient.get(`/advances/${id}`),
|
|
|
+ getApprovals: (id: BxId) => bxClient.get(`/advances/${id}/approvals`),
|
|
|
+ create: (data: Record<string, any>) => bxClient.post('/advances/', data),
|
|
|
+ update: (id: BxId, data: Record<string, any>) => bxClient.put(`/advances/${id}`, data),
|
|
|
+ submit: (id: BxId) => bxClient.post(`/advances/${id}/submit`),
|
|
|
+ approve: (id: BxId, data: { approvalOpinion?: string }) =>
|
|
|
+ bxClient.post(`/advances/${id}/approve`, data),
|
|
|
+ reject: (id: BxId, data: { approvalOpinion?: string }) =>
|
|
|
+ bxClient.post(`/advances/${id}/reject`, data),
|
|
|
+ delete: (id: BxId) => bxClient.delete(`/advances/${id}`),
|
|
|
}
|
|
|
|
|
|
export const reimburseApi = {
|
|
|
- generateTitle: () => client.get('/reimburses/generate-title'),
|
|
|
- list: (params?: Record<string, any>) => client.get('/reimburses/', { params }),
|
|
|
- my: (params?: Record<string, any>) => client.get('/reimburses/my', { params }),
|
|
|
- myStats: () => client.get('/reimburses/my/stats'),
|
|
|
+ generateTitle: () => bxClient.get('/reimburses/generate-title'),
|
|
|
+ list: (params?: Record<string, any>) => bxClient.get('/reimburses/', { params }),
|
|
|
+ my: (params?: Record<string, any>) => bxClient.get('/reimburses/my', { params }),
|
|
|
+ myStats: () => bxClient.get('/reimburses/my/stats'),
|
|
|
pendingApproval: (params?: Record<string, any>) =>
|
|
|
- client.get('/reimburses/pending-approval', { params }),
|
|
|
+ bxClient.get('/reimburses/pending-approval', { params }),
|
|
|
approvedByMe: (params?: Record<string, any>) =>
|
|
|
- client.get('/reimburses/approved-by-me', { params }),
|
|
|
- getById: (id: number) => client.get(`/reimburses/${id}`),
|
|
|
- getApprovals: (id: number) => client.get(`/reimburses/${id}/approvals`),
|
|
|
- create: (data: Record<string, any>) => client.post('/reimburses/', data),
|
|
|
- update: (id: number, data: Record<string, any>) => client.put(`/reimburses/${id}`, data),
|
|
|
- submit: (id: number) => client.post(`/reimburses/${id}/submit`),
|
|
|
- approve: (id: number, data: { approvalOpinion?: string }) =>
|
|
|
- client.post(`/reimburses/${id}/approve`, data),
|
|
|
- reject: (id: number, data: { approvalOpinion?: string }) =>
|
|
|
- client.post(`/reimburses/${id}/reject`, data),
|
|
|
- delete: (id: number) => client.delete(`/reimburses/${id}`),
|
|
|
+ bxClient.get('/reimburses/approved-by-me', { params }),
|
|
|
+ getById: (id: BxId) => bxClient.get(`/reimburses/${id}`),
|
|
|
+ getApprovals: (id: BxId) => bxClient.get(`/reimburses/${id}/approvals`),
|
|
|
+ create: (data: Record<string, any>) => bxClient.post('/reimburses/', data),
|
|
|
+ update: (id: BxId, data: Record<string, any>) => bxClient.put(`/reimburses/${id}`, data),
|
|
|
+ submit: (id: BxId) => bxClient.post(`/reimburses/${id}/submit`),
|
|
|
+ approve: (id: BxId, data: { approvalOpinion?: string }) =>
|
|
|
+ bxClient.post(`/reimburses/${id}/approve`, data),
|
|
|
+ reject: (id: BxId, data: { approvalOpinion?: string }) =>
|
|
|
+ bxClient.post(`/reimburses/${id}/reject`, data),
|
|
|
+ delete: (id: BxId) => bxClient.delete(`/reimburses/${id}`),
|
|
|
}
|
|
|
|
|
|
export const paymentApi = {
|
|
|
- pending: (params?: Record<string, any>) => client.get('/payments/pending', { params }),
|
|
|
- pay: (id: number, data?: { payRemark?: string; actualAmount?: number }) =>
|
|
|
- client.post(`/payments/${id}/pay`, data),
|
|
|
- offset: (id: number, data: { advanceId: number; offsetAmount: number; remark?: string }) =>
|
|
|
- client.post(`/payments/${id}/offset`, data),
|
|
|
+ pending: (params?: Record<string, any>) => bxClient.get('/payments/pending', { params }),
|
|
|
+ pay: (id: BxId, data?: { payRemark?: string; actualAmount?: number }) =>
|
|
|
+ bxClient.post(`/payments/${id}/pay`, data),
|
|
|
+ offset: (
|
|
|
+ id: BxId,
|
|
|
+ data: { advanceId: BxId; offsetAmount: number; remark?: string },
|
|
|
+ ) => bxClient.post(`/payments/${id}/offset`, data),
|
|
|
batchOffset: (
|
|
|
- id: number,
|
|
|
+ id: BxId,
|
|
|
data: {
|
|
|
- items: Array<{ advanceId: number; offsetAmount: number }>
|
|
|
+ items: Array<{ advanceId: BxId; offsetAmount: number }>
|
|
|
payAmount: number
|
|
|
remark?: string
|
|
|
},
|
|
|
- ) => client.post(`/payments/${id}/batch-offset`, data),
|
|
|
+ ) => bxClient.post(`/payments/${id}/batch-offset`, data),
|
|
|
advanceIssues: (params?: Record<string, any>) =>
|
|
|
- client.get('/payments/advance-issues', {
|
|
|
+ bxClient.get('/payments/advance-issues', {
|
|
|
params: params
|
|
|
? {
|
|
|
page: params.page,
|
|
|
@@ -127,41 +90,38 @@ export const paymentApi = {
|
|
|
: undefined,
|
|
|
}),
|
|
|
exportAdvanceIssues: (params?: Record<string, any>) =>
|
|
|
- client.get('/payments/advance-issues/export', {
|
|
|
+ bxClient.get('/payments/advance-issues/export', {
|
|
|
params: params
|
|
|
? { issue_status: params.issueStatus, keyword: params.keyword }
|
|
|
: undefined,
|
|
|
responseType: 'blob',
|
|
|
}),
|
|
|
- issueAdvance: (
|
|
|
- advanceId: number,
|
|
|
- data: { issueRemark?: string; actualAmount?: number },
|
|
|
- ) => client.post(`/payments/advance/${advanceId}/issue`, data),
|
|
|
- processed: (params?: Record<string, any>) =>
|
|
|
- client.get('/payments/processed', { params }),
|
|
|
- advanceOffsetRecords: (advanceId: number) =>
|
|
|
- client.get(`/payments/advance/${advanceId}/offset-records`),
|
|
|
- reimburseOffsetRecords: (reimburseId: number) =>
|
|
|
- client.get(`/payments/${reimburseId}/offset-records`),
|
|
|
+ issueAdvance: (advanceId: BxId, data: { issueRemark?: string; actualAmount?: number }) =>
|
|
|
+ bxClient.post(`/payments/advance/${advanceId}/issue`, data),
|
|
|
+ processed: (params?: Record<string, any>) => bxClient.get('/payments/processed', { params }),
|
|
|
+ advanceOffsetRecords: (advanceId: BxId) =>
|
|
|
+ bxClient.get(`/payments/advance/${advanceId}/offset-records`),
|
|
|
+ reimburseOffsetRecords: (reimburseId: BxId) =>
|
|
|
+ bxClient.get(`/payments/${reimburseId}/offset-records`),
|
|
|
}
|
|
|
|
|
|
export const attachmentApi = {
|
|
|
- upload: (file: File, bizType: string = '', bizId: number = 0) => {
|
|
|
+ upload: (file: File, bizType: string = '', bizId: BxId = 0) => {
|
|
|
const form = new FormData()
|
|
|
form.append('file', file)
|
|
|
- return client.post('/attachments/upload', form, {
|
|
|
- headers: { 'Content-Type': 'multipart/form-data' },
|
|
|
+ return bxClient.post('/attachments/upload', form, {
|
|
|
params: { biz_type: bizType, biz_id: bizId },
|
|
|
})
|
|
|
},
|
|
|
- download: (id: number) => client.get(`/attachments/download/${id}`, { responseType: 'blob' }),
|
|
|
- preview: (id: number) => client.get(`/attachments/preview/${id}`),
|
|
|
- delete: (id: number) => client.delete(`/attachments/${id}`),
|
|
|
- listByBiz: (bizType: string, bizId: number) =>
|
|
|
- client.get('/attachments/list', { params: { biz_type: bizType, biz_id: bizId } }),
|
|
|
- bindBiz: (ids: number[], bizType: string, bizId: number) =>
|
|
|
- client.put('/attachments/bind-biz', null, {
|
|
|
+ download: (id: BxId) =>
|
|
|
+ bxClient.get(`/attachments/download/${id}`, { responseType: 'blob' }),
|
|
|
+ preview: (id: BxId) => bxClient.get(`/attachments/preview/${id}`),
|
|
|
+ delete: (id: BxId) => bxClient.delete(`/attachments/${id}`),
|
|
|
+ listByBiz: (bizType: string, bizId: BxId) =>
|
|
|
+ bxClient.get('/attachments/list', { params: { biz_type: bizType, biz_id: bizId } }),
|
|
|
+ bindBiz: (ids: BxId[], bizType: string, bizId: BxId) =>
|
|
|
+ bxClient.put('/attachments/bind-biz', null, {
|
|
|
params: { ids: ids.join(','), biz_type: bizType, biz_id: bizId },
|
|
|
}),
|
|
|
- downloadUrl: (id: number) => `/api/attachments/download/${id}`,
|
|
|
+ downloadUrl: (id: BxId) => `/api/attachments/download/${id}`,
|
|
|
}
|