product.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 getProductList = (params: {
  18. page?: number;
  19. pageSize?: number;
  20. name?: string;
  21. barcode?: string;
  22. category?: string;
  23. syncStatus?: number;
  24. }) => {
  25. return http.request<ResultTable>("get", "/products/list", { params });
  26. };
  27. export const getProductById = (id: number) => {
  28. return http.request<Result>("get", `/products/${id}`);
  29. };
  30. export const getProductStatistics = () => {
  31. return http.request<Result>("get", "/products/statistics");
  32. };
  33. export const addProduct = (data: any) => {
  34. return http.request<Result>("post", "/products", { data });
  35. };
  36. export const updateProduct = (id: number, data: any) => {
  37. return http.request<Result>("put", `/products/${id}`, { data });
  38. };
  39. export const deleteProduct = (id: number) => {
  40. return http.request<Result>("delete", `/products/${id}`);
  41. };
  42. export const syncProduct = (id: number) => {
  43. return http.request<Result>("post", `/products/${id}/sync`);
  44. };
  45. // 商品总库
  46. export const getMasterProductList = (params: {
  47. page?: number;
  48. pageSize?: number;
  49. barcode?: string;
  50. code?: string;
  51. productName?: string;
  52. deviceAdapt?: string;
  53. }) => {
  54. return http.request<ResultTable>("get", "/products/master/list", { params });
  55. };
  56. export const addToMerchantProducts = (data: { codeList: string }) => {
  57. return http.request<Result>("post", "/products/master/add-to-merchant", { data });
  58. };
  59. // 商品上下架控制
  60. export const setProductShelfStatus = (data: {
  61. deviceId: string;
  62. goodsCode: string;
  63. salesType: string;
  64. callType?: string;
  65. }) => {
  66. return http.request<Result>("post", "/products/shelf-status", { data });
  67. };
  68. // 获取指定设备可售卖商品列表
  69. export const getDeviceProducts = (deviceId: string) => {
  70. return http.request<Result>("get", `/products/device/${deviceId}`);
  71. };
  72. // 查询商品ID对应关系
  73. export const getIdMapping = (codeList?: string) => {
  74. const params = codeList ? { codeList } : {};
  75. return http.request<Result>("get", "/products/id-mapping", { params });
  76. };