replenisher.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { http } from "@/utils/http";
  2. type Result = {
  3. code: number;
  4. message: string;
  5. data?: any;
  6. };
  7. type ResultTable = {
  8. code: number;
  9. message: string;
  10. data?: {
  11. list: Array<any>;
  12. total: number;
  13. pageSize: number;
  14. currentPage: number;
  15. };
  16. };
  17. export const getReplenisherList = (params: {
  18. page?: number;
  19. pageSize?: number;
  20. keyword?: string;
  21. status?: number;
  22. }) => {
  23. return http.request<ResultTable>("get", "/replenishers/list", { params });
  24. };
  25. export const getReplenisherById = (id: number) => {
  26. return http.request<Result>("get", `/replenishers/${id}`);
  27. };
  28. export const searchReplenishers = (keyword?: string) => {
  29. return http.request<Result>(
  30. "get",
  31. `/replenishers/search${keyword ? `?keyword=${keyword}` : ""}`
  32. );
  33. };
  34. export const createReplenisher = (data: {
  35. name: string;
  36. phone?: string;
  37. employeeId?: string;
  38. }) => {
  39. return http.request<Result>("post", "/replenishers", { data });
  40. };
  41. export const updateReplenisher = (
  42. id: number,
  43. data: {
  44. name?: string;
  45. phone?: string;
  46. employeeId?: string;
  47. status?: number;
  48. }
  49. ) => {
  50. return http.request<Result>("put", `/replenishers/${id}`, { data });
  51. };
  52. export const updateReplenisherStatus = (id: number, data: { status: number }) => {
  53. return http.request<Result>("put", `/replenishers/${id}/status`, { data });
  54. };
  55. export const deleteReplenisher = (id: number) => {
  56. return http.request<Result>("delete", `/replenishers/${id}`);
  57. };
  58. export const getBoundDevices = (id: number) => {
  59. return http.request<Result>("get", `/replenishers/${id}/devices`);
  60. };
  61. export const bindDevices = (id: number, data: { deviceIds: string[] }) => {
  62. return http.request<Result>("post", `/replenishers/${id}/devices`, { data });
  63. };
  64. export const unbindDevice = (replenisherId: number, deviceId: string) => {
  65. return http.request<Result>(
  66. "delete",
  67. `/replenishers/${replenisherId}/devices/${deviceId}`
  68. );
  69. };
  70. export const batchBindDevices = (data: {
  71. replenisherIds: number[];
  72. deviceIds: string[];
  73. }) => {
  74. return http.request<Result>("post", "/replenishers/batch-bind", { data });
  75. };
  76. /**
  77. * 生成补货员绑定码
  78. * @param id 补货员ID
  79. * @returns bindingCode
  80. */
  81. export const generateBindingCode = (id: number) => {
  82. return http.request<Result>("post", `/replenishers/${id}/binding-code`);
  83. };