优化
This commit is contained in:
@@ -1127,7 +1127,7 @@
|
||||
const serverPartialQuantities = {}
|
||||
this.currentBox.items.forEach((item) => {
|
||||
if (item.itemStatus === 'PICKED') serverStates[item.id] = ITEM_STATUS.PICKED
|
||||
else if (item.itemStatus === 'PARTIAL') {
|
||||
else if (item.itemStatus === 'PICKING' || item.itemStatus === 'PARTIAL') {
|
||||
serverStates[item.id] = ITEM_STATUS.PARTIAL
|
||||
serverPartialQuantities[item.id] = Number(item.pickedPackageCount ?? item.finalPickedPackageCount ?? 0)
|
||||
} else if (item.itemStatus === 'SKIPPED') serverStates[item.id] = ITEM_STATUS.SKIPPED
|
||||
@@ -1529,6 +1529,64 @@
|
||||
this.showToast(`已部分拣货:${value}/${item.qty} ${item.unit}`, 'success')
|
||||
this.persistSession()
|
||||
},
|
||||
async submitImmediateItemAction(item, action, payload = {}) {
|
||||
if (this.submitting) { this.showToast('上一笔拣货正在提交,请稍候', 'warning'); return false }
|
||||
if (!this.remoteTaskId || !this.currentBox.warehouseId || this.pickingVersion === null) {
|
||||
this.showToast('任务状态尚未同步,请刷新重试', 'warning')
|
||||
return false
|
||||
}
|
||||
const itemId = item.taskItemId ?? item.remoteItemId ?? item.id
|
||||
const identity = stableTaskOperationIdentity(this.draftIdentity())
|
||||
const operationId = stableOperationId(`item-${action.toLowerCase()}`, identity, {
|
||||
itemId, itemVersion: item.version, taskVersion: this.pickingVersion, ...payload
|
||||
})
|
||||
const common = { warehouseId: this.currentBox.warehouseId, version: Number(item.version || 0), operationId }
|
||||
this.submitting = true
|
||||
this.remoteError = ''
|
||||
try {
|
||||
let task
|
||||
if (action === 'PICK') task = await pickContainerItem(this.remoteTaskId, itemId, { ...common, pickedPackageCount: payload.pickedPackageCount })
|
||||
else if (action === 'PARTIAL') task = await partialContainerItem(this.remoteTaskId, itemId, { ...common, finalPickedPackageCount: payload.finalPickedPackageCount })
|
||||
else if (action === 'SKIP') task = await skipContainerItem(this.remoteTaskId, itemId, { ...common, reason: payload.reason })
|
||||
else task = await pickContainerPallet(this.remoteTaskId, { warehouseId: this.currentBox.warehouseId, palletNo: payload.palletNo, expectedTaskVersion: Number(this.pickingVersion), operationId })
|
||||
this.applyImmediateTaskResult(task)
|
||||
return true
|
||||
} catch (error) {
|
||||
if (this.isTaskConflict(error)) await this.refreshAfterTaskConflict(sanitizeUserMessage(error.message, '装柜明细已变化,请刷新后重试'))
|
||||
else {
|
||||
this.remoteError = error.network ? '网络失败,本次拣货未提交' : this.remoteFailureMessage(error, '拣货提交失败')
|
||||
this.showToast('拣货未提交,请重试', 'error')
|
||||
}
|
||||
return false
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
},
|
||||
applyImmediateTaskResult(result) {
|
||||
if (!result) return
|
||||
const task = normalizePickingTask({ ...this.remotePick, ...result })
|
||||
this.remotePick = task
|
||||
this.pickingVersion = task.pickingVersion ?? task.version ?? this.pickingVersion
|
||||
const remoteItems = Array.isArray(result.items) ? result.items : []
|
||||
const byId = new Map(remoteItems.map((item) => [String(item.id ?? item.itemId), item]))
|
||||
this.currentBox.items = this.currentBox.items.map((item) => {
|
||||
const remote = byId.get(String(item.taskItemId ?? item.remoteItemId ?? item.id))
|
||||
return remote ? { ...item, ...remote, id: item.id, taskItemId: remote.id ?? remote.itemId ?? item.taskItemId } : item
|
||||
})
|
||||
const nextStates = { ...this.itemStates }
|
||||
const nextPartial = { ...this.partialQuantities }
|
||||
this.currentBox.items.forEach((item) => {
|
||||
const count = Number(item.pickedPackageCount || 0)
|
||||
if (item.itemStatus === 'PICKED') nextStates[item.id] = ITEM_STATUS.PICKED
|
||||
else if (item.itemStatus === 'PICKING' || item.itemStatus === 'PARTIAL') {
|
||||
nextStates[item.id] = ITEM_STATUS.PARTIAL
|
||||
nextPartial[item.id] = count
|
||||
} else if (item.itemStatus === 'SKIPPED') nextStates[item.id] = ITEM_STATUS.SKIPPED
|
||||
})
|
||||
this.itemStates = nextStates
|
||||
this.partialQuantities = nextPartial
|
||||
this.evidenceIdentity = this.captureEvidenceIdentity()
|
||||
},
|
||||
availablePickQuantity(item) {
|
||||
if (!item) return null
|
||||
if (item.locationAvailable === false || item.locationStatus === 'DISABLED') return 0
|
||||
|
||||
Reference in New Issue
Block a user