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
+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() }, '查询可合箱退货单失败') },