Files
klp-mono/apps/hand-factory/strategies/wmsScan.js
2025-10-27 13:21:43 +08:00

64 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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}`]: { ... },
};