优化
This commit is contained in:
@@ -126,7 +126,7 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
pallets: { deep: true, handler() { if (!this.submitting) this.pendingKey = '' } }
|
pallets: { deep: true, handler() { if (!this.submitting) this.pendingKey = '' } }
|
||||||
},
|
},
|
||||||
onShow() { if (requireSession()) { this.user = session.currentUser; restoreWarehouseWork(`${this.user.id}:${this.user.warehouseId}`); this.startScanner(); this.loadCandidates().then(() => { const activeNo = String(warehouseWork.warehouseTransfer.currentNo || ''); const taskNo = this.pendingTaskNo || activeNo; if (this.entryMode === 'work' && taskNo) { const active = this.candidates.find((item) => String(item.transferNo) === taskNo); if (active) { this.pendingTaskNo = ''; void this.select(active) } } }) } },
|
onShow() { if (requireSession()) { this.user = session.currentUser; restoreWarehouseWork(`${this.user.id}:${this.user.warehouseId}`); this.startScanner(); this.loadCandidates().then(() => { const activeNo = String(warehouseWork.warehouseTransfer.currentNo || ''); const taskNo = this.pendingTaskNo || activeNo; if (this.entryMode === 'work' && taskNo) { const active = this.candidates.find((item) => String(item.transferNo) === taskNo); if (active) { const fromExplicitTask = Boolean(this.pendingTaskNo); this.pendingTaskNo = ''; void this.select(active, fromExplicitTask) } } }) } },
|
||||||
onLoad(options) { this.entryMode = options?.mode === 'list' ? 'list' : 'work'; this.pendingTaskNo = String(options?.task || '') },
|
onLoad(options) { this.entryMode = options?.mode === 'list' ? 'list' : 'work'; this.pendingTaskNo = String(options?.task || '') },
|
||||||
onHide() { this.stopScanner() },
|
onHide() { this.stopScanner() },
|
||||||
beforeUnmount() { this.stopScanner() },
|
beforeUnmount() { this.stopScanner() },
|
||||||
@@ -163,12 +163,24 @@ export default {
|
|||||||
catch (error) { this.error = error; pallet.busy = false }
|
catch (error) { this.error = error; pallet.busy = false }
|
||||||
},
|
},
|
||||||
async printDraftPallet(pallet) { if (!pallet.labelDownloadPath) { this.error = new Error('服务端未返回托盘标签下载地址'); return }; await this.openLabelPdf(() => downloadWarehouseTransferPalletLabel(pallet.labelDownloadPath)) },
|
async printDraftPallet(pallet) { if (!pallet.labelDownloadPath) { this.error = new Error('服务端未返回托盘标签下载地址'); return }; await this.openLabelPdf(() => downloadWarehouseTransferPalletLabel(pallet.labelDownloadPath)) },
|
||||||
async loadCandidates() { this.loading = true; this.error = null; try { const activeNo = String(warehouseWork.warehouseTransfer.currentNo || ''); this.candidates = (await listWarehouseTransferCandidates()).map((item) => String(item.transferNo) === activeNo && item.status === 'WAIT_PDA_RECEIVING' ? { ...item, status: 'PARTIALLY_RECEIVED' } : item) } catch (e) { this.error = e } finally { this.loading = false } },
|
async loadCandidates() {
|
||||||
async select(item) {
|
this.loading = true; this.error = null
|
||||||
|
try {
|
||||||
|
const activeNo = String(warehouseWork.warehouseTransfer.currentNo || '')
|
||||||
|
const measuredStatuses = new Set(['WAIT_PDA_RECEIVING', 'APPROVED', 'ALLOCATED', 'PARTIALLY_RECEIVED'])
|
||||||
|
this.candidates = (await listWarehouseTransferCandidates()).map((item) => String(item.transferNo) === activeNo && item.status === 'WAIT_PDA_RECEIVING' ? { ...item, status: 'PARTIALLY_RECEIVED' } : item)
|
||||||
|
// 服务端已完成当前单但设备在提交响应前断网时,本地 currentNo 会遗留。
|
||||||
|
// 候选已成功读取且当前单不再可测,清掉本地锁,允许继续下一票。
|
||||||
|
if (activeNo && !this.candidates.some((item) => String(item.transferNo) === activeNo && measuredStatuses.has(String(item.status)))) {
|
||||||
|
resetWarehouseDomain('warehouseTransfer')
|
||||||
|
}
|
||||||
|
} catch (e) { this.error = e } finally { this.loading = false }
|
||||||
|
},
|
||||||
|
async select(item, fromExplicitTask = false) {
|
||||||
if (this.detailLoading || this.submitting) return
|
if (this.detailLoading || this.submitting) return
|
||||||
const requestedNo = String(item?.transferNo || '')
|
const requestedNo = String(item?.transferNo || '')
|
||||||
const activeNo = String(warehouseWork.warehouseTransfer.currentNo || '')
|
const activeNo = String(warehouseWork.warehouseTransfer.currentNo || '')
|
||||||
if (!activeNo) {
|
if (!activeNo && !fromExplicitTask) {
|
||||||
const result = await new Promise((resolve) => uni.showModal({ title: '开始测量', content: `确认开始测量转运单 ${requestedNo} 吗?开始后本设备需先完成该单,才能选择下一单。`, confirmText: '确认开始', cancelText: '取消', success: resolve, fail: () => resolve({ confirm: false }) }))
|
const result = await new Promise((resolve) => uni.showModal({ title: '开始测量', content: `确认开始测量转运单 ${requestedNo} 吗?开始后本设备需先完成该单,才能选择下一单。`, confirmText: '确认开始', cancelText: '取消', success: resolve, fail: () => resolve({ confirm: false }) }))
|
||||||
if (!result.confirm) return
|
if (!result.confirm) return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user