index.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import APP from "@/services";
  2. import { Callback } from "@/utils/websocket";
  3. import { getSelectedAccountId, getUserId } from "@/services/bus/account";
  4. import {
  5. AreaInOutApplyAuditPassReq, AuditERMCPAreaInOutStockApplyReq,
  6. WarehouseApplyReq,
  7. WarehouseStateChangeReq
  8. } from "@/services/proto/warehouse/interface";
  9. import {getUUID} from "@/utils/qt/common";
  10. import {buildProtoReq50, parseProtoRsp50} from "@/services/socket/protobuf/buildReq";
  11. /**
  12. * 新增 / 修改 仓库信息请求 修改需要传仓库id
  13. * @param param.type (必填) 类型 1 新增 2 修改
  14. * @param param.warehousecode (必填) 仓库代码
  15. * @param param.warehousename (必填) 仓库名称
  16. * @param param.warehousetype (必填) 仓库类型
  17. */
  18. export const addWarehouseApply = (param: WarehouseApplyReq): Promise<any> => {
  19. return new Promise((resolve, reject) => {
  20. const userid = getUserId();
  21. const accountid = getSelectedAccountId()
  22. const params = {
  23. protobufName: 'WarehouseApplyReq',
  24. funCodeName: 'WarehouseApplyReq',
  25. reqParams: Object.assign(param, { userid, accountid }),
  26. msgHeadParams: {
  27. AccountID: accountid,
  28. MarketID: 18,
  29. GoodsID: 0,
  30. }
  31. };
  32. const package50 = buildProtoReq50(params);
  33. APP.sendTradingServer(package50, undefined, {
  34. onSuccess: (res) => {
  35. const { isSuccess, result } = parseProtoRsp50(res, 'WareHouseApplyRsp');
  36. if (isSuccess) {
  37. resolve(result);
  38. } else {
  39. reject(result);
  40. }
  41. },
  42. onFail: (err) => reject(err.message),
  43. } as Callback);
  44. });
  45. }
  46. /**
  47. * 仓库状态修改请求
  48. * @param param.warehouseid 仓库ID
  49. * @param param.warehousestatus 仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝
  50. */
  51. export const warehouseStateChangeReq = (param: WarehouseStateChangeReq): Promise<any> => {
  52. return new Promise((resolve, reject) => {
  53. const params = {
  54. protobufName: 'WarehouseStateChangeReq',
  55. funCodeName: 'WarehouseStateChangeReq',
  56. reqParams: param,
  57. msgHeadParams: {
  58. AccountID: param.accountid,
  59. MarketID: 18,
  60. GoodsID: 0,
  61. }
  62. };
  63. const package50 = buildProtoReq50(params);
  64. APP.sendTradingServer(package50, undefined, {
  65. onSuccess: (res) => {
  66. const { isSuccess, result } = parseProtoRsp50(res, 'WarehouseStateChangeRsp');
  67. if (isSuccess) {
  68. resolve(result);
  69. } else {
  70. reject(result);
  71. }
  72. },
  73. onFail: (err) => reject(err.message),
  74. } as Callback);
  75. });
  76. }
  77. /**
  78. * 出入库审核 审核通过
  79. * @param param
  80. */
  81. export const inOutStockApplyReq = (param: AreaInOutApplyAuditPassReq): Promise<any> => {
  82. param.ClientTicket = getUUID()
  83. param.AuditSrc = 2
  84. return new Promise((resolve, reject) => {
  85. const params = {
  86. protobufName: 'AreaInOutApplyAuditPassReq',
  87. funCodeName: 'AreaInOutApplyAuditPassReq',
  88. reqParams: param,
  89. msgHeadParams: {
  90. AccountID: getSelectedAccountId(),
  91. MarketID: 18,
  92. GoodsID: 0,
  93. }
  94. };
  95. const package50 = buildProtoReq50(params);
  96. APP.sendTradingServer(package50, undefined, {
  97. onSuccess: (res) => {
  98. const { isSuccess, result } = parseProtoRsp50(res, 'AreaInOutApplyAuditPassRsp');
  99. if (isSuccess) {
  100. resolve(result);
  101. } else {
  102. reject(result);
  103. }
  104. },
  105. onFail: (err) => reject(err.message),
  106. } as Callback);
  107. });
  108. }
  109. /**
  110. * 出入库审核 审核拒绝 & 撤回
  111. * @param param
  112. */
  113. export const refuseStockApplyReq = (param: AuditERMCPAreaInOutStockApplyReq): Promise<any> => {
  114. return new Promise((resolve, reject) => {
  115. const params = {
  116. protobufName: 'AuditERMCPAreaInOutStockApplyReq',
  117. funCodeName: 'AuditERMCPAreaInOutStockApplyReq',
  118. reqParams: param,
  119. msgHeadParams: {
  120. AccountID: getSelectedAccountId(),
  121. MarketID: 18,
  122. GoodsID: 0,
  123. }
  124. };
  125. const package50 = buildProtoReq50(params);
  126. APP.sendTradingServer(package50, undefined, {
  127. onSuccess: (res) => {
  128. const { isSuccess, result } = parseProtoRsp50(res, 'AuditERMCPAreaInOutStockApplyRsp');
  129. if (isSuccess) {
  130. resolve(result);
  131. } else {
  132. reject(result);
  133. }
  134. },
  135. onFail: (err) => reject(err.message),
  136. } as Callback);
  137. });
  138. }