replenisher.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * 补货员管理 API(运营平台端)
  3. */
  4. import { get, post, put, del } from '@/utils/request';
  5. export interface ReplenisherQuery {
  6. page: number;
  7. pageSize: number;
  8. keyword?: string;
  9. status?: number;
  10. }
  11. export interface ReplenisherForm {
  12. id?: string;
  13. name: string;
  14. phone?: string;
  15. employeeId?: string;
  16. status?: number;
  17. wechatOpenid?: string;
  18. }
  19. export interface ReplenisherListResponse {
  20. list: any[];
  21. total: number;
  22. }
  23. /**
  24. * 分页查询补货员列表
  25. */
  26. export function getReplenisherList(params: ReplenisherQuery): Promise<ReplenisherListResponse> {
  27. return get('/replenishers/list', params);
  28. }
  29. /**
  30. * 获取补货员详情
  31. */
  32. export function getReplenisherById(id: string): Promise<any> {
  33. return get(`/replenishers/${id}`);
  34. }
  35. /**
  36. * 新增补货员
  37. */
  38. export function createReplenisher(data: ReplenisherForm): Promise<void> {
  39. return post('/replenishers', data);
  40. }
  41. /**
  42. * 更新补货员
  43. */
  44. export function updateReplenisher(id: string, data: Partial<ReplenisherForm>): Promise<void> {
  45. return put(`/replenishers/${id}`, data);
  46. }
  47. /**
  48. * 切换补货员状态
  49. */
  50. export function updateReplenisherStatus(id: string, status: number): Promise<void> {
  51. return put(`/replenishers/${id}/status`, { status });
  52. }
  53. /**
  54. * 删除补货员
  55. */
  56. export function deleteReplenisher(id: string): Promise<void> {
  57. return del(`/replenishers/${id}`);
  58. }
  59. /**
  60. * 获取补货员已绑定的设备列表
  61. */
  62. export function getBoundDevices(id: string): Promise<string[]> {
  63. return get(`/replenishers/${id}/devices`);
  64. }
  65. /**
  66. * 绑定设备
  67. */
  68. export function bindDevices(id: string, deviceIds: string[]): Promise<void> {
  69. return post(`/replenishers/${id}/devices`, { deviceIds });
  70. }
  71. /**
  72. * 解绑设备
  73. */
  74. export function unbindDevice(replenisherId: string, deviceId: string): Promise<void> {
  75. return del(`/replenishers/${replenisherId}/devices/${deviceId}`);
  76. }
  77. /**
  78. * 生成微信绑定码
  79. */
  80. export function generateBindingCode(id: string): Promise<{ bindingCode: string }> {
  81. return post(`/replenishers/${id}/binding-code`);
  82. }