index.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import {buildProtoReq50, parseProtoRsp50} from "@/services/socket/protobuf/buildReq";
  2. import APP from "@/services";
  3. import {Callback} from "@/utils/websocket";
  4. import {WarehouseApplyReq, WarehouseStateChangeReq} from "@/protoService/warehouse/interface";
  5. /**
  6. * 新增 / 修改 仓库信息请求 修改需要传仓库id
  7. * @param param.type (必填) 类型 1 新增 2 修改
  8. * @param param.warehousecode (必填) 仓库代码
  9. * @param param.warehousename (必填) 仓库名称
  10. * @param param.warehousetype (必填) 仓库类型
  11. */
  12. export const addWarehouseApply = (param: WarehouseApplyReq): Promise<any> => {
  13. return new Promise((resolve, reject) => {
  14. const params = {
  15. protobufName: 'WareHouseApplyReq',
  16. funCodeName: 'WareHouseApplyReq',
  17. reqParams: param,
  18. msgHeadParams: {
  19. AccountID: param.accountid,
  20. MarketID: 18,
  21. GoodsID: 0,
  22. }
  23. };
  24. const package50 = buildProtoReq50(params);
  25. APP.sendTradingServer(package50, undefined, {
  26. onSuccess: (res) => {
  27. const { isSuccess, result } = parseProtoRsp50(res, 'WareHouseApplyRsp');
  28. if (isSuccess) {
  29. resolve(result);
  30. } else {
  31. reject(result);
  32. }
  33. },
  34. onFail: (err) => reject(err.message),
  35. } as Callback);
  36. });
  37. }
  38. /**
  39. * 仓库状态修改请求
  40. * @param param.warehouseid 仓库ID
  41. * @param param.warehousestatus 仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝
  42. */
  43. export const warehouseStateChangeReq = (param: WarehouseStateChangeReq): Promise<any> => {
  44. return new Promise((resolve, reject) => {
  45. const params = {
  46. protobufName: 'WareHouseStateChangeReq',
  47. funCodeName: 'WareHouseStateChangeReq',
  48. reqParams: param,
  49. msgHeadParams: {
  50. AccountID: param.accountid,
  51. MarketID: 18,
  52. GoodsID: 0,
  53. }
  54. };
  55. const package50 = buildProtoReq50(params);
  56. APP.sendTradingServer(package50, undefined, {
  57. onSuccess: (res) => {
  58. const { isSuccess, result } = parseProtoRsp50(res, 'WareHouseStateChangeRsp');
  59. if (isSuccess) {
  60. resolve(result);
  61. } else {
  62. reject(result);
  63. }
  64. },
  65. onFail: (err) => reject(err.message),
  66. } as Callback);
  67. });
  68. }