修改订单拣货页面
This commit is contained in:
parent
ec5dd24860
commit
207631e7ef
@ -28,9 +28,11 @@
|
||||
</view>
|
||||
|
||||
<template v-else>
|
||||
<view v-if="taskInfo.batchNo" class="wave-banner">
|
||||
<view v-if="waveBatchDisplay" class="wave-banner" :class="{ 'wave-banner--clickable': hasMultipleWaves }" @click="handleWaveBannerClick">
|
||||
<text class="wave-banner__label">波次:</text>
|
||||
<text class="wave-banner__value">{{ taskInfo.batchNo }}</text>
|
||||
<text class="wave-banner__value">{{ waveBatchPrefix }}<text v-if="waveBatchSuffix" class="wave-banner__suffix">{{ waveBatchSuffix }}</text></text>
|
||||
<text v-if="modeName && modeName !== '--'" class="wave-banner__mode">{{ modeName }}</text>
|
||||
<text v-if="hasMultipleWaves" class="wave-banner__arrow">›</text>
|
||||
</view>
|
||||
<view class="top-detail-panel">
|
||||
<view v-if="!selectedPickItem" class="list-empty">暂无拣货数据</view>
|
||||
@ -249,6 +251,27 @@
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 波次列表弹窗 -->
|
||||
<u-popup :show="showWaveListPopup" mode="bottom" :closeable="true" border-radius="20" @close="showWaveListPopup = false">
|
||||
<view class="wave-list-popup">
|
||||
<view class="wave-list-popup__title">波次列表</view>
|
||||
<scroll-view class="wave-list-popup__body" scroll-y>
|
||||
<view
|
||||
v-for="(label, index) in distinctWaveLabels"
|
||||
:key="label"
|
||||
class="wave-list-item"
|
||||
:class="{ 'wave-list-item--even': index % 2 === 1 }"
|
||||
>
|
||||
<text class="wave-list-item__index">{{ index + 1 }}</text>
|
||||
<text class="wave-list-item__label">{{ label }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="wave-list-popup__footer">
|
||||
<view class="wave-list-popup__close" @click="showWaveListPopup = false">关闭</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user