| 12345678910111213141516171819 |
- import { barcodeToUpperCase } from '@/utils/dataType'
- /** 组合商品:匹配ASN明细中条码,附加 matchedJson */
- export function receivingBarcodeCombine(asnDetailList, combineSkuMap) {
- if (!combineSkuMap || !Array.isArray(asnDetailList) || !asnDetailList.length) return []
- const mapUpper = Object.fromEntries(
- Object.entries(combineSkuMap).filter(([barcode]) => barcode).map(([barcode, config]) => [barcodeToUpperCase(barcode), config])
- )
- return asnDetailList
- .map((item) => {
- const barcodes = [item.barcode, item.barcode2, item.sku].filter(Boolean)
- const matchedBar = barcodes.find((bar) => mapUpper[barcodeToUpperCase(bar)])
- if (!matchedBar) return null
- const matched = mapUpper[barcodeToUpperCase(matchedBar)]
- const remaining = (item.expectedQuantity || 0) - (item.receivedQuantity || 0)
- return remaining >= matched.quantity ? { ...item, matchedJson: matched } : null
- })
- .filter(Boolean)
- }
|