fix(pda): preserve packing plan retry keys and surface missing API

This commit is contained in:
2026-09-29 22:41:05 +08:00
parent 4e14721cb7
commit 19268b38d1
5 changed files with 81 additions and 8 deletions
+3 -6
View File
@@ -76,12 +76,9 @@ export function normalizeReturnPackingPlan(value = {}) {
}
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 }
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) {
+18 -1
View File
@@ -56,7 +56,24 @@
removePlanBox(index) { if (this.planBoxes.length > 1) this.planBoxes.splice(index, 1) },
addPlanItem(box) { box.items.push({ skuCode: '', quantity: 0 }) },
removePlanItem(box, index) { if (box.items.length > 1) box.items.splice(index, 1) },
async completePlan() { if (!this.canCompletePlan || this.busy || !this.activePlan) return; const payload = { boxes: this.planBoxes.map((box, index) => ({ boxNo: index + 1, items: box.items.filter((item) => String(item.skuCode || '').trim() && Number(item.quantity) > 0).map((item) => ({ skuCode: String(item.skuCode).trim(), quantity: Number(item.quantity) })), length: Number(box.length), width: Number(box.width), height: Number(box.height), weight: Number(box.weight) })), idempotencyKey: warehouseIdempotencyKey('returnPackingPlan', 'complete', { planNo: this.activePlan.planNo, boxes: this.planBoxes }).value }; await this.run(async () => { this.result = await mergeReturnPackingPlan(this.activePlan.planNo, payload); this.activePlan = null; this.planBoxes = []; await this.loadPlans(); playSuccessSound() }, '合箱计划执行失败') },
async completePlan() {
if (!this.canCompletePlan || this.busy || !this.activePlan) return
await this.run(async () => {
const planNo = this.activePlan.planNo
const boxes = this.planBoxes.map((box, index) => ({
boxNo: index + 1,
items: box.items.filter((item) => String(item.skuCode || '').trim() && Number(item.quantity) > 0).map((item) => ({ skuCode: String(item.skuCode).trim(), quantity: Number(item.quantity) })),
length: Number(box.length), width: Number(box.width), height: Number(box.height), weight: Number(box.weight)
}))
const key = warehouseIdempotencyKey('returnPackingPlan', 'complete', { planNo, boxes })
this.result = await mergeReturnPackingPlan(planNo, { boxes, idempotencyKey: key.value })
releaseWarehouseKey('returnPackingPlan', key.signature)
this.activePlan = null
this.planBoxes = []
await this.loadPlans()
playSuccessSound()
}, '合箱计划执行失败')
},
startScanner() { this.stopScanner(); this._stopScanner = startScanBroadcast({ onScan: (value) => { if (!this.busy) { this.searchCode = value; this.search(value) } }, onError: (error) => this.setError(error, '扫码广播注册失败') }) },
stopScanner() { if (this._stopScanner) this._stopScanner(); this._stopScanner = null },
async search(raw) { const value = String(raw?.detail?.value ?? raw ?? this.searchCode).trim(); if (!value || this.busy) return; this.searchCode = value; await this.run(async () => { const preview = await findPackingOrders(value); this.candidates = preview.orders.filter((item) => !this.selectedOrders.some((selected) => selected.returnNo === item.returnNo)); if (this.candidates.length) playSuccessSound() }, '查询可合箱退货单失败') },
+2
View File
@@ -8,6 +8,7 @@ const blankState = () => ({
relabel: { currentNo: '', oldLabel: '', newLabel: '', action: 'RELABEL', reason: '', remark: '', photoFileIds: [], photoNames: [], pendingKeys: {} },
returnReceipt: { entryMode: 'SKU', lookupCode: '', currentReturnNo: '', startedBy: 'SKU', trackingNo: '', palletCode: '', quantities: {}, boxCounts: {}, pendingKeys: {} },
returnPacking: { searchCode: '', selectedOrders: [], quantities: {}, length: '', width: '', height: '', weight: '', pendingKeys: {} },
returnPackingPlan: { pendingKeys: {} },
warehouseTransfer: { currentNo: '', pendingKeys: {} },
query: { inventoryCode: '', locationCode: '', palletCode: '' }
})
@@ -40,6 +41,7 @@ export function restoreWarehouseWork(scopeKey) {
stocktake: domain(saved.stocktake, fresh.stocktake), move: domain(saved.move, fresh.move),
relabel: domain(saved.relabel, fresh.relabel), returnReceipt: domain(saved.returnReceipt, fresh.returnReceipt),
returnPacking: domain(saved.returnPacking, fresh.returnPacking),
returnPackingPlan: domain(saved.returnPackingPlan, fresh.returnPackingPlan),
warehouseTransfer: domain(saved.warehouseTransfer, fresh.warehouseTransfer),
query: { ...fresh.query, ...(saved.query || {}) }
})