import { CODE_STATUS, IO_TYPE } from '@/constants/wms'; /** * 扫码确认操作的策略配置:key = "状态-IO类型",value = 策略函数/配置 * 每个策略包含: * - getAddParams:组装addStockIoDetail的参数 * - getUpdateStatus:扫码后需更新的二维码状态 */ export const SCAN_OPERATION_STRATEGIES = { // 场景1:状态0(未使用)+ 入库 → 正常入库,状态改为1(已入库) [`${CODE_STATUS.UNUSED}-${IO_TYPE.IN}`]: { getAddParams: (scanResult, remark) => ({ quantity: scanResult.quantity, ioType: scanResult.ioType, batchNo: scanResult.batchNo, itemType: scanResult.itemType, stockIoId: scanResult.stockIoId, // 用原始库存单ID warehouseId: scanResult.warehouseId, fromWarehouseId: scanResult.fromWarehouseId, itemId: scanResult.itemId, remark: remark, recordType: 1 // 扫码录入标识 }), getUpdateStatus: () => CODE_STATUS.IN_STOCK // 更新为“已入库” }, // 场景2:状态0(未使用)+ 出库 → 正常出库,状态改为2(已出库) [`${CODE_STATUS.UNUSED}-${IO_TYPE.OUT}`]: { getAddParams: (scanResult, remark) => ({ quantity: scanResult.quantity, ioType: scanResult.ioType, batchNo: scanResult.batchNo, itemType: scanResult.itemType, stockIoId: scanResult.stockIoId, warehouseId: scanResult.warehouseId, fromWarehouseId: scanResult.fromWarehouseId, itemId: scanResult.itemId, remark: remark, recordType: 1 }), getUpdateStatus: () => CODE_STATUS.OUT_STOCK // 更新为“已出库” }, // 场景3:状态1(已入库)+ 入库 → 实际为出库,用备用库存单ID,状态改为2 [`${CODE_STATUS.IN_STOCK}-${IO_TYPE.IN}`]: { getAddParams: (scanResult, remark) => ({ quantity: scanResult.quantity, ioType: IO_TYPE.OUT, // 强制改为出库 batchNo: scanResult.batchNo, itemType: scanResult.itemType, stockIoId: scanResult.stockIoWaitId, // 用备用库存单ID warehouseId: scanResult.warehouseId, fromWarehouseId: scanResult.fromWarehouseId, itemId: scanResult.itemId, remark: remark, recordType: 1 }), getUpdateStatus: () => CODE_STATUS.OUT_STOCK // 更新为“已出库” } // 新增场景:直接在这里加新的key和策略,无需修改父组件逻辑 // 示例:场景4:状态0+移库 → ... // [`${CODE_STATUS.UNUSED}-${IO_TYPE.TRANSFER}`]: { ... }, };