This commit is contained in:
2026-09-29 20:52:44 +08:00
parent ef5c8250c5
commit e379e5b586
8 changed files with 144 additions and 36 deletions
+5 -2
View File
@@ -54,6 +54,7 @@ export function normalizeOutboundTask(value) {
...header,
taskNo: String(header?.taskNo || ''),
outboundNo: String(header?.outboundNo || ''),
outboundType: String(header?.outboundType || ''),
status: String(header?.status || ''),
items: asList(value?.items).map((item) => ({
...item,
@@ -117,12 +118,14 @@ export function pickOutboundPallet(taskNo, palletNo, request) {
return overseasRequest('POST', `${OUTBOUND_BASE}/${encoded(taskNo)}/pallets/${encoded(palletNo)}/pick`, request)
}
export function outboundPickPayload(item, position, packages) {
export function outboundPickPayload(item, position, packages, scannedCode = '') {
const skuScan = item.skuCode && scannedCode === item.skuCode
return {
outboundPalletItemId: item.outboundPalletItemId,
inventoryPositionId: position.inventoryPositionId,
packages: Number(packages),
cartonMarks: position.cartonMark ? [position.cartonMark] : []
cartonMarks: skuScan ? [] : position.cartonMark ? [position.cartonMark] : [],
...(skuScan ? { skuCode: item.skuCode } : {})
}
}
+37
View File
@@ -55,3 +55,40 @@ export async function mergeReturnCartons(request) {
export async function getReturnCartonLabel(cartonMark) {
return normalizeReturnLabel(await overseasRequest('GET', `${BASE}/cartons/${encoded(cartonMark)}/label`))
}
function normalizePlanBox(box = {}) {
return {
boxNo: Number(box.boxNo || 0),
items: Array.isArray(box.items) ? box.items.map((item) => ({ skuCode: String(item.skuCode || ''), quantity: count(item.quantity) })) : [],
length: count(box.length), width: count(box.width), height: count(box.height), weight: count(box.weight),
}
}
export function normalizeReturnPackingPlan(value = {}) {
const skuLines = Array.isArray(value.skuLines) ? value.skuLines.map((item) => ({ skuCode: String(item.skuCode || ''), productNameZh: String(item.productNameZh || ''), quantity: count(item.quantity) })) : []
const boxes = Array.isArray(value.boxes) && value.boxes.length ? value.boxes.map(normalizePlanBox) : skuLines.map((item, index) => ({ boxNo: index + 1, items: [{ skuCode: item.skuCode, quantity: item.quantity }], length: 0, width: 0, height: 0, weight: 0 }))
return {
planNo: String(value.planNo || ''), status: String(value.status || 'READY'), mode: String(value.mode || 'WAREHOUSE_RECOMMENDATION'),
customerName: String(value.customerName || ''), customerReferenceNo: String(value.customerReferenceNo || ''),
returnNos: Array.isArray(value.returnNos) ? value.returnNos.map((item) => String(item || '')).filter(Boolean) : [],
skuLines, boxes, remark: String(value.remark || ''),
}
}
export async function listReturnPackingPlans() {
try {
const value = await overseasRequest('GET', `${BASE}/packing/plans`)
const records = Array.isArray(value) ? value : Array.isArray(value?.records) ? value.records : []
return records.map(normalizeReturnPackingPlan)
}
catch (error) { if (isNotFound(error)) return []; throw error }
}
export async function getReturnPackingPlan(planNo) {
return normalizeReturnPackingPlan(await overseasRequest('GET', `${BASE}/packing/plans/${encoded(planNo)}`))
}
export async function mergeReturnPackingPlan(planNo, request) {
const value = await overseasRequest('POST', `${BASE}/packing/plans/${encoded(planNo)}/complete`, request)
return { ...value, labels: Array.isArray(value?.labels) ? value.labels.map(normalizeReturnLabel) : [normalizeReturnLabel(value?.label || value)], label: normalizeReturnLabel(value?.label || value) }
}
+17 -2
View File
@@ -47,7 +47,7 @@ export function normalizeReturnSkuCandidates(value = {}) {
}
export function normalizeReturnReceiptResult(value = {}) {
return {
const result = {
returnNo: String(value.returnNo || ''),
receiptNo: String(value.receiptNo || ''),
receiptBatchNo: String(value.receiptBatchNo || ''),
@@ -58,6 +58,17 @@ export function normalizeReturnReceiptResult(value = {}) {
receivedQuantity: count(value.receivedQuantity),
signedAt: value.signedAt || null
}
if (value.cartonMark != null || value.printableHtml != null || value.totalBoxCount != null) {
result.cartonMark = String(value.cartonMark || '')
result.printableHtml = String(value.printableHtml || '')
result.totalBoxCount = count(value.totalBoxCount)
}
if (value.unitType != null || value.unitCode != null) {
result.unitType = String(value.unitType || (value.palletCode ? 'PALLET' : ''))
result.unitCode = String(value.unitCode || value.palletCode || '')
}
if (Array.isArray(value.labels)) result.labels = value.labels.map((item) => ({ cartonMark: String(item.cartonMark || ''), printableHtml: String(item.printableHtml || '') })).filter((item) => item.cartonMark && item.printableHtml)
return result
}
export async function startReturnReceipt(returnNo) {
@@ -80,7 +91,11 @@ export async function findReturnSkuCandidates(skuCode) {
}
export async function confirmReturnReceipt(request) {
return normalizeReturnReceiptResult(await overseasRequest('POST', `${BASE}/confirm`, request))
const value = String(request?.palletCode || '')
const encoded = value.startsWith('BOX:') || value.startsWith('PARCEL:')
? { ...request, unitType: value.slice(0, value.indexOf(':')), unitCode: value.slice(value.indexOf(':') + 1), palletCode: undefined }
: request
return normalizeReturnReceiptResult(await overseasRequest('POST', `${BASE}/confirm`, encoded))
}
export async function createReturnPallet(returnNo, skuCode) {