fix(pda): align return workflows with current test backend

This commit is contained in:
2026-09-29 23:25:00 +08:00
parent fddaaf71fb
commit 33c395937a
8 changed files with 31 additions and 333 deletions
-34
View File
@@ -55,37 +55,3 @@ 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() {
const value = await overseasRequest('GET', `${BASE}/packing/plans`)
const records = Array.isArray(value) ? value : Array.isArray(value?.records) ? value.records : []
return records.map(normalizeReturnPackingPlan)
}
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) }
}
+2 -17
View File
@@ -47,7 +47,7 @@ export function normalizeReturnSkuCandidates(value = {}) {
}
export function normalizeReturnReceiptResult(value = {}) {
const result = {
return {
returnNo: String(value.returnNo || ''),
receiptNo: String(value.receiptNo || ''),
receiptBatchNo: String(value.receiptBatchNo || ''),
@@ -58,17 +58,6 @@ 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) {
@@ -91,11 +80,7 @@ export async function findReturnSkuCandidates(skuCode) {
}
export async function confirmReturnReceipt(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))
return normalizeReturnReceiptResult(await overseasRequest('POST', `${BASE}/confirm`, request))
}
export async function createReturnPallet(returnNo, skuCode) {