zm2000 27f4d178aa feat(拣货/复核/打包): 新增拣货要求与复核要求展示、语音播报及样式优化
- 拣货页:新增拣货要求横幅与弹窗展示,兼容 pick_mode 5 与 2/3/4 两种字段来源;
  显示哪个商品即播报该商品拣货要求,去重串行、只播一次;弹窗样式优化
- 复核发货页:进入详情去重串行播报复核要求,「数据一致」排队到复核要求播报完成后;
  复核要求字段优先取 recheck_requirements
- 复核详情组件:「包装」改为「复核要求」,要求行改浅红底标签,字号调大;
  「数据一致」改为事件上抛由父组件排队播报
- 打包模式页:新增打包要求标签展示与语音播报(去重串行、数据一致排队播报);
  扫描重复跳过增加失败态豁免;重查失败恢复待重传状态;映射补充 packing_requirements
2026-09-30 18:41:57 +08:00

1725 lines
46 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="review-detail">
<!-- 空状态 -->
<view v-if="goodsList.length === 0" class="empty-state">
<u-icon name="list" size="86" color="#c0c4cc"></u-icon>
<text class="empty-text">暂无拣货商品</text>
</view>
<!-- 商品详情 -->
<view v-else class="content-layout">
<!-- 订单信息行 -->
<view class="order-info-row">
<view class="order-info-left">
<text class="order-info-text" v-if="detailInfo.listType === 'group'">波次:{{ detailInfo.waveNo || '--' }}</text>
<text class="order-info-text" v-else-if="detailInfo.waybillNo && detailInfo.waybillNo !== '--'">运单:{{ detailInfo.waybillNo }}</text>
<text class="order-info-text" v-else>波次:{{ detailInfo.waveNo }}</text>
<text class="order-info-divider"></text>
<text class="order-info-text">{{ detailInfo.pickerName }}</text>
</view>
<view class="order-info-right">
<view class="reprint-btn" @click="$emit('reprint')">面单补打</view>
</view>
</view>
<view v-if="detailInfo.storeName && detailInfo.listType !== 'group'" class="store-info-row">
<!-- 单品单件(pick_mode=2)不显示篮号;散单分播(pick_mode=3)时蓝号在商品列表蓝号列展示 -->
<template v-if="Number(pickMode) !== 3 && Number(pickMode) !== 2">
<text class="store-info-text">篮号:{{ detailInfo.waveIndex || detailInfo.boxNo || '--' }}</text>
<text class="store-info-divider"></text>
</template>
<text class="store-info-text">货主:{{ detailInfo.storeName }}</text>
</view>
<view v-if="detailInfo.listType === 'group'" class="wave-info-row">
<text class="wave-info-text">订单数:{{ detailInfo.totalOrders || '--' }}</text>
<text class="wave-info-divider"></text>
<text class="wave-info-text">篮号:{{ detailInfo.waveIndex || detailInfo.boxNo || '--' }}</text>
<text class="wave-info-divider"></text>
<text class="wave-info-text">货主:{{ detailInfo.storeName || '--' }}</text>
</view>
<!-- 推荐包材提示 -->
<view v-if="detailInfo.listType === 'group' && detailInfo.suggestedPkg" class="package-info-hint">
<text class="package-info-label">推荐包材:</text>
<text class="package-info-value">{{ detailInfo.suggestedPkg.name }}</text>
</view>
<view class="bottom-module">
<view class="pick-list-scroll">
<!-- 宫格模式 -->
<view v-if="viewMode === 'grid'" class="pick-list pick-list--grid">
<view
v-for="(item, index) in goodsList"
:key="item.id"
class="pick-item-wrap"
@click="selectGoods(index)"
>
<view
class="metric-card-btn"
:class="{
'metric-card-btn--active': index === currentGoodsIndex,
'metric-card-btn--matched': isGoodsMatched(item)
}"
>
<view class="order-corner"></view>
<view class="metric-diagonal"></view>
<text class="metric-order">{{ showBoxNoColumn ? (item.boxNo || '--') : (item.lineNo || 0) }}</text>
<text class="metric-product">{{ item.planQty || 0 }}</text>
<text class="metric-scanned">{{ item.scannedQty || 0 }}</text>
</view>
<view v-if="item.packageRequirement && item.packageRequirement !== '--'" class="goods-pack-row goods-pack-row--grid">
<text class="goods-pack-label">复核要求:</text>
<text class="goods-pack-value">{{ item.packageRequirement }}</text>
</view>
</view>
</view>
<!-- 列表模式 -->
<view v-else class="pick-list pick-list--table">
<view
v-for="(item, index) in goodsList"
:key="item.id"
class="list-card-row"
:class="{
'list-card-row--active': index === currentGoodsIndex,
'list-card-row--matched': isGoodsMatched(item)
}"
@click="selectGoods(index)"
@longpress="handleListLongPress(item, index)"
>
<view class="list-card-row__top">
<view class="list-card-qty-group">
<view v-if="showBoxNoColumn" class="list-card-qty-item">
<text class="list-card-label">篮号</text>
<text class="list-card-value">{{ item.boxNo || '--' }}</text>
</view>
<view class="list-card-qty-item">
<text class="list-card-label">数量</text>
<text class="list-card-value">{{ item.planQty || 0 }}</text>
</view>
<view class="list-card-qty-item">
<text class="list-card-label">已扫</text>
<text class="list-card-value" :class="{ 'list-card-value--done': (item.scannedQty || 0) >= (item.planQty || 0) }">{{ item.scannedQty || 0 }}</text>
</view>
</view>
<view class="list-card-image-wrap" @click.stop="previewListGoodsImage(item)">
<u-image
:key="'goods-img-' + index + '-' + (item.imageUrl || 'noimg')"
class="list-card-image"
:src="item.imageUrl || ''"
mode="aspectFill"
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>
</view>
</template>
</u-image>
</view>
</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">{{ item.barcode || '--' }}</text>
<text class="list-card-space">{{'、'}}</text>
<text class="list-card-tag">{{ item.location || '--' }}</text>
</view>
<view v-if="item.packageRequirement && item.packageRequirement !== '--'" class="goods-pack-row">
<text class="goods-pack-label">复核要求:</text>
<text class="goods-pack-value">{{ item.packageRequirement }}</text>
</view>
</view>
</view>
</view>
<view class="safe-area-bottom"></view>
</view>
</view>
<!-- 底部合计 -->
<view class="bottom-summary">
<text class="bottom-summary-text">合计:<text class="bottom-summary-value">{{ totalPlanQty }}</text></text>
<text class="bottom-summary-scan">已扫:<text class="bottom-summary-value">{{ totalScannedQty }}</text><text class="bottom-summary-split">/</text><text class="bottom-summary-total">{{ totalPlanQty }}</text>件</text>
<view v-if="canConfirmRecheck && !autoShip" class="confirm-btn" @click="$emit('confirmRecheck')">确认复核</view>
<view class="view-mode-toggle" @click="toggleViewMode">
<u-icon :name="viewMode === 'grid' ? 'list' : 'grid'" size="24" color="#2979ff"></u-icon>
<text class="view-mode-text">{{ viewMode === 'grid' ? '列表' : '宫格' }}</text>
</view>
</view>
<!-- 多商品匹配弹窗 -->
<u-popup v-if="showMultiMatchPopup" :show="showMultiMatchPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10100" @close="handleMultiMatchClose">
<view class="multi-match-popup">
<view class="multi-match-popup-title">库内有相同商品</view>
<view class="multi-match-popup-body">
<view class="multi-match-card" @click="handleMultiMatchSelect()">
<view class="multi-match-thumb">
<u-image
:key="'multi-match-img-' + (multiMatchFirst.imageUrl || 'noimg')"
class="multi-match-image"
:src="multiMatchFirst.imageUrl || ''"
mode="aspectFill"
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>
</view>
</template>
</u-image>
</view>
<view class="multi-match-info">
<text class="multi-match-name">{{ multiMatchFirst.skuName || '--' }}</text>
<text class="multi-match-barcode">条码:{{ multiMatchFirst.barcode || '--' }}</text>
<text class="multi-match-spec">规格:{{ multiMatchFirst.location || '--' }}</text>
<text class="multi-match-qty">计划 {{ multiMatchFirst.planQty || 0 }} / 已扫 {{ multiMatchFirst.scannedQty || 0 }}</text>
</view>
</view>
</view>
<view class="multi-match-popup-footer">
<view class="multi-match-footer-btn" @click="handleMultiMatchClose">关闭</view>
</view>
</view>
</u-popup>
<!-- 无条码复核弹窗 -->
<u-popup v-if="showNoBarcodePopup" :show="showNoBarcodePopup" mode="center" :closeable="true" :closeOnClickOverlay="false" border-radius="20" @close="showNoBarcodePopup = false">
<view class="no-barcode-popup">
<view class="no-barcode-popup__title">无条码复核</view>
<view class="no-barcode-popup__body">
<text class="no-barcode-popup__text">
将商品「{{ noBarcodeItemName }}」标记为已复核({{ noBarcodePickedCount }}/{{ noBarcodeItemTotalQty }} → {{ noBarcodeItemTotalQty }}/{{ noBarcodeItemTotalQty }})?
</text>
</view>
<view class="no-barcode-popup__actions">
<view class="no-barcode-popup__btn no-barcode-popup__btn--cancel" @click="showNoBarcodePopup = false">取消</view>
<view class="no-barcode-popup__btn no-barcode-popup__btn--confirm" @click="confirmNoBarcodeReview">确定</view>
</view>
</view>
</u-popup>
<!-- 拦截信息弹窗 -->
<u-popup v-if="showInterceptInfoPopup" :show="showInterceptInfoPopup" mode="bottom" :closeable="false" :closeOnClickOverlay="false" border-radius="20" @close="showInterceptInfoPopup = false">
<view class="intercept-info-popup">
<view class="intercept-info-popup__header">
<text class="intercept-info-popup__title">拦截信息</text>
</view>
<view class="intercept-info-popup__body">
<template v-if="isWaveInterceptList">
<view class="intercept-info-popup__row">
<text class="intercept-info-popup__label">波次号</text>
<text class="intercept-info-popup__value">{{ detailInfo.waveNo || '--' }}</text>
</view>
<view class="intercept-info-popup__tip intercept-info-popup__tip--first">该波次以下订单已被拦截,请勿复核发货</view>
<view v-for="(o, idx) in detailInfo.interceptList" :key="idx" class="intercept-info-popup__row">
<text class="intercept-info-popup__label">运单号</text>
<text class="intercept-info-popup__value">{{ interceptWaybill(o) }}</text>
</view>
</template>
<template v-else>
<view class="intercept-info-popup__row">
<text class="intercept-info-popup__label">运单号</text>
<text class="intercept-info-popup__value">{{ detailInfo.waybillNo || '--' }}</text>
</view>
<view class="intercept-info-popup__tip">该订单已被拦截,请勿复核发货</view>
</template>
</view>
<view class="intercept-info-popup__footer">
<view class="intercept-info-popup__btn" @click="showInterceptInfoPopup = false">关闭</view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import voice from '@/core/utils/voice';
export default {
name: 'ReviewDetail',
created() {
console.log('[ReviewDetail] created');
},
mounted() {
console.log('[ReviewDetail] mounted, goodsList length:', this.goodsList?.length);
},
props: {
goodsList: {
type: Array,
default: () => []
},
scanQty: {
type: Number,
default: 1
},
autoShip: {
type: Boolean,
default: false
},
detailInfo: {
type: Object,
default: () => ({
recordId: '',
orderId: 0,
waveId: '',
waveNo: '--',
waybillNo: '',
matchType: '',
recheckStatus: '',
pickerName: '--',
cartNo: '--',
status: 'pending',
unreviewedCount: 0,
storeRemark: '',
storeName: '',
waveIndex: '',
orderIds: [],
interceptStatus: '',
interceptList: [],
printStationId: '',
printStationName: '',
boxNo: ''
})
},
scannedPackageMaterial: {
type: Object,
default: null
},
pickMode: {
type: [Number, String],
default: ''
}
},
data() {
// 读取本地存储的视图模式,默认列表模式
let savedMode = 'list';
try {
const stored = uni.getStorageSync('review_view_mode');
if (stored === 'grid' || stored === 'list') {
savedMode = stored;
}
} catch (e) {
// 忽略读取失败
}
return {
currentGoodsIndex: 0,
matchedGoodsId: '',
matchedGoodsState: {},
viewMode: savedMode,
showMultiMatchPopup: false,
multiMatchFirst: {},
multiMatchGoodsIndex: -1,
pendingScanCode: '',
dismissedMultiMatchCodes: [],
lastScanCode: '',
lastScanTime: 0,
showNoBarcodePopup: false,
noBarcodeItemName: '',
noBarcodePickedCount: 0,
noBarcodeItemTotalQty: 0,
showInterceptInfoPopup: false,
// 单品单件自动复核场景弹窗确认回调(弹窗关闭/确认后调用,继续自动复核发货)
sharedBarcodeOnClose: null
};
},
computed: {
currentGoods() {
return this.goodsList[this.currentGoodsIndex] || {};
},
isCurrentBarcodeMatched() {
const currentId = String(this.currentGoods?.id || '');
if (!currentId) return false;
return !!this.matchedGoodsState[currentId];
},
totalPlanQty() {
return this.goodsList.reduce((sum, item) => sum + (item.planQty || 0), 0);
},
totalScannedQty() {
return this.goodsList.reduce((sum, item) => sum + (this.isNoRecheck(item) ? (item.planQty || 0) : (item.scannedQty || 0)), 0);
},
isReadOnly() {
return String(this.detailInfo?.recheckStatus || '').toLowerCase() === 'fin';
},
showBoxNoColumn() {
// 散单模式 pick_mode=3 时显示蓝号列,顺序为 蓝号、数量、已扫
// 以 pick_mode 为准(pick_mode=3 即散单模式),避免依赖 listType 取值差异
return Number(this.pickMode) === 3;
},
isScannedComplete() {
// 无需复核商品(need_recheck=N)视为已扫完成
if (this.isNoRecheck(this.currentGoods)) return true;
const plan = Number(this.currentGoods?.planQty || 0);
const scanned = Number(this.currentGoods?.scannedQty || 0);
return plan > 0 && scanned >= plan;
},
isAllMatched() {
return this.goodsList.every(item => {
// 无需复核商品(need_recheck=N,如虚拟赠品)视为已匹配
if (this.isNoRecheck(item)) return true;
const id = String(item?.id || '');
if (!id) return false;
return !!this.matchedGoodsState[id];
});
},
isAllScanned() {
return this.goodsList.every(item => this.isNoRecheck(item) || (item.scannedQty || 0) >= (item.planQty || 0));
},
canConfirmRecheck() {
return this.isAllMatched && this.isAllScanned;
},
isIntercepted() {
// 散单模式:波次内任一订单被拦截即显示拦截信息按钮(waveHasIntercept)
// 其它模式:直接看当前订单/波次的拦截状态
if (!!this.detailInfo?.waveHasIntercept) return true;
const status = String(this.detailInfo?.interceptStatus || '').trim();
return !!status && status !== 'none';
},
isWaveInterceptList() {
const listType = String(this.detailInfo?.listType || '').trim();
// 散单/团单模式:波次内存在被拦截订单时,弹窗以列表形式展示波次内所有被拦截订单
return (listType === 'single' || listType === 'group') &&
Array.isArray(this.detailInfo?.interceptList) &&
this.detailInfo.interceptList.length > 0;
}
},
watch: {
goodsList: {
handler(newList, oldList) {
// 切换订单时重置匹配状态,防止残留
if (oldList && oldList.length > 0 && newList !== oldList) {
this.resetMatchState();
}
const total = this.totalPlanQty;
const scanned = this.totalScannedQty;
// 全部为"无需复核"商品(need_recheck=N)时不在此触发 allScanned:
// 此类订单商品初始即"已扫满",切换订单/进入详情时 goodsList 变化会误触发,
// 导致自动模式跳过"点击商品卡片核对"直接连续自动发货。
// 该场景改由父组件 handleGoodsItemClick(点击商品卡片)触发发货。
const allNoRecheck = this.goodsList.length > 0 && this.goodsList.every(item => this.isNoRecheck(item));
if (total > 0 && scanned >= total && !allNoRecheck) {
this.$emit('allScanned');
}
},
deep: true
},
currentGoodsIndex(val) {
this.$emit('currentGoodsChange', val);
}
},
methods: {
openInterceptInfo() {
// 由订单复核页面导航栏标题左侧的拦截信息按钮触发打开
this.showInterceptInfoPopup = true;
},
interceptWaybill(o) {
// 安全获取拦截订单的运单号(模板中不支持可选链写法)
const waybill = String((o && (o.firstWaybillNo || o.waybillNo)) || '').trim();
// 团购模式:运单号-总订单数-波次索引(data.list[x].intercepted[x].wave_index)
if (String(this.detailInfo?.listType || '').trim() === 'group') {
const totalOrders = Number(o?.totalOrders ?? this.detailInfo?.totalOrders ?? 0);
const waveIndex = String(o?.waveIndex ?? '').trim();
const parts = [waybill || '--'];
parts.push(totalOrders > 0 ? String(totalOrders) : '--');
parts.push(waveIndex || '--');
return parts.join('-');
}
return waybill || '--';
},
isNoRecheck(item) {
// 无需复核商品(need_recheck=N,如虚拟赠品):视为已扫
return String((item && item.need_recheck) || '').trim().toUpperCase() === 'N';
},
isGoodsMatched(item) {
// 无需复核商品(need_recheck=N)直接视为已匹配/已扫
if (this.isNoRecheck(item)) return true;
const id = String(item?.id || '');
if (!id) return false;
return !!this.matchedGoodsState[id];
},
normalizeBarcode(value) {
return String(value || '').replace(/\s+/g, '').toUpperCase();
},
extractBarcodeCandidates(item) {
const sourceList = [item?.barcode, item?.skuCode];
const result = [];
sourceList.forEach(source => {
const text = String(source || '').trim();
if (!text) return;
text
.split(/[;,,|\s]+/)
.map(part => this.normalizeBarcode(part))
.filter(part => !!part)
.forEach(part => {
result.push(part);
// 包含汉字时,额外添加去除汉字后的部分作为候选
if (/[\u4e00-\u9fff]/.test(part)) {
const stripped = part.replace(/[\u4e00-\u9fff]+/g, '');
if (stripped) result.push(stripped);
}
});
});
return Array.from(new Set(result));
},
/**
* 外部调用:处理扫描到的条码
* @param {string} scanCode - 扫描结果
* @returns {boolean} 是否匹配成功
*/
handleScanCode(scanCode) {
// 已复核订单只读,不做商品匹配
if (this.isReadOnly) return false;
const code = this.normalizeBarcode(scanCode);
if (!code) return false;
// 基于时间的去重:300ms 内相同条码跳过,防止广播重复触发导致弹窗多次
const now = Date.now();
const elapsed = now - this.lastScanTime;
if (code === this.lastScanCode && elapsed < 300) {
console.log('[ReviewDetail][handleScanCode] 去重拦截,相同条码:', code, '间隔(ms):', elapsed);
return true;
}
this.lastScanCode = code;
this.lastScanTime = now;
// 多商品匹配弹窗已打开且扫描相同条码时,跳过避免重复提示
if (this.showMultiMatchPopup && this.pendingScanCode === code) {
return true;
}
// 查找所有匹配的商品
const matchIndices = [];
this.goodsList.forEach((item, idx) => {
const candidates = this.extractBarcodeCandidates(item);
if (candidates.includes(code)) {
matchIndices.push(idx);
}
});
if (matchIndices.length === 0) {
voice.speak('无记录');
return false;
}
// 命中行中存在 has_shared_barcode(库内存在共享同一条码的其他商品)时,弹出底部抽屉提示
const sharedIdx = matchIndices.find(idx => this.goodsList[idx]?.has_shared_barcode);
if (sharedIdx !== undefined) {
// 如果用户之前关闭过该条码的弹窗,不再弹出,自动分配到未扫完的共享条码商品
if (this.dismissedMultiMatchCodes.includes(code)) {
// 优先找共享条码商品中第一个未扫完的,否则找任意匹配商品中第一个未扫完的
let matchIndex = -1;
for (let i = 0; i < matchIndices.length; i++) {
const idx = matchIndices[i];
const item = this.goodsList[idx];
if (item?.has_shared_barcode && (item?.scannedQty || 0) < (item?.planQty || 0)) {
matchIndex = idx;
break;
}
}
if (matchIndex === -1) {
for (let i = 0; i < matchIndices.length; i++) {
const idx = matchIndices[i];
const item = this.goodsList[idx];
if ((item?.scannedQty || 0) < (item?.planQty || 0)) {
matchIndex = idx;
break;
}
}
}
if (matchIndex === -1) {
uni.showToast({ title: '所有匹配商品已复核完成', icon: 'none' });
voice.speak('超出订单数');
return true;
}
this.currentGoodsIndex = matchIndex;
const matchedItem = this.goodsList[matchIndex];
const maxQty = matchedItem?.planQty || 0;
const currentScanned = matchedItem?.scannedQty || 0;
const addQty = Math.min(this.scanQty || 1, maxQty - currentScanned);
const newScanned = Math.min(currentScanned + addQty, maxQty);
// 扫描数量超过剩余数量时语音提示
if ((this.scanQty || 1) > (maxQty - currentScanned)) {
voice.speak('超出订单数');
}
this.$emit('updateScannedQty', matchIndex, newScanned);
// 扫码匹配成功即播报"数据一致"(排队到复核要求播报完成后)
this.$emit('speakDataConsistent');
// 已扫数量达到计划数量时,标记为已匹配(显示绿底和"已匹配"状态)
if (newScanned >= maxQty) {
const matchedId = String(matchedItem?.id || '');
if (matchedId) {
this.matchedGoodsId = matchedId;
if (typeof this.$set === 'function') {
this.$set(this.matchedGoodsState, matchedId, true);
} else {
this.matchedGoodsState[matchedId] = true;
}
}
}
if ((this.scanQty || 1) > 1) {
this.$emit('resetScanQty');
}
return true;
}
this.multiMatchFirst = { ...this.goodsList[sharedIdx] };
this.multiMatchGoodsIndex = sharedIdx;
this.pendingScanCode = code;
this.showMultiMatchPopup = true;
voice.speak('库内有相同商品');
return true;
}
// 无共享条码商品,直接处理第一个匹配商品
const matchIndex = matchIndices[0];
this.currentGoodsIndex = matchIndex;
const matchedItem = this.goodsList[matchIndex];
const maxQty = matchedItem?.planQty || 0;
const currentScanned = matchedItem?.scannedQty || 0;
// 已复核完成的商品,不再增加数量
if (currentScanned >= maxQty) {
// 无需复核商品(need_recheck=N)提示"无需复核",避免与实际已复核订单混淆
const msg = this.isNoRecheck(matchedItem) ? '该商品无需复核' : '该商品已复核完成';
uni.showToast({ title: msg, icon: 'none' });
voice.speak('超出订单数');
return true;
}
const addQty = Math.min(this.scanQty || 1, maxQty - currentScanned);
const newScanned = Math.min(currentScanned + addQty, maxQty);
// 扫描数量超过剩余数量时语音提示
if ((this.scanQty || 1) > (maxQty - currentScanned)) {
voice.speak('超出订单数');
}
// 更新已扫数量
this.$emit('updateScannedQty', matchIndex, newScanned);
// 扫码匹配成功即播报"数据一致"(排队到复核要求播报完成后)
this.$emit('speakDataConsistent');
// 已扫数量达到计划数量时,才标记为已匹配
if (newScanned >= maxQty) {
const matchedId = String(matchedItem?.id || '');
if (matchedId) {
this.matchedGoodsId = matchedId;
if (typeof this.$set === 'function') {
this.$set(this.matchedGoodsState, matchedId, true);
} else {
this.matchedGoodsState[matchedId] = true;
}
}
}
// 设置的数量>1时,使用后回归1(一次性)
if ((this.scanQty || 1) > 1) {
this.$emit('resetScanQty');
}
return true;
},
/**
* 无条码复核(点击条码区域触发)
*/
handleBarcodeClick() {
const item = this.currentGoods;
if (!item) return;
// 无需复核商品(need_recheck=N):无需扫码/无条码复核,提示"无需复核"而非"已复核完成"
if (this.isNoRecheck(item)) {
uni.showToast({ title: '该商品无需复核', icon: 'none' });
return;
}
const skuName = item.skuName || '商品';
const planQty = item.planQty || 0;
const scannedQty = item.scannedQty || 0;
if (scannedQty >= planQty) {
uni.showToast({ title: '该商品已复核完成', icon: 'none' });
return;
}
// 设置弹窗数据
this.noBarcodeItemName = skuName;
this.noBarcodePickedCount = scannedQty;
this.noBarcodeItemTotalQty = planQty;
this.showNoBarcodePopup = true;
},
confirmNoBarcodeReview() {
const item = this.currentGoods;
if (!item) return;
const planQty = item.planQty || 0;
this.showNoBarcodePopup = false;
this.$emit('updateScannedQty', this.currentGoodsIndex, planQty);
const matchId = String(item.id || '');
if (matchId) {
this.matchedGoodsId = matchId;
if (typeof this.$set === 'function') {
this.$set(this.matchedGoodsState, matchId, true);
} else {
this.matchedGoodsState[matchId] = true;
}
}
// 标记当前商品条码匹配
this.$emit('barcodeMatched', matchId);
uni.showToast({ title: `已标记为已复核(${planQty}/${planQty})`, icon: 'success' });
this.$emit('speakDataConsistent');
},
handleListLongPress(item, index) {
if (this.isReadOnly) return;
this.currentGoodsIndex = index;
this.openNoBarcodePopup(item);
},
openNoBarcodePopup(item) {
if (!item) return;
// 无需复核商品(need_recheck=N,如虚拟赠品):无需扫码/无条码复核,
// 提示"无需复核"而非"已复核完成",避免与真实已复核订单混淆
if (this.isNoRecheck(item)) {
uni.showToast({ title: '该商品无需复核', icon: 'none' });
return;
}
const skuName = item.skuName || '商品';
const planQty = item.planQty || 0;
const scannedQty = item.scannedQty || 0;
if (scannedQty >= planQty) {
uni.showToast({ title: '该商品已复核完成', icon: 'none' });
return;
}
this.noBarcodeItemName = skuName;
this.noBarcodePickedCount = scannedQty;
this.noBarcodeItemTotalQty = planQty;
this.showNoBarcodePopup = true;
},
previewListGoodsImage(item) {
const list = Array.isArray(item?.images) ? item.images : [];
const normalizedList = list
.map(url => String(url || '').trim())
.filter(url => !!url);
const currentUrl = String(item?.imageUrl || '').trim();
const images = normalizedList.length ? normalizedList : (currentUrl ? [currentUrl] : []);
if (!images.length) return;
uni.previewImage({
current: images[0],
urls: images
});
},
previewCurrentGoodsImage() {
const images = this.getCurrentGoodsImageList();
if (!images.length) return;
uni.previewImage({
current: images[0],
urls: images
});
},
getCurrentGoodsImageList() {
const list = Array.isArray(this.currentGoods?.images) ? this.currentGoods.images : [];
const normalizedList = list
.map(url => String(url || '').trim())
.filter(url => !!url);
const currentUrl = String(this.currentGoods?.imageUrl || '').trim();
if (!normalizedList.length && currentUrl) {
return [currentUrl];
}
return normalizedList;
},
selectGoods(index) {
this.currentGoodsIndex = index;
this.$emit('goodsItemClick');
},
toggleViewMode() {
this.viewMode = this.viewMode === 'grid' ? 'list' : 'grid';
try {
uni.setStorageSync('review_view_mode', this.viewMode);
} catch (e) {
console.warn('[ReviewDetail] 保存视图模式失败:', e);
}
this.$emit('viewModeChange', this.viewMode);
},
/**
* 标记条码匹配成功
*/
markBarcodeMatched(itemId) {
const id = String(itemId || '');
if (!id) return;
if (typeof this.$set === 'function') {
this.$set(this.matchedGoodsState, id, true);
} else {
this.matchedGoodsState[id] = true;
}
},
/**
* 重置匹配状态(切换订单时调用)
*/
resetMatchState() {
this.matchedGoodsState = {};
this.matchedGoodsId = '';
this.currentGoodsIndex = 0;
this.showMultiMatchPopup = false;
this.multiMatchFirst = {};
this.multiMatchGoodsIndex = -1;
this.pendingScanCode = '';
this.dismissedMultiMatchCodes = [];
this.lastScanCode = '';
this.lastScanTime = 0;
this.sharedBarcodeOnClose = null;
},
/**
* 外部调用:单品单件 D 前缀波次自动复核场景,库内有相同商品时弹出确认弹窗
* 用户关闭/确认后执行 onConfirm 回调,继续自动复核发货
*/
showSharedBarcodePopup(item, onConfirm) {
this.sharedBarcodeOnClose = typeof onConfirm === 'function' ? onConfirm : null;
this.multiMatchFirst = item && typeof item === 'object' ? { ...item } : {};
this.multiMatchGoodsIndex = -1;
if (item && typeof item === 'object') {
const idx = this.goodsList.findIndex(g => String(g?.id || '') === String(item.id || ''));
if (idx >= 0) this.multiMatchGoodsIndex = idx;
}
this.pendingScanCode = '';
this.showMultiMatchPopup = true;
voice.speak('库内有相同商品');
},
/**
* 多商品匹配时,选择第一个商品进行处理
*/
handleMultiMatchClose() {
this.showMultiMatchPopup = false;
this.multiMatchGoodsIndex = -1;
// 将当前条码加入已忽略列表,关闭后不再弹窗提示
if (this.pendingScanCode && !this.dismissedMultiMatchCodes.includes(this.pendingScanCode)) {
this.dismissedMultiMatchCodes.push(this.pendingScanCode);
}
this.pendingScanCode = '';
// 自动复核场景:弹窗关闭后执行确认回调,继续自动复核发货
const cb = this.sharedBarcodeOnClose;
this.sharedBarcodeOnClose = null;
if (cb) cb();
},
handleMultiMatchSelect(index) {
this.showMultiMatchPopup = false;
// 自动复核场景(单品单件 D 前缀波次):仅确认弹窗,不追加数量,直接继续自动复核发货
if (this.sharedBarcodeOnClose) {
const cb = this.sharedBarcodeOnClose;
this.sharedBarcodeOnClose = null;
this.pendingScanCode = '';
this.multiMatchGoodsIndex = -1;
if (cb) cb();
return;
}
const code = this.pendingScanCode;
this.pendingScanCode = '';
if (!code) return;
// 定位弹窗对应的共享条码商品(无参数时使用弹窗打开时记录的行)
const targetIdx = (typeof index === 'number' && index >= 0) ? index : this.multiMatchGoodsIndex;
this.multiMatchGoodsIndex = -1;
if (targetIdx === undefined || targetIdx < 0 || !this.goodsList[targetIdx]) return;
this.currentGoodsIndex = targetIdx;
const matchedItem = this.goodsList[targetIdx];
const maxQty = matchedItem?.planQty || 0;
const currentScanned = matchedItem?.scannedQty || 0;
if (currentScanned >= maxQty) {
uni.showToast({ title: '该商品已复核完成', icon: 'none' });
return;
}
const addQty = Math.min(this.scanQty || 1, maxQty - currentScanned);
const newScanned = Math.min(currentScanned + addQty, maxQty);
this.$emit('updateScannedQty', targetIdx, newScanned);
// 扫码匹配成功即播报"数据一致"(排队到复核要求播报完成后)
this.$emit('speakDataConsistent');
if (newScanned >= maxQty) {
const matchedId = String(matchedItem?.id || '');
if (matchedId) {
this.matchedGoodsId = matchedId;
if (typeof this.$set === 'function') {
this.$set(this.matchedGoodsState, matchedId, true);
} else {
this.matchedGoodsState[matchedId] = true;
}
}
}
if ((this.scanQty || 1) > 1) {
this.$emit('resetScanQty');
}
}
}
};
</script>
<style lang="scss" scoped>
.review-detail {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
overflow: hidden;
position: relative;
}
/* u-popup 根元素默认带 flex:1(uview 全局样式),会参与本组件 flex 布局并与商品列表区平分空间,
导致弹窗(v-if 渲染)弹出时底部合计行被顶到页面中间。这里让弹窗不参与 flex 分配(其内容为 fixed 定位,高度为 0,不占文档流)。 */
::v-deep .u-popup {
flex: none !important;
}
.content-layout {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
overflow: hidden;
}
.info-row {
display: flex;
align-items: center;
font-size: 28rpx;
line-height: 32rpx;
}
.info-label {
color: #909399;
flex-shrink: 0;
width: 60rpx;
}
.info-value {
color: #303133;
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.info-row--barcode-highlight .info-value {
color: #2979ff;
font-weight: 500;
}
.info-value--warn {
color: #07c160;
font-weight: 500;
}
.box-no-suffix {
color: #e6a23c;
margin-left: 6rpx;
font-size: 26rpx;
}
.order-info-row {
display: flex;
align-items: center;
justify-content: space-between;
margin: 8rpx 16rpx 0;
padding: 12rpx 16rpx;
background: #ffffff;
border-radius: 10rpx;
border: 1rpx solid #ebeef5;
}
.order-info-left {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
}
.order-info-text {
font-size: 28rpx;
color: #000000;
white-space: nowrap;
}
.order-info-divider {
width: 1rpx;
height: 20rpx;
background: #dcdfe6;
margin: 0 24rpx;
flex-shrink: 0;
}
.wave-info-row {
display: flex;
align-items: center;
gap: 12rpx;
margin: 0 16rpx;
padding: 8rpx 16rpx;
background: #f5f7fa;
border-radius: 6rpx;
font-size: 26rpx;
}
.wave-info-text {
color: #000000;
font-size: 26rpx;
}
.store-info-row {
display: flex;
align-items: center;
margin: 0 16rpx;
padding: 6rpx 16rpx;
background: #f5f7fa;
border-radius: 6rpx;
}
.store-info-text {
font-size: 26rpx;
color: #000000;
}
.store-info-divider {
width: 1rpx;
height: 20rpx;
background: #dcdfe6;
margin: 0 24rpx;
flex-shrink: 0;
}
.wave-info-divider {
width: 1rpx;
height: 18rpx;
background: #dcdfe6;
flex-shrink: 0;
}
.order-info-right {
flex-shrink: 0;
}
.reprint-btn {
padding: 4rpx 16rpx;
border: 1rpx solid #2979ff;
border-radius: 6rpx;
font-size: 26rpx;
color: #2979ff;
line-height: 1.6;
}
.reprint-btn:active {
opacity: 0.7;
}
.name-barcode-row {
gap: 12rpx;
margin-bottom: 2rpx;
}
.name-barcode-row .goods-name--compact {
flex: 1;
min-width: 0;
word-break: break-all;
}
.barcode-tag {
flex-shrink: 0;
font-size: 26rpx;
color: #000000;
background: #f0f7ff;
border: 1rpx solid #b3d8ff;
border-radius: 6rpx;
padding: 2rpx 10rpx;
line-height: 1.6;
max-width: 240rpx;
word-break: break-all;
}
.barcode-tag--matched {
color: #07c160;
background: #f0fff5;
border-color: #b3ebc1;
}
.bottom-module {
flex: 1;
min-height: 0;
padding: 8rpx 16rpx 0;
box-sizing: border-box;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.pick-list-scroll {
min-height: 0;
}
.pick-list {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
}
.pick-item-wrap {
flex: 0 0 auto;
}
.metric-card-btn {
position: relative;
width: 96rpx;
height: 96rpx;
border: 2rpx solid #dcdfe6;
border-radius: 10rpx;
background: #fafafa;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2rpx;
overflow: hidden;
}
.metric-card-btn--active {
border-color: #2979ff;
background: #f0f7ff;
}
.metric-card-btn--matched {
border-color: #07c160;
background: #07c160;
}
.metric-card-btn--matched .metric-order,
.metric-card-btn--matched .metric-product,
.metric-card-btn--matched .metric-scanned {
color: #ffffff;
}
.order-corner {
display: none;
}
.metric-diagonal {
display: none;
}
.metric-order {
font-size: 32rpx;
font-weight: 600;
color: #2979ff;
line-height: 1.2;
}
.metric-card-btn--matched .metric-order {
color: #ffffff;
}
.metric-product {
font-size: 20rpx;
color: #909399;
line-height: 1.2;
}
.metric-scanned {
font-size: 20rpx;
color: #e6a23c;
line-height: 1.2;
}
.metric-card-btn--matched .metric-scanned {
color: #ffffff;
}
.bottom-summary {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 6rpx 24rpx;
padding-bottom: calc(6rpx + env(safe-area-inset-bottom));
background: #ffffff;
border-top: 1rpx solid #ebeef5;
}
.bottom-summary-text {
font-size: 34rpx;
color: #909399;
flex-shrink: 0;
}
.bottom-summary-value {
color: #303133;
font-weight: 500;
margin-left: 4rpx;
}
.bottom-summary-scan {
font-size: 32rpx;
color: #909399;
flex-shrink: 0;
}
.bottom-summary-split {
color: #c0c4cc;
margin: 0 4rpx;
}
.bottom-summary-total {
color: #303133;
font-weight: 500;
}
.confirm-btn {
flex-shrink: 0;
padding: 8rpx 24rpx;
background: #2979ff;
border-radius: 8rpx;
font-size: 32rpx;
color: #ffffff;
font-weight: 500;
line-height: 1.4;
}
.confirm-btn:active {
opacity: 0.7;
}
.view-mode-toggle {
display: flex;
align-items: center;
gap: 2rpx;
padding: 2rpx 6rpx;
border: 1rpx solid #2979ff;
border-radius: 6rpx;
flex-shrink: 0;
}
.view-mode-toggle:active {
opacity: 0.7;
}
.view-mode-text {
font-size: 18rpx;
color: #2979ff;
}
.intercept-info-btn {
display: flex;
align-items: center;
padding: 4rpx 16rpx;
border: 1rpx solid #fa3534;
border-radius: 6rpx;
background: #fef0f0;
flex-shrink: 0;
}
.intercept-info-btn:active {
opacity: 0.7;
}
.intercept-info-btn__text {
font-size: 26rpx;
color: #fa3534;
line-height: 1.6;
}
.intercept-info-btn--row {
margin-left: auto;
}
.intercept-info-popup {
background: #ffffff;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
padding-bottom: env(safe-area-inset-bottom);
}
.intercept-info-popup__header {
display: flex;
align-items: center;
justify-content: center;
padding: 24rpx 32rpx;
border-bottom: 1rpx solid #f2f3f5;
}
.intercept-info-popup__title {
font-size: 38rpx;
font-weight: 600;
color: #303133;
text-align: center;
}
.intercept-info-popup__body {
padding: 24rpx 32rpx;
}
.intercept-info-popup__row {
display: flex;
align-items: center;
padding: 12rpx 0;
}
.intercept-info-popup__label {
width: 160rpx;
font-size: 30rpx;
color: #000000;
}
.intercept-info-popup__value {
flex: 1;
font-size: 36rpx;
color: #303133;
word-break: break-all;
}
.intercept-info-popup__tip {
margin-top: 20rpx;
padding: 16rpx;
background: #fef0f0;
border-radius: 8rpx;
font-size: 28rpx;
color: #fa3534;
text-align: center;
}
.intercept-info-popup__tip--first {
margin-top: 0;
margin-bottom: 12rpx;
}
.intercept-info-popup__footer {
padding: 16rpx 32rpx 32rpx;
}
.intercept-info-popup__btn {
height: 88rpx;
line-height: 88rpx;
text-align: center;
background: #2979ff;
border-radius: 12rpx;
font-size: 32rpx;
color: #ffffff;
}
.intercept-info-popup__btn:active {
opacity: 0.7;
}
/* 列表模式卡片样式 */
.pick-list--table {
display: flex;
flex-direction: column;
gap: 0;
}
.list-card-row {
padding: 0;
border: 1rpx solid #000000;
border-radius: 10rpx;
background: #ffffff;
margin-bottom: 24rpx;
}
.list-card-row:active {
background: #f5f6fa;
}
.list-card-row--active .list-card-label,
.list-card-row--active .list-card-value,
.list-card-row--active .list-card-name,
.list-card-row--active .list-card-tag {
color: #000000;
}
.list-card-row--matched {
background: #07c160;
}
.list-card-row--matched .list-card-label,
.list-card-row--matched .list-card-value,
.list-card-row--matched .list-card-name,
.list-card-row--matched .list-card-tag {
color: #ffffff;
}
.list-card-row__top {
display: flex;
align-items: flex-start;
justify-content: space-between;
margin-bottom: 0;
}
.list-card-qty-group {
display: flex;
flex-direction: row;
flex: 1;
min-width: 0;
border-bottom: 1rpx solid #000000;
}
.list-card-qty-item {
display: flex;
align-items: center;
flex: 1;
padding: 20rpx 0 8rpx 16rpx;
}
.list-card-qty-item:not(:last-child) {
border-right: 1rpx solid #000000;
}
.list-card-label {
font-size: 32rpx;
color: #000000;
flex-shrink: 0;
width: 100rpx;
text-align: left;
padding: 0;
line-height: 1.8;
}
.list-card-value {
font-size: 46rpx;
color: #000000;
font-weight: 500;
flex: 1;
text-align: center;
padding: 0 10rpx;
}
.list-card-value--done {
color: #07c160;
font-weight: 600;
}
.list-card-image-wrap {
flex-shrink: 0;
margin-left: 16rpx;
padding: 4rpx 16rpx 0 0;
}
.list-card-image {
width: 120rpx;
height: 120rpx;
border-radius: 10rpx;
}
.list-card-row__bottom {
display: block;
padding: 4rpx 16rpx 20rpx;
line-height: 1.5;
}
.list-card-name {
font-size: 38rpx;
color: #000000;
font-weight: 500;
line-height: 1.5;
}
.list-card-tag {
font-size: 38rpx;
color: #000000;
line-height: 1.5;
}
.list-card-space {
font-size: 38rpx;
color: #000000;
line-height: 1.5;
}
.image-placeholder--small {
width: 120rpx;
height: 120rpx;
display: flex;
align-items: center;
justify-content: center;
background: #f2f3f5;
border-radius: 10rpx;
}
.empty-state {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.empty-text {
margin-top: 18rpx;
font-size: 36rpx;
color: #909399;
}
.safe-area-bottom {
height: calc(30rpx + env(safe-area-inset-bottom));
}
.review-pack-row {
flex-shrink: 0;
display: flex;
align-items: center;
margin: 0 16rpx;
padding: 4rpx 16rpx;
background: #fef0f0;
border-radius: 6rpx;
gap: 6rpx;
}
.goods-pack-row {
flex-shrink: 0;
display: inline-flex;
align-items: center;
margin: 4rpx 16rpx 8rpx;
padding: 2rpx 10rpx;
background: #fef0f0;
border-radius: 6rpx;
gap: 4rpx;
}
.goods-pack-row--grid {
display: flex;
margin: 0;
}
.review-pack-label {
flex-shrink: 0;
font-size: 24rpx;
color: #e64242;
font-weight: 500;
}
.goods-pack-label {
flex-shrink: 0;
font-size: 34rpx;
color: #e64242;
}
.review-pack-value {
flex: 1;
min-width: 0;
font-size: 24rpx;
color: #e64242;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.goods-pack-value {
flex: 1;
min-width: 0;
font-size: 34rpx;
color: #e64242;
word-break: break-all;
}
.package-info-hint {
flex-shrink: 0;
padding: 10rpx 24rpx;
background: #fffbe6;
border-top: 1rpx solid #f0e6b8;
border-bottom: 1rpx solid #f0e6b8;
display: flex;
align-items: center;
gap: 6rpx;
line-height: 1.4;
}
.package-info-label {
font-size: 34rpx;
color: #909399;
flex-shrink: 0;
}
.package-info-value {
font-size: 34rpx;
color: #000000;
font-weight: 500;
}
.package-info-spec {
font-size: 34rpx;
color: #c0c4cc;
}
/* 多商品匹配弹窗 */
.multi-match-popup {
padding: 48rpx 32rpx calc(40rpx + env(safe-area-inset-bottom));
background: #ffffff;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
}
.multi-match-popup-title {
font-size: 38rpx;
font-weight: 600;
color: #303133;
text-align: center;
margin-bottom: 32rpx;
}
.multi-match-popup-body {
margin-bottom: 32rpx;
}
.multi-match-card {
display: flex;
flex-direction: row;
align-items: stretch;
padding: 0;
background: #f8f9fa;
border-radius: 12rpx;
border: 1rpx solid #ebeef5;
overflow: hidden;
}
.multi-match-card:active {
opacity: 0.7;
}
.multi-match-thumb {
flex: 1;
min-height: 240rpx;
overflow: hidden;
background: #f2f3f5;
display: flex;
align-items: center;
justify-content: center;
}
.multi-match-image {
width: 100%;
height: 100%;
}
.multi-match-image-placeholder {
width: 100%;
height: 100%;
min-height: 240rpx;
display: flex;
align-items: center;
justify-content: center;
background: #f2f3f5;
}
.multi-match-info {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
justify-content: center;
gap: 10rpx;
padding: 24rpx;
}
.multi-match-name {
font-size: 38rpx;
font-weight: 600;
color: #303133;
line-height: 1.4;
word-break: break-all;
}
.multi-match-barcode,
.multi-match-spec {
font-size: 32rpx;
color: #909399;
line-height: 1.4;
}
.multi-match-qty {
font-size: 32rpx;
color: #2979ff;
font-weight: 500;
line-height: 1.3;
}
.multi-match-popup-footer {
display: flex;
justify-content: center;
}
.multi-match-footer-btn {
flex: 1;
height: 80rpx;
line-height: 80rpx;
text-align: center;
border-radius: 12rpx;
font-size: 36rpx;
background: #f5f5f5;
color: #909399;
}
.multi-match-footer-btn:active {
opacity: 0.7;
}
/* 无条码复核弹窗 */
.no-barcode-popup {
width: 640rpx;
padding: 40rpx 32rpx 32rpx;
background: #ffffff;
border-radius: 20rpx;
box-sizing: border-box;
}
.no-barcode-popup__title {
font-size: 42rpx;
font-weight: 600;
color: #303133;
text-align: center;
margin-bottom: 32rpx;
}
.no-barcode-popup__body {
margin-bottom: 36rpx;
padding: 24rpx;
background: #f8f9fa;
border-radius: 12rpx;
}
.no-barcode-popup__text {
font-size: 36rpx;
color: #303133;
line-height: 1.6;
}
.no-barcode-popup__actions {
display: flex;
align-items: center;
gap: 20rpx;
}
.no-barcode-popup__btn {
flex: 1;
height: 88rpx;
border-radius: 12rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 36rpx;
font-weight: 500;
}
.no-barcode-popup__btn--cancel {
background: #f5f7fa;
color: #606266;
border: 1rpx solid #dcdfe6;
}
.no-barcode-popup__btn--confirm {
background: #2979ff;
color: #ffffff;
}
</style>