From 207631e7efe2c6472e74f9691287ae07f629b96c Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Tue, 4 Aug 2026 13:36:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E6=8B=A3?= =?UTF-8?q?=E8=B4=A7=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/work/order/picking.vue | 275 +++++++++++++++++++++++++++++++---- 1 file changed, 249 insertions(+), 26 deletions(-) diff --git a/pages/work/order/picking.vue b/pages/work/order/picking.vue index e5e9667..9b0fa08 100644 --- a/pages/work/order/picking.vue +++ b/pages/work/order/picking.vue @@ -28,9 +28,11 @@ @@ -294,6 +317,7 @@ import voice from '@/core/utils/voice'; noBarcodeItemTotalQty: 0, showCancelPickPopup: false, showCompletePickPopup: false, + showWaveListPopup: false, submittingWavePickTask: false, currentWavePickSubmitPromise: null, wavePickSubmitQueue: [], @@ -349,6 +373,57 @@ import voice from '@/core/utils/voice'; modeName() { return this.pickingView.modeName || '--'; }, + waveBatchDisplay() { + const boxes = this.boxList; + if (Array.isArray(boxes) && boxes.length > 0) { + const firstRefLabel = boxes[0]?.ref_label || ''; + if (firstRefLabel) { + const remaining = boxes.length - 1; + return remaining > 0 ? `${firstRefLabel}+${remaining}` : firstRefLabel; + } + } + return this.taskInfo.batchNo || ''; + }, + waveBatchPrefix() { + const boxes = this.boxList; + if (Array.isArray(boxes) && boxes.length > 0) { + const firstRefLabel = boxes[0]?.ref_label || ''; + if (firstRefLabel) { + return firstRefLabel; + } + } + return this.taskInfo.batchNo || ''; + }, + waveBatchSuffix() { + const boxes = this.boxList; + if (!Array.isArray(boxes) || boxes.length <= 1) { + return ''; + } + const firstRefLabel = boxes[0]?.ref_label || ''; + if (!firstRefLabel) { + return ''; + } + return `+${boxes.length - 1}`; + }, + distinctWaveLabels() { + const boxes = this.boxList; + if (!Array.isArray(boxes) || boxes.length === 0) { + return []; + } + const seen = new Set(); + const result = []; + for (let i = 0; i < boxes.length; i += 1) { + const label = boxes[i]?.ref_label; + if (label && !seen.has(label)) { + seen.add(label); + result.push(label); + } + } + return result; + }, + hasMultipleWaves() { + return this.distinctWaveLabels.length > 1; + }, filteredPickItems() { return Array.isArray(this.pickingView.items) ? this.pickingView.items : []; }, @@ -1284,6 +1359,12 @@ import voice from '@/core/utils/voice'; } this.showActionsPopup = true; }, + handleWaveBannerClick() { + if (!this.hasMultipleWaves) { + return; + } + this.showWaveListPopup = true; + }, requestWavePickTaskComplete(taskIdNumber, options = {}) { const payload = { task_id: taskIdNumber, @@ -1555,6 +1636,12 @@ import voice from '@/core/utils/voice'; this.restoreConfirmedOrderIdsForCurrentTask(); this.restoreBoundCartForCurrentTask(); this.selectedIndex = 0; + // 清除旧缓存,准备新任务数据 + this.itemBarcodeCache = {}; + this.itemImageCache = {}; + this.itemImageListCache = {}; + // 后台批量预加载所有条码,避免切换时逐个请求 + this.preloadAllItemBarcodes(); }, async requestWavePickTaskDetail() { const taskIdNumber = Number(this.taskId || 0); @@ -1763,31 +1850,82 @@ import voice from '@/core/utils/voice'; } this.selectedItemBarcodeLoading = true; this.selectedItemBarcode = ''; - try { - const stockId = Number(item.stockId || 0); - const response = await this.$http('stock.warehouse.getBarcodes', { - id: stockId - }); - const list = this.extractBarcodeListFromResponse(response); - const allBarcodes = (list || []) - .map(entry => this.resolveBarcodeFromEntry(entry)) - .filter(b => b); - const joinedBarcodes = allBarcodes.join(','); - this.$set(this.itemBarcodeCache, barcodeKey, joinedBarcodes || ''); - if (this.getSelectedItemBarcodeKey(this.selectedPickItem) === barcodeKey) { - this.selectedItemBarcode = joinedBarcodes || ''; - } - } catch (error) { - this.$set(this.itemBarcodeCache, barcodeKey, ''); - if (this.getSelectedItemBarcodeKey(this.selectedPickItem) === barcodeKey) { - this.selectedItemBarcode = ''; - } - } finally { - if (this.getSelectedItemBarcodeKey(this.selectedPickItem) === barcodeKey) { - this.selectedItemBarcodeLoading = false; - } + const stockId = Number(item.stockId || 0); + // 复用去重请求:若已在缓存或有进行中的请求则直接使用 + const result = await this.loadSingleItemBarcodeToCache(stockId, barcodeKey); + if (this.getSelectedItemBarcodeKey(this.selectedPickItem) === barcodeKey) { + this.selectedItemBarcode = result || ''; + this.selectedItemBarcodeLoading = false; } }, + // 后台批量预加载所有拣货商品的条码,避免网络卡顿时切换商品逐个请求 + async preloadAllItemBarcodes() { + const items = this.filteredPickItems; + if (!items.length) { + return; + } + // 收集需要加载的唯一 stockId + const stockIdsToLoad = []; + const seenStockIds = new Set(); + for (let i = 0; i < items.length; i += 1) { + const stockId = Number(items[i].stockId || 0); + if (!stockId) { + continue; + } + const barcodeKey = String(stockId); + if (seenStockIds.has(barcodeKey)) { + continue; + } + // 如果当前已在缓存中(可能被当前选中商品先加载),跳过 + if (Object.prototype.hasOwnProperty.call(this.itemBarcodeCache, barcodeKey)) { + continue; + } + seenStockIds.add(barcodeKey); + stockIdsToLoad.push({ stockId, barcodeKey }); + } + if (!stockIdsToLoad.length) { + return; + } + // 每批 3 个并发请求,避免过多请求堵塞 + const BATCH_SIZE = 3; + for (let i = 0; i < stockIdsToLoad.length; i += BATCH_SIZE) { + const batch = stockIdsToLoad.slice(i, i + BATCH_SIZE); + await Promise.all(batch.map(({ stockId, barcodeKey }) => + this.loadSingleItemBarcodeToCache(stockId, barcodeKey) + )); + } + }, + async loadSingleItemBarcodeToCache(stockId, barcodeKey) { + // 惰性初始化请求去重 Map(非响应式,避免 Vue 2 响应式系统干扰) + if (!this._pendingBarcodePromises) { + this._pendingBarcodePromises = {}; + } + // 请求去重:同一 stockId 只发一次请求 + if (Object.prototype.hasOwnProperty.call(this._pendingBarcodePromises, barcodeKey)) { + return this._pendingBarcodePromises[barcodeKey]; + } + const promise = (async () => { + try { + const response = await this.$http('stock.warehouse.getBarcodes', { + id: stockId + }); + const list = this.extractBarcodeListFromResponse(response); + const allBarcodes = (list || []) + .map(entry => this.resolveBarcodeFromEntry(entry)) + .filter(b => b); + const joinedBarcodes = allBarcodes.join(','); + this.$set(this.itemBarcodeCache, barcodeKey, joinedBarcodes || ''); + return joinedBarcodes; + } catch (error) { + this.$set(this.itemBarcodeCache, barcodeKey, ''); + return ''; + } finally { + delete this._pendingBarcodePromises[barcodeKey]; + } + })(); + this._pendingBarcodePromises[barcodeKey] = promise; + return promise; + }, selectPickItem(index) { this.selectedIndex = Number(index || 0); }, @@ -1972,13 +2110,98 @@ import voice from '@/core/utils/voice'; flex: 1; min-width: 0; font-size: 30rpx; - font-weight: 600; + font-weight: bold; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .wave-banner__suffix { + flex-shrink: 0; + font-size: 30rpx; + font-weight: bold; + color: #909399; + margin-left: 10rpx; + } + + .wave-banner__mode { + flex-shrink: 0; + font-size: 28rpx; + color: #303133; + border-radius: 6rpx; + padding: 2rpx 12rpx; + } + + .wave-banner--clickable { + cursor: pointer; + } + + .wave-banner__arrow { + flex-shrink: 0; + font-size: 36rpx; + color: #909399; + line-height: 1; + } + + .wave-list-popup { + padding: 32rpx 24rpx 24rpx; + } + + .wave-list-popup__title { + font-size: 32rpx; + font-weight: 600; + color: #303133; + text-align: center; + margin-bottom: 24rpx; + } + + .wave-list-popup__body { + max-height: 600rpx; + } + + .wave-list-item { + display: flex; + align-items: center; + gap: 16rpx; + padding: 20rpx 16rpx; + border-bottom: 1rpx solid #f2f2f2; + } + + .wave-list-item__index { + flex-shrink: 0; + width: 44rpx; + height: 44rpx; + line-height: 44rpx; + text-align: center; + font-size: 24rpx; + color: #ffffff; + background: #2979ff; + border-radius: 50%; + } + + .wave-list-item__label { + flex: 1; + font-size: 34rpx; + color: #303133; + } + + .wave-list-item--even { + background: #f5f7fa; + } + + .wave-list-popup__footer { + display: flex; + justify-content: center; + margin-top: 24rpx; + } + + .wave-list-popup__close { + font-size: 32rpx; + color: #909399; + padding: 12rpx 48rpx; + } + .nav-right { padding-right: 24rpx; display: flex;