fix: complete October 22 workflow feedback and request failure recovery

This commit is contained in:
2026-10-22 23:06:06 +08:00
parent 161128ff9e
commit 54e49e2426
28 changed files with 530 additions and 413 deletions
+11 -22
View File
@@ -3,13 +3,13 @@ import { reactive } from 'vue'
const STORAGE_KEY = 'overseas-pda-warehouse-work-v1'
const blankState = () => ({
scopeKey: '',
stocktake: { taskNo: '', scopeType: 'LOCATION', scopeCode: '', reason: '', pendingKeys: {} },
move: { sourcePalletCode: '', targetLocationCode: '', reason: '', pendingKeys: {} },
relabel: { currentNo: '', oldLabel: '', newLabel: '', action: 'RELABEL', reason: '', remark: '', photoFileIds: [], photoNames: [], pendingKeys: {} },
returnReceipt: { pendingBatch: null, entryMode: 'SKU', lookupCode: '', currentReturnNo: '', startedBy: 'SKU', trackingNo: '', palletCode: '', quantities: {}, boxCounts: {}, pendingKeys: {} },
returnPacking: { mode: 'SKU', searchCode: '', selectedOrders: [], quantities: {}, targetBoxes: [], sourceCartonMarks: [], targetCode: '', activePlan: null, result: null, putawayResults: {}, pendingKeys: {} },
returnPackingPlan: { pendingKeys: {} },
warehouseTransfer: { currentNo: '', pendingKeys: {} },
stocktake: { taskNo: '', scopeType: 'LOCATION', scopeCode: '', reason: '' },
move: { sourcePalletCode: '', targetLocationCode: '', reason: '' },
relabel: { currentNo: '', oldLabel: '', newLabel: '', action: 'RELABEL', reason: '', remark: '', photoFileIds: [], photoNames: [] },
returnReceipt: { entryMode: 'SKU', lookupCode: '', currentReturnNo: '', startedBy: 'SKU', trackingNo: '', palletCode: '', quantities: {}, boxCounts: {} },
returnPacking: { mode: 'SKU', searchCode: '', selectedOrders: [], quantities: {}, targetBoxes: [], sourceCartonMarks: [], targetCode: '', activePlan: null, result: null, putawayResults: {} },
returnPackingPlan: {},
warehouseTransfer: { currentNo: '' },
query: { inventoryCode: '', locationCode: '', palletCode: '' }
})
@@ -19,7 +19,7 @@ function storageAvailable() {
return typeof uni !== 'undefined' && typeof uni.setStorageSync === 'function' && typeof uni.getStorageSync === 'function'
}
function domain(value, fallback) { return { ...fallback, ...(value || {}), pendingKeys: { ...(value?.pendingKeys || {}) } } }
function domain(value, fallback) { return Object.fromEntries(Object.keys(fallback).map(key => [key, value?.[key] ?? fallback[key]])) }
export function persistWarehouseWork() {
if (!storageAvailable() || !warehouseWork.scopeKey) return
@@ -54,21 +54,10 @@ export function updateWarehouseWork(name, patch) {
persistWarehouseWork()
}
export function warehouseIdempotencyKey(name, action, payload = {}) {
const target = warehouseWork[name]
if (!target?.pendingKeys) throw new Error('当前作业不支持写操作')
const signature = `${action}:${JSON.stringify(payload)}`
if (!target.pendingKeys[signature]) target.pendingKeys[signature] = `pda-${name}-${action}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`
persistWarehouseWork()
return { signature, value: target.pendingKeys[signature] }
export function warehouseIdempotencyKey(name, action, _payload = {}) {
if (!warehouseWork[name]) throw new Error('当前作业不支持写操作')
return { value: `pda-${name}-${action}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}` }
}
export function releaseWarehouseKey(name, signature) {
if (!warehouseWork[name]?.pendingKeys) return
delete warehouseWork[name].pendingKeys[signature]
persistWarehouseWork()
}
export function resetWarehouseDomain(name) {
const fresh = blankState()
if (!fresh[name]) return