bx.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { bxRequest, bxUploadFile, bxUploadInvoice } from '@/utils/bxRequest'
  2. export const advanceApi = {
  3. list: (params) => bxRequest({ url: '/advances/', method: 'GET', params }),
  4. my: (params) => bxRequest({ url: '/advances/my', method: 'GET', params }),
  5. getById: (id) => bxRequest({ url: `/advances/${id}`, method: 'GET' }),
  6. getApprovals: (id) => bxRequest({ url: `/advances/${id}/approvals`, method: 'GET' }),
  7. getApprovalHistory: (id) => bxRequest({ url: `/advances/${id}/approval-history`, method: 'GET' }),
  8. create: (data) => bxRequest({ url: '/advances/', method: 'POST', data }),
  9. update: (id, data) => bxRequest({ url: `/advances/${id}`, method: 'PUT', data }),
  10. submit: (id) => bxRequest({ url: `/advances/${id}/submit`, method: 'POST' }),
  11. delete: (id) => bxRequest({ url: `/advances/${id}`, method: 'DELETE' })
  12. }
  13. export const reimburseApi = {
  14. generateTitle: (params) =>
  15. bxRequest({ url: '/reimburses/generate-title', method: 'GET', params }),
  16. list: (params) => bxRequest({ url: '/reimburses/', method: 'GET', params }),
  17. my: (params) => bxRequest({ url: '/reimburses/my', method: 'GET', params }),
  18. getById: (id) => bxRequest({ url: `/reimburses/${id}`, method: 'GET' }),
  19. getApprovals: (id) => bxRequest({ url: `/reimburses/${id}/approvals`, method: 'GET' }),
  20. getApprovalHistory: (id) =>
  21. bxRequest({ url: `/reimburses/${id}/approval-history`, method: 'GET' }),
  22. create: (data) => bxRequest({ url: '/reimburses/', method: 'POST', data }),
  23. update: (id, data) => bxRequest({ url: `/reimburses/${id}`, method: 'PUT', data }),
  24. submit: (id, data) =>
  25. bxRequest({ url: `/reimburses/${id}/submit`, method: 'POST', data }),
  26. delete: (id) => bxRequest({ url: `/reimburses/${id}`, method: 'DELETE' })
  27. }
  28. export const expenseItemApi = {
  29. tree: () => bxRequest({ url: '/expense-items/tree', method: 'GET' })
  30. }
  31. export const invoiceWalletApi = {
  32. mineSummary: (params) =>
  33. bxRequest({ url: '/invoice-wallets/mine/summary', method: 'GET', params }),
  34. list: (params) => bxRequest({ url: '/invoice-wallets', method: 'GET', params })
  35. }
  36. export const invoiceApi = {
  37. list: (params) => bxRequest({ url: '/invoices', method: 'GET', params }),
  38. /**
  39. * 上传发票(multipart)。uni-app 用 uni.uploadFile,单次一张图。
  40. * @param {{ amount: number|string, remark?: string, filePath: string, targetUserId?: string|number }} opts
  41. */
  42. upload: (opts) => bxUploadInvoice(opts),
  43. delete: (id) => bxRequest({ url: `/invoices/${id}`, method: 'DELETE' }),
  44. ledgers: (params) => bxRequest({ url: '/invoice-ledgers', method: 'GET', params })
  45. }
  46. /** 附件:申请页图片上传所需最小集合 */
  47. export const attachmentApi = {
  48. upload: (filePath, bizType = '', bizId = 0) =>
  49. bxUploadFile(filePath, { bizType, bizId }),
  50. listByBiz: (bizType, bizId) =>
  51. bxRequest({
  52. url: '/attachments/list',
  53. method: 'GET',
  54. params: { biz_type: bizType, biz_id: bizId }
  55. }),
  56. preview: (id) => bxRequest({ url: `/attachments/preview/${id}`, method: 'GET' }),
  57. delete: (id) => bxRequest({ url: `/attachments/${id}`, method: 'DELETE' }),
  58. bindBiz: (ids, bizType, bizId) =>
  59. bxRequest({
  60. url: '/attachments/bind-biz',
  61. method: 'PUT',
  62. params: {
  63. ids: (ids || []).join(','),
  64. biz_type: bizType,
  65. biz_id: bizId
  66. }
  67. })
  68. }
  69. export default {
  70. advanceApi,
  71. reimburseApi,
  72. expenseItemApi,
  73. invoiceWalletApi,
  74. invoiceApi,
  75. attachmentApi
  76. }