import APP from "@/services"; import { Callback } from "@/utils/websocket"; import { getSelectedAccountId, getUserId } from "@/services/bus/account"; import { AreaInOutApplyAuditPassReq, AuditERMCPAreaInOutStockApplyReq, WarehouseApplyReq, WarehouseStateChangeReq } from "@/services/proto/warehouse/interface"; import {getUUID} from "@/utils/qt/common"; import {buildProtoReq50, parseProtoRsp50} from "@/services/socket/protobuf/buildReq"; /** * 新增 / 修改 仓库信息请求 修改需要传仓库id * @param param.type (必填) 类型 1 新增 2 修改 * @param param.warehousecode (必填) 仓库代码 * @param param.warehousename (必填) 仓库名称 * @param param.warehousetype (必填) 仓库类型 */ export const addWarehouseApply = (param: WarehouseApplyReq): Promise => { return new Promise((resolve, reject) => { const userid = getUserId(); const accountid = getSelectedAccountId() const params = { protobufName: 'WarehouseApplyReq', funCodeName: 'WarehouseApplyReq', reqParams: Object.assign(param, { userid, accountid }), msgHeadParams: { AccountID: accountid, MarketID: 18, GoodsID: 0, } }; const package50 = buildProtoReq50(params); APP.sendTradingServer(package50, undefined, { onSuccess: (res) => { const { isSuccess, result } = parseProtoRsp50(res, 'WareHouseApplyRsp'); if (isSuccess) { resolve(result); } else { reject(result); } }, onFail: (err) => reject(err.message), } as Callback); }); } /** * 仓库状态修改请求 * @param param.warehouseid 仓库ID * @param param.warehousestatus 仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝 */ export const warehouseStateChangeReq = (param: WarehouseStateChangeReq): Promise => { return new Promise((resolve, reject) => { const params = { protobufName: 'WarehouseStateChangeReq', funCodeName: 'WarehouseStateChangeReq', reqParams: param, msgHeadParams: { AccountID: param.accountid, MarketID: 18, GoodsID: 0, } }; const package50 = buildProtoReq50(params); APP.sendTradingServer(package50, undefined, { onSuccess: (res) => { const { isSuccess, result } = parseProtoRsp50(res, 'WarehouseStateChangeRsp'); if (isSuccess) { resolve(result); } else { reject(result); } }, onFail: (err) => reject(err.message), } as Callback); }); } /** * 出入库审核 审核通过 * @param param */ export const inOutStockApplyReq = (param: AreaInOutApplyAuditPassReq): Promise => { param.ClientTicket = getUUID() param.AuditSrc = 2 return new Promise((resolve, reject) => { const params = { protobufName: 'AreaInOutApplyAuditPassReq', funCodeName: 'AreaInOutApplyAuditPassReq', reqParams: param, msgHeadParams: { AccountID: getSelectedAccountId(), MarketID: 18, GoodsID: 0, } }; const package50 = buildProtoReq50(params); APP.sendTradingServer(package50, undefined, { onSuccess: (res) => { const { isSuccess, result } = parseProtoRsp50(res, 'AreaInOutApplyAuditPassRsp'); if (isSuccess) { resolve(result); } else { reject(result); } }, onFail: (err) => reject(err.message), } as Callback); }); } /** * 出入库审核 审核拒绝 & 撤回 * @param param */ export const refuseStockApplyReq = (param: AuditERMCPAreaInOutStockApplyReq): Promise => { return new Promise((resolve, reject) => { const params = { protobufName: 'AuditERMCPAreaInOutStockApplyReq', funCodeName: 'AuditERMCPAreaInOutStockApplyReq', reqParams: param, msgHeadParams: { AccountID: getSelectedAccountId(), MarketID: 18, GoodsID: 0, } }; const package50 = buildProtoReq50(params); APP.sendTradingServer(package50, undefined, { onSuccess: (res) => { const { isSuccess, result } = parseProtoRsp50(res, 'AuditERMCPAreaInOutStockApplyRsp'); if (isSuccess) { resolve(result); } else { reject(result); } }, onFail: (err) => reject(err.message), } as Callback); }); }