修改订单复核页面

This commit is contained in:
zm2000 2026-07-31 17:00:00 +08:00
parent 3d5d96b2ee
commit c290eecc2b
3 changed files with 328 additions and 19 deletions

View File

@ -19,6 +19,11 @@
width="120rpx"
height="120rpx"
>
<template #loading>
<view class="goods-info-image-placeholder">
<u-icon name="photo" size="28" color="#c0c4cc"></u-icon>
</view>
</template>
<template #error>
<view class="goods-info-image-placeholder">
<u-icon name="photo" size="28" color="#c0c4cc"></u-icon>

View File

@ -95,6 +95,11 @@
width="120rpx"
height="120rpx"
>
<template #loading>
<view class="image-placeholder image-placeholder--small">
<u-icon name="photo" size="24" color="#c0c4cc"></u-icon>
</view>
</template>
<template #error>
<view class="image-placeholder image-placeholder--small">
<u-icon name="photo" size="24" color="#c0c4cc"></u-icon>
@ -105,7 +110,9 @@
</view>
<view class="list-card-row__bottom">
<text class="list-card-name">{{ item.skuName || '--' }}</text>
<text class="list-card-space">{{' '}}</text>
<text class="list-card-tag" @click.stop="handleListBarcodeClick(item, index)">{{ item.barcode || '--' }}</text>
<text class="list-card-space">{{' '}}</text>
<text class="list-card-tag">{{ item.location || '--' }}</text>
</view>
</view>
@ -140,6 +147,11 @@
width="100%"
height="100%"
>
<template #loading>
<view class="multi-match-image-placeholder">
<u-icon name="photo" size="40" color="#c0c4cc"></u-icon>
</view>
</template>
<template #error>
<view class="multi-match-image-placeholder">
<u-icon name="photo" size="40" color="#c0c4cc"></u-icon>
@ -1154,25 +1166,28 @@ import voice from '@/core/utils/voice';
}
.list-card-row__bottom {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
gap: 8rpx;
display: block;
padding: 4rpx 16rpx 20rpx;
line-height: 1.5;
}
.list-card-name {
font-size: 34rpx;
color: #000000;
font-weight: 500;
line-height: 1.4;
line-height: 1.5;
}
.list-card-tag {
font-size: 34rpx;
color: #000000;
line-height: 1.4;
line-height: 1.5;
}
.list-card-space {
font-size: 34rpx;
color: #000000;
line-height: 1.5;
}
.image-placeholder--small {

View File

@ -319,6 +319,31 @@
</view>
</u-popup>
<!-- 打印失败弹窗:打印失败/超时未发货时提示,可重试打印 -->
<u-popup
:show="showPrintFailPopup"
mode="center"
:closeable="false"
:closeOnClickOverlay="false"
border-radius="16"
:z-index="10095"
@close="showPrintFailPopup = false"
>
<view class="print-fail-popup">
<view class="print-fail-popup-title">打印未完成</view>
<view class="print-fail-popup-body">
<text class="print-fail-popup-text">打印失败或超时,未触发发货。请重试打印,打印成功后将自动发货。</text>
<view v-if="printFailMessage" class="print-fail-popup-msg">
<text class="print-fail-popup-msg__text">{{ printFailMessage }}</text>
</view>
</view>
<view class="print-fail-popup-footer">
<view class="print-fail-footer-btn print-fail-footer-btn--cancel" @click="showPrintFailPopup = false">关闭</view>
<view class="print-fail-footer-btn print-fail-footer-btn--print" @click="handlePrintFailRetry">打印</view>
</view>
</view>
</u-popup>
<u-popup :show="showStationListPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10090" @close="showStationListPopup = false; selectedStationId = ''">
<view class="print-popup">
<view class="print-popup-title">打印台列表</view>
@ -413,6 +438,11 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
packageBindingActivated: false,
showPackageBindingPopup: false,
autoShip: true,
showPrintFailPopup: false,
printFailMessage: '',
_pendingShipAction: 'autoNext',
_lastPrintError: '',
_printFailDismissed: false,
printStationList: [],
selectedStationId: '',
stationListPage: 1,
@ -436,6 +466,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
_debugMode: false,
_debugLogs: [],
_autoSelectFirst: false,
_scanKeyword: '',
packageBindingCancelled: false,
skipPackagePopupOnAllScanned: false,
showDetailView: false,
@ -1213,6 +1244,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
if (!text) return;
this.keyword = '';
this._autoSelectFirst = true; // 输入搜索选第一个
this._scanKeyword = text; // 记录本次扫描/输入的快递单号或波次号
// 详情视图模式下,搜索框输入当作条码传给 ReviewDetail
if (this.showDetailView && this.$refs.reviewDetail) {
// 已复核订单禁止扫描
@ -1413,6 +1445,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
};
this.reviewedOrderIds = [];
this.currentOrderIndex = -1;
this._printFailDismissed = false;
// 数量回归1
this.scanQuantity = 1;
this.saveSettings();
@ -1520,11 +1553,14 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
const groupWaybillNo = String(
payload?.waybill_no || payload?.waybillNo || ''
).trim();
// 后端返回的当前波次ID(data.wave_id),用于精确匹配进入对应波次
const currentWaveId = String(payload?.wave_id ?? payload?.waveId ?? '').trim();
return {
listType: 'group',
matchType,
waves: normalizedWaves,
waybillNo: groupWaybillNo,
waveId: currentWaveId,
total: Number(payload?.total ?? payload?.count ?? waves.length),
totalOrders: calcTotalOrders,
totalUnreviewedCount: calcUnreviewed,
@ -1667,12 +1703,26 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
});
}
// D前缀波次:不自动进入详情,等待扫描商品条码定位所属订单
// 自动选中订单:输入搜索选第一个,任务刷新选最后一个
// 自动选中订单:扫描/输入搜索时优先匹配快递单号,否则选第一个;任务刷新选最后一个
this.$nextTick(() => {
if (this.isDprefixedWave) return;
const unreviewedItems = this.orderList.filter(item => !item.isReviewed);
const target = this._autoSelectFirst ? unreviewedItems[0] : unreviewedItems.pop();
let target = null;
if (this._autoSelectFirst) {
const scanKw = String(this._scanKeyword || '').trim();
// 扫描快递单号时:优先精确匹配该运单号对应的订单,进入其复核详情
if (scanKw) {
target = this.orderList.find(item => String(item.waybillNo || '').trim() === scanKw) || null;
}
}
if (!target) {
target = this._autoSelectFirst ? unreviewedItems[0] : unreviewedItems.pop();
}
if (target) {
// 扫描快递单号进入详情时,确保顶部显示该运单号(接口未返回运单号时兜底)
if (this._autoSelectFirst && !String(target.waybillNo || '').trim() && this._scanKeyword) {
target = { ...target, waybillNo: this._scanKeyword };
}
this.goPickGoodsDetail(target);
}
});
@ -1722,10 +1772,20 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
icon: 'none'
});
}
// 自动选中波次:输入搜索选第一个,任务刷新选最后一个
// 自动选中波次:扫描/输入搜索时优先精确匹配后端返回的 wave_id 对应波次,否则选第一个;任务刷新选最后一个
this.$nextTick(() => {
const unreviewedItems = this.orderList.filter(item => (item.unreviewedCount || 0) > 0);
const target = this._autoSelectFirst ? unreviewedItems[0] : unreviewedItems.pop();
let target = null;
if (this._autoSelectFirst) {
// 优先精确匹配 data.wave_id 对应的波次,进入该波次详情并显示其波次号
const targetWaveId = String(result?.waveId ?? '').trim();
if (targetWaveId) {
target = this.orderList.find(wave => String(wave?.waveId ?? wave?.id ?? '').trim() === targetWaveId) || null;
}
}
if (!target) {
target = this._autoSelectFirst ? unreviewedItems[0] : unreviewedItems.pop();
}
if (target) {
this.goPickGoodsDetail(target);
}
@ -2108,6 +2168,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
// 切换订单时重置包材/称重取消标志,新订单继续正常弹窗
this.packageBindingCancelled = false;
this.weighCancelled = false;
this._printFailDismissed = false;
// 收集商品明细数据
let rawItems = [];
@ -2325,6 +2386,12 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
this.afterPackageBinding();
},
handleGoodsItemClick() {
// 打印未完成被关闭后(订单未打印未发货),点击商品列表项只重新弹出打印未完成弹窗,不自动重试打印
if (this._printFailDismissed && !this.showPrintFailPopup) {
this.printFailMessage = this._lastPrintError || '打印失败,未触发发货';
this.showPrintFailPopup = true;
return;
}
// 点击商品列表项时,如果之前取消过包材绑定则重新弹出
if (this.packageBindingCancelled && this.listType !== 'single' && this.enablePackageBinding && !this.showPackageBindingPopup) {
this.packageBindingCancelled = false;
@ -2608,26 +2675,181 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
this.showWeighPopup = true;
return;
}
const ok = await this.callConfirmRecheck();
if (ok && this.autoShip) {
setTimeout(() => this.goToNextOrder(), 500);
// 数据一致后先确保打印完成,打印成功前不触发发货
if (!(await this.ensurePrintedBeforeShip('manual'))) {
return;
}
await this.doShip('manual');
},
async handleAutoConfirmAndNext() {
const ok = await this.callConfirmRecheck();
if (ok) {
setTimeout(() => this.goToNextOrder(), 500);
// 数据一致后先确保打印完成,打印成功前不触发发货
if (!(await this.ensurePrintedBeforeShip('autoNext'))) {
return;
}
await this.doShip('autoNext');
},
async handleDprefixedAutoConfirm() {
// D前缀波次:确认复核后返回列表,等待下一个商品条码扫描定位
// D前缀波次:数据一致后先确保打印完成,打印成功前不触发发货
if (!(await this.ensurePrintedBeforeShip('dprefixed'))) {
return;
}
await this.doShip('dprefixed');
},
/**
* 数据一致后、发货前的打印确认:
* 1. 不打印模式直接放行
* 2. 未绑定打印台时阻止发货并提示
* 3. 已打印订单直接放行
* 4. 未打印则先调用打印并等待结果,打印成功后才允许发货
* 5. 打印失败/超时不触发发货,弹出提示弹窗(含打印按钮)
* @param {string} actionType 打印成功后执行的发货动作:autoNext | manual | dprefixed
* @returns {Promise<boolean>} 是否允许继续发货
*/
async ensurePrintedBeforeShip(actionType = 'autoNext') {
// 记录打印成功后的发货动作,供弹窗重试后继续执行
this._pendingShipAction = actionType;
// 不打印模式:直接放行
if (this.effectivePrintMode === 'noPrint') {
return true;
}
// 需要打印但未绑定打印台:阻止发货并提示
if (!this.printStationId) {
this.printFailMessage = '未绑定打印台,请先绑定打印台后再发货';
this._printFailDismissed = true;
this.showPrintFailPopup = true;
return false;
}
// 已打印的订单直接放行
const isGroup = this.listType === 'group';
const isAlreadyPrinted = isGroup
? (this.detailInfo?.unprintedCount || 0) === 0 && (this.detailInfo?.orderCount || 0) > 0
: !!this.detailInfo?.isPrinted;
if (isAlreadyPrinted) {
return true;
}
// 未打印:先打印并等待结果,打印成功后才允许发货
uni.showLoading({ title: '打印中...', mask: true });
const printed = await this.printOrderAndWait(this.detailInfo);
uni.hideLoading();
if (printed) {
this.detailInfo = { ...this.detailInfo, isPrinted: true, unprintedCount: 0 };
this.updateOrderPrintStatus(this.detailInfo);
this._printFailDismissed = false;
this.speakVoice('打印成功');
return true;
}
// 打印失败/超时:不触发发货,弹窗提示并提供打印按钮
this.printFailMessage = this._lastPrintError || '打印失败,未触发发货';
this._printFailDismissed = true;
this.showPrintFailPopup = true;
this.speakVoice('打印失败');
return false;
},
/**
* 为 Promise 增加超时控制
* @param {Promise} promise
* @param {number} ms 超时毫秒数,默认 10000
*/
withTimeout(promise, ms = 10000) {
let timer = null;
const timeoutPromise = new Promise((_, reject) => {
timer = setTimeout(() => reject(new Error('打印请求超时')), ms);
});
return Promise.race([Promise.resolve(promise), timeoutPromise]).finally(() => {
if (timer) clearTimeout(timer);
});
},
/**
* 打印当前订单并等待结果(含超时),返回是否成功
* @param {object} item
* @returns {Promise<boolean>}
*/
async printOrderAndWait(item) {
const target = item || this.detailInfo;
if (!target || !this.printStationId) {
this._lastPrintError = '未绑定打印台';
return false;
}
try {
let waveGroups;
if (this.listType === 'group') {
const warehouseId = this.resolveWarehouseId();
const waveId = String(target?.waveId || target?.id || '').trim();
const response = await this.$http('order.print.getWavePlatformPrintData', { warehouse_id: warehouseId, wave_ids: [waveId] });
const payload = this.extractWavePlatformPrintPayload(response);
waveGroups = this.normalizeWaveGroups(payload);
} else {
const params = this.buildOrderPrintDataParams(target);
const response = await this.$http('order.print.getOrderPrintData', params);
const payload = this.extractOrderPrintPayload(response);
waveGroups = this.normalizeOrderPrintGroups(payload);
}
if (!waveGroups.length) {
this._lastPrintError = '未获取到可打印数据';
return false;
}
this.printRequestCode = this.buildPrintRequestCode();
const sendParams = {
type: 'express',
printStationId: this.printStationId,
requestCode: this.printRequestCode,
data: { waveGroups }
};
this.debugLog('print.send 请求参数', sendParams);
const response = await this.withTimeout(this.$http('print.send', sendParams), 10000);
this.debugLog('print.send 返回数据', response);
const success = response?.flag !== 'failure' && response?.code !== '500' && response?.code !== 500;
if (!success) {
this._lastPrintError = String(response?.message || response?.msg || '打印失败');
return false;
}
this._lastPrintError = '';
return true;
} catch (error) {
this._lastPrintError = String(error?.message || error?.msg || error?.errMsg || '打印失败或超时');
console.warn('[printOrderAndWait] 打印失败/超时:', this._lastPrintError);
return false;
}
},
/**
* 执行发货(确认复核)及后续跳转
* @param {string} action autoNext | manual | dprefixed
*/
async doShip(action = 'autoNext') {
const ok = await this.callConfirmRecheck();
if (ok) {
if (!ok) return;
this._printFailDismissed = false;
if (action === 'dprefixed') {
// D前缀波次:确认复核后返回列表,等待下一个商品条码扫描定位
setTimeout(() => {
this.backToList();
}, 500);
} else if (action === 'manual' && !this.autoShip) {
// 手动发货:复核完成后留在当前页,由用户继续操作
} else {
setTimeout(() => this.goToNextOrder(), 500);
}
},
handlePrintFailClose() {
this.showPrintFailPopup = false;
},
async handlePrintFailRetry() {
uni.showLoading({ title: '打印中...', mask: true });
const printed = await this.printOrderAndWait(this.detailInfo);
uni.hideLoading();
if (!printed) {
this.printFailMessage = this._lastPrintError || '打印失败,请重试';
this.speakVoice('打印失败');
return;
}
// 打印成功:关闭弹窗,更新打印状态,触发发货
this._printFailDismissed = false;
this.showPrintFailPopup = false;
this.detailInfo = { ...this.detailInfo, isPrinted: true, unprintedCount: 0 };
this.updateOrderPrintStatus(this.detailInfo);
this.speakVoice('打印成功');
await this.doShip(this._pendingShipAction || 'autoNext');
},
goToNextOrder() {
// 标记当前已复核
const currentId = String(this.detailInfo?.orderId || this.detailInfo?.recordId || '');
@ -3189,6 +3411,73 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
border-radius: 0;
}
/* 打印失败弹窗 */
.print-fail-popup {
width: 580rpx;
padding: 36rpx;
background: #ffffff;
border-radius: 16rpx;
}
.print-fail-popup-title {
font-size: 34rpx;
font-weight: 600;
color: #303133;
text-align: center;
margin-bottom: 24rpx;
}
.print-fail-popup-body {
margin-bottom: 28rpx;
}
.print-fail-popup-text {
font-size: 30rpx;
color: #606266;
line-height: 1.6;
display: block;
}
.print-fail-popup-msg {
margin-top: 16rpx;
padding: 16rpx 20rpx;
background: #fef0f0;
border-radius: 8rpx;
}
.print-fail-popup-msg__text {
font-size: 28rpx;
color: #f56c6c;
line-height: 1.5;
}
.print-fail-popup-footer {
display: flex;
align-items: center;
justify-content: space-between;
}
.print-fail-footer-btn {
flex: 1;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 10rpx;
font-size: 30rpx;
}
.print-fail-footer-btn--cancel {
margin-right: 20rpx;
background: #f5f5f5;
color: #606266;
}
.print-fail-footer-btn--print {
background: #2979ff;
color: #ffffff;
}
/* 设置弹窗 */
.settings-popup {
width: 560rpx;