diff --git a/pages/packing/packMode.vue b/pages/packing/packMode.vue index 6f6fa91..e5c6764 100644 --- a/pages/packing/packMode.vue +++ b/pages/packing/packMode.vue @@ -154,6 +154,9 @@ {{ item.item_name || '--' }} 、 {{ orderItemBarcode(item) || item.item_code || '--' }} + + 打包要求:{{ itemPackingRequirement(item) }} + @@ -474,6 +477,7 @@ export default { packWaitRemain: 0, // 大团购打包时长闸门:剩余等待秒数(倒计时展示,<=0 隐藏) packWaitTimer: null, // 大团购打包时长闸门:倒计时 interval 句柄 packWaveScope: null, // 当前「打包中」任务波次范围(0=未分配 1=大团购 2=散单 3=小团购 4=单品单件) + packReqChain: null, // 打包要求语音播报串行队列(核实播报排队用) // 团购核实:商品行已扫计数(key=商品行id/序号 → 已扫次数),达 plan_qty 视为已核实 groupVerified: {}, groupSubmitting: false, // 团购提交开始打包防重入 @@ -804,6 +808,49 @@ export default { console.warn('[packMode] 语音播报异常:', error); } }, + // 语音播报并返回完成 Promise(用于串行排队:上一条播完再播下一条) + speakTextAsync(text = '') { + try { + const tools = this.$tools; + if (!tools || typeof tools.speakText !== 'function') return Promise.resolve(false); + const task = tools.speakText(String(text).trim(), {}); + if (task && typeof task.then === 'function') { + return task.catch(error => { + console.warn('[packMode] 语音播报失败:', error); + return false; + }); + } + return Promise.resolve(false); + } catch (error) { + console.warn('[packMode] 语音播报异常:', error); + return Promise.resolve(false); + } + }, + // 语音播报商品打包要求(查询订单成功后调用,多条要求去重后串行播报,记录完成 Promise 供核实播报排队) + speakPackingRequirements(items) { + if (!Array.isArray(items) || !items.length) return; + const reqs = []; + items.forEach((it) => { + const v = String((it && it.packing_requirements) || '').trim(); + if (v && reqs.indexOf(v) === -1) reqs.push(v); + }); + if (!reqs.length) return; + // 串行链:上一条播完再播下一条,最终 resolve 表示全部打包要求播报完成 + let chain = Promise.resolve(); + reqs.forEach((text) => { + chain = chain.then(() => this.speakTextAsync(`${text}`)); + }); + this.packReqChain = chain; + }, + // 核实播报:排队到打包要求播报完成之后,避免打断打包要求播报 + speakAfterPackRequirements(text = '') { + const chain = this.packReqChain; + if (chain && typeof chain.then === 'function') { + this.packReqChain = chain.then(() => this.speakTextAsync(`${text}`)).catch(() => {}); + } else { + this.speakText(`${text}`); + } + }, // 清理广播自愈定时器(页面隐藏/卸载时避免残留定时器误注册广播) clearBcastHealTimer() { if (this.bcastHealTimer) { @@ -907,8 +954,9 @@ export default { this.retryGroupPackSubmit(); return; } - // 与上一次扫描内容完全一致 → 跳过(防止运单/商品条码重复触发查询/核实) - if (this.lastScannedCode === c) return; + // 与上一次扫描内容完全一致 → 跳过(防止运单/商品条码重复触发查询/核实); + // 查询失败态豁免:断网/查询失败后重新扫描同一运单可再次触发查询(重试) + if (this.lastScannedCode === c && this.orderQueryState !== 'error') return; this.lastScannedCode = c; // 手动扫码重新查单:重置打包上下文 key 失效自动重查计数(用户主动换单/重扫视为新的一轮) this.packKeyRetryCount = 0; @@ -1055,7 +1103,7 @@ export default { const name = String(item.item_name || '商品').trim(); // 团单:条码比对命中一次即标记该商品已完成(数量一次扫满) this.markItemVerified(item, i); - this.speakText('数据一致'); + this.speakAfterPackRequirements('数据一致'); uni.showToast({ title: `${name} 已核实`, icon: 'none' }); return true; } @@ -1095,7 +1143,7 @@ export default { const info = this.noBarcodeItem; if (!info) return; this.markItemVerified(info.item, info.idx); - this.speakText('数据一致'); + this.speakAfterPackRequirements('数据一致'); this.noBarcodePopupOpen = false; // 延迟清空,避免关闭动画期间文案闪变 setTimeout(() => { @@ -1175,11 +1223,21 @@ export default { } // 重查前记录团购核实进度(重查会重置核实状态,成功后恢复并重新提交) const wasGroupAllVerified = !this.orderQueryIsSandan && this.groupAllVerified; + // 重查前保存完整订单上下文:重查失败(断网/无记录)时恢复,保持「待重传」能力 + const prevResult = this.orderQueryResult; + const prevState = this.orderQueryState; + const prevVerified = this.groupVerified; + const prevAutoSubmitted = this.groupAutoSubmitted; this.speakText('上报失败,重新查询订单'); uni.showToast({ title: '上报失败,正在重新查询订单', icon: 'none', duration: 2500 }); await this.queryOrder(barcode); if (this.orderQueryState !== 'success' || !this.orderQueryResult) { - // 重查失败:弹出重传弹窗提示手动处理 + // 重查失败:恢复重查前的订单与核实状态,保持「待重传」能力(长按/点击商品、扫描商品条码可重新上报) + this.orderQueryResult = prevResult; + this.orderQueryState = prevState; + this.groupVerified = prevVerified; + this.groupAutoSubmitted = prevAutoSubmitted; + this.orderQueryError = ''; this.openRetryPopup('重新查询订单失败,请检查网络后重新扫码'); return; } @@ -1394,6 +1452,8 @@ export default { this.packContextKey = String(data?.key || '').trim(); // 查询成功:清空输入框,方便连续扫描下一单 this.orderBarcode = ''; + // 语音播报商品打包要求 + this.speakPackingRequirements(data?.items); // 团购:初始化商品核实状态(不自动上报,全部核实后将自动提交开始打包) this.groupVerified = {}; this.groupAutoSubmitted = false; @@ -1480,6 +1540,10 @@ export default { if (codes && typeof codes === 'object') return String(codes.barcode || codes.code || ''); return String(codes || ''); }, + // 商品打包要求 + itemPackingRequirement(item) { + return String((item && item.packing_requirements) || '').trim(); + }, // 打包预检(上报 packOrder 前):散单拦截 → 未复核 → 已打包;命中则文字+语音提示并禁止打包 packPrecheck() { const r = this.orderQueryResult; @@ -2326,7 +2390,8 @@ export default { item_code: String((o.item_code ?? o.itemCode ?? o.sku_code) || '').trim(), barcodes: o.barcodes ?? o.barcode, image_url: o.image_url ?? o.imageUrl ?? o.image, - need_recheck: o.need_recheck + need_recheck: o.need_recheck, + packing_requirements: o.packing_requirements }; }); @@ -3147,6 +3212,21 @@ export default { word-break: break-all; } +.order-item__requirement { + margin-top: 8rpx; + line-height: 1.5; +} + +.order-item__requirement-text { + display: inline-block; + font-size: 34rpx; + color: #e64340; + background: #fef0f0; + border-radius: 6rpx; + padding: 2rpx 10rpx; + word-break: break-all; +} + .order-empty { padding: 24rpx 0; font-size: 30rpx; @@ -3212,6 +3292,11 @@ export default { color: #ffffff; } +.order-item--verified .order-item__requirement-text { + color: #e64340; + background: #fef0f0; +} + .action-area { margin-top: 48rpx; display: flex; diff --git a/pages/work/order/order-review-comps/ReviewDetail.vue b/pages/work/order/order-review-comps/ReviewDetail.vue index 2b8df3f..9d9645c 100644 --- a/pages/work/order/order-review-comps/ReviewDetail.vue +++ b/pages/work/order/order-review-comps/ReviewDetail.vue @@ -65,7 +65,7 @@ {{ item.scannedQty || 0 }} - 包装: + 复核要求: {{ item.packageRequirement }} @@ -128,7 +128,7 @@ {{ item.location || '--' }} - 包装: + 复核要求: {{ item.packageRequirement }} @@ -548,13 +548,8 @@ import voice from '@/core/utils/voice'; voice.speak('超出订单数'); } this.$emit('updateScannedQty', matchIndex, newScanned); - const allDone = this.goodsList.every((item, idx) => { - const qty = idx === matchIndex ? newScanned : (item.scannedQty || 0); - return qty >= (item.planQty || 0); - }); - if (allDone) { - voice.speak('数据一致'); - } + // 扫码匹配成功即播报"数据一致"(排队到复核要求播报完成后) + this.$emit('speakDataConsistent'); // 已扫数量达到计划数量时,标记为已匹配(显示绿底和"已匹配"状态) if (newScanned >= maxQty) { const matchedId = String(matchedItem?.id || ''); @@ -606,14 +601,8 @@ import voice from '@/core/utils/voice'; // 更新已扫数量 this.$emit('updateScannedQty', matchIndex, newScanned); - // 所有商品都已完成扫描时才播报"数据一致" - const allDone = this.goodsList.every((item, idx) => { - const qty = idx === matchIndex ? newScanned : (item.scannedQty || 0); - return qty >= (item.planQty || 0); - }); - if (allDone) { - voice.speak('数据一致'); - } + // 扫码匹配成功即播报"数据一致"(排队到复核要求播报完成后) + this.$emit('speakDataConsistent'); // 已扫数量达到计划数量时,才标记为已匹配 if (newScanned >= maxQty) { @@ -679,7 +668,7 @@ import voice from '@/core/utils/voice'; // 标记当前商品条码匹配 this.$emit('barcodeMatched', matchId); uni.showToast({ title: `已标记为已复核(${planQty}/${planQty})`, icon: 'success' }); - voice.speak('数据一致'); + this.$emit('speakDataConsistent'); }, handleListLongPress(item, index) { if (this.isReadOnly) return; @@ -847,13 +836,8 @@ import voice from '@/core/utils/voice'; const newScanned = Math.min(currentScanned + addQty, maxQty); this.$emit('updateScannedQty', targetIdx, newScanned); - const allDone = this.goodsList.every((item, idx) => { - const qty = idx === targetIdx ? newScanned : (item.scannedQty || 0); - return qty >= (item.planQty || 0); - }); - if (allDone) { - voice.speak('数据一致'); - } + // 扫码匹配成功即播报"数据一致"(排队到复核要求播报完成后) + this.$emit('speakDataConsistent'); if (newScanned >= maxQty) { const matchedId = String(matchedItem?.id || ''); @@ -953,7 +937,6 @@ import voice from '@/core/utils/voice'; .order-info-left { display: flex; align-items: center; - gap: 12rpx; flex: 1; min-width: 0; } @@ -968,6 +951,7 @@ import voice from '@/core/utils/voice'; width: 1rpx; height: 20rpx; background: #dcdfe6; + margin: 0 24rpx; flex-shrink: 0; } @@ -1435,20 +1419,20 @@ import voice from '@/core/utils/voice'; } .list-card-name { - font-size: 34rpx; + font-size: 38rpx; color: #000000; font-weight: 500; line-height: 1.5; } .list-card-tag { - font-size: 34rpx; + font-size: 38rpx; color: #000000; line-height: 1.5; } .list-card-space { - font-size: 34rpx; + font-size: 38rpx; color: #000000; line-height: 1.5; } @@ -1494,14 +1478,17 @@ import voice from '@/core/utils/voice'; .goods-pack-row { flex-shrink: 0; - display: flex; + display: inline-flex; align-items: center; - margin: 0; - padding: 0; + margin: 4rpx 16rpx 8rpx; + padding: 2rpx 10rpx; + background: #fef0f0; + border-radius: 6rpx; gap: 4rpx; } .goods-pack-row--grid { + display: flex; margin: 0; } @@ -1514,7 +1501,7 @@ import voice from '@/core/utils/voice'; .goods-pack-label { flex-shrink: 0; - font-size: 28rpx; + font-size: 34rpx; color: #e64242; } @@ -1531,7 +1518,7 @@ import voice from '@/core/utils/voice'; .goods-pack-value { flex: 1; min-width: 0; - font-size: 28rpx; + font-size: 34rpx; color: #e64242; word-break: break-all; } diff --git a/pages/work/order/order-review.vue b/pages/work/order/order-review.vue index d6d170b..019c45e 100644 --- a/pages/work/order/order-review.vue +++ b/pages/work/order/order-review.vue @@ -57,6 +57,7 @@ @autoConfirmAndNext="handleAutoConfirmAndNext" @reprint="handleReprint" @goodsItemClick="handleGoodsItemClick" + @speakDataConsistent="handleSpeakDataConsistent" /> @@ -491,6 +492,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; goodsInfoList: [], orderList: [], listType: '', packingRequirements: '', + recheckReqChain: null, pickMode: '', totalOrders: 0, taskId: '', @@ -1144,6 +1146,34 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; speakVoice(text) { voice.speak(text, { minInterval: 800 }); }, + // 语音播报复核要求(进入详情后调用,去重后串行播报,记录链供后续播报排队,参考打包模式页 speakPackingRequirements) + speakRecheckRequirements(items) { + if (!Array.isArray(items) || !items.length) return; + const reqs = []; + items.forEach((it) => { + const v = String((it && it.packageRequirement) || '').trim(); + if (v && v !== '--' && reqs.indexOf(v) === -1) reqs.push(v); + }); + if (!reqs.length) return; + let chain = Promise.resolve(); + reqs.forEach((text) => { + chain = chain.then(() => voice.speak(`${text}`, { minInterval: 800 })); + }); + this.recheckReqChain = chain; + }, + // 复核要求播报完成后再播报(避免打断复核要求播报) + speakAfterRecheckRequirements(text = '') { + const chain = this.recheckReqChain; + if (chain && typeof chain.then === 'function') { + this.recheckReqChain = chain.then(() => voice.speak(`${text}`, { minInterval: 800 })).catch(() => {}); + } else { + voice.speak(`${text}`, { minInterval: 800 }); + } + }, + // 子组件(ReviewDetail)数据一致播报统一入口:排队到复核要求播报完成后 + handleSpeakDataConsistent() { + this.speakAfterRecheckRequirements('数据一致'); + }, loadScanQuantity() { try { const stored = uni.getStorageSync('review_scan_quantity'); @@ -2570,7 +2600,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; // 无需复核商品(need_recheck=N):已扫数量视为计划数,卡片标记为已扫 scannedQty: needRecheck === 'N' ? (isNaN(planQty) ? 0 : planQty) : (isNaN(scannedQty) ? 0 : scannedQty), need_recheck: needRecheck, - packageRequirement: String(rawItem?.packing_requirements || rawItem?.package_requirement || rawItem?.packageRequirement || rawItem?.packing_requirement || '').trim() || '--', + packageRequirement: String(stockItem?.recheck_requirements || rawItem?.recheck_requirements || stockItem?.packing_requirements || rawItem?.packing_requirements || rawItem?.package_requirement || rawItem?.packageRequirement || rawItem?.packing_requirement || '').trim() || '--', skuCode: String(stockItem?.item_code || rawItem?.item_code || snapshot?.item_code || ''), skuName: stockName || String(snapshot?.item_name || rawItem?.item_name || '--'), location: String(stockItem?.sku_property || snapshot?.sku_property || rawItem?.sku_property || '--'), @@ -2583,12 +2613,12 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; }; }); - // 提取包装要求(取第一个 stock 的 packing_requirements) + // 提取包装要求(取第一个 stock 的 recheck_requirements) let packingRequirements = ''; for (let i = 0; i < rawItems.length; i++) { const raw = rawItems[i]; const stockItem = raw?.stock_id ? raw : (Array.isArray(raw?.stock) && raw.stock.length > 0 ? raw.stock[0] : null); - const req = stockItem?.packing_requirements || raw?.packing_requirements || ''; + const req = stockItem?.recheck_requirements || raw?.recheck_requirements || stockItem?.packing_requirements || raw?.packing_requirements || ''; if (req) { packingRequirements = String(req).trim(); break; @@ -2635,6 +2665,9 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; this.showDetailView = true; this.listExpanded = false; + // 进入详情后语音播报复核要求(去重串行播报) + this.speakRecheckRequirements(this.detailGoodsList); + // 团购模式:进入含拦截单的波次时自动弹出拦截信息提示(含波次号、运单号) // 每个波次本次会话只自动弹 1 次(按 waveId/waveNo 去重);已复核波次仅展示只读详情,不自动弹窗 if ( @@ -3065,7 +3098,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; this.scannedPackageId = String(matched.id || ''); uni.hideLoading(); uni.showToast({ title: '包材匹配成功:' + (matched.material_name || trimmed), icon: 'success' }); - this.speakVoice('数据一致'); + this.speakAfterRecheckRequirements('数据一致'); } else { this.scannedPackageMaterial = null; uni.hideLoading(); diff --git a/pages/work/order/picking.vue b/pages/work/order/picking.vue index 983c6c0..2f339bc 100644 --- a/pages/work/order/picking.vue +++ b/pages/work/order/picking.vue @@ -86,6 +86,10 @@ 包装: {{ selectedPickItem.packingRequirements }} + + 拣货要求: + {{ selectedPickItem.pickRequirements }} + 分配篮号: @@ -283,6 +287,19 @@ + + + + + 拣货要求 + + {{ (selectedPickItem && selectedPickItem.pickRequirements) || '' }} + + + 关闭 + + + @@ -333,6 +350,9 @@ import voice from '@/core/utils/voice'; noBarcodeItemTotalQty: 0, showWaveListPopup: false, showPackingReqPopup: false, + showPickReqPopup: false, + pickReqChain: null, + spokenPickReqSet: {}, submittingWavePickTask: false, currentWavePickSubmitPromise: null, wavePickSubmitQueue: [], @@ -1605,6 +1625,31 @@ import voice from '@/core/utils/voice'; } this.showWaveListPopup = true; }, + // 语音播报拣货要求(进入详情/切换商品时调用,去重后串行播报,参考复核发货页 speakRecheckRequirements) + speakPickRequirements(items) { + if (!Array.isArray(items) || !items.length) return; + const spoken = this.spokenPickReqSet || {}; + const reqs = []; + items.forEach((it) => { + const v = String((it && it.pickRequirements) || '').trim(); + if (v && !spoken[v] && reqs.indexOf(v) === -1) reqs.push(v); + }); + if (!reqs.length) return; + const base = this.pickReqChain && typeof this.pickReqChain.then === 'function' + ? this.pickReqChain + : Promise.resolve(); + let chain = base; + reqs.forEach((text) => { + spoken[text] = true; + chain = chain.then(() => voice.speak(`${text}`, { minInterval: 800 })); + }); + this.spokenPickReqSet = spoken; + this.pickReqChain = chain; + }, + // 切换商品后播报当前选中商品的拣货要求 + speakCurrentPickRequirement() { + this.speakPickRequirements([this.selectedPickItem]); + }, requestWavePickTaskComplete(taskIdNumber, options = {}) { const payload = { task_id: taskIdNumber, @@ -1819,6 +1864,21 @@ import voice from '@/core/utils/voice'; } return map; }, + // 拣货要求:pick_mode(2/3/4) 时字段在 data.picking_details[x].stock.pick_requirements + extractPickRequirements(payload = {}) { + const details = Array.isArray(payload?.picking_details) ? payload.picking_details : []; + const map = {}; + for (let i = 0; i < details.length; i += 1) { + const detail = details[i]; + const stockId = detail?.stock_id ?? detail?.stock?.id ?? ''; + const req = detail?.pick_requirements ?? detail?.stock?.pick_requirements ?? ''; + if (stockId && req) { + const key = String(stockId).trim(); + map[key] = String(req).trim(); + } + } + return map; + }, extractCurrentTaskIdFromResponse(response) { const payload = response?.data?.data || response?.data || response?.result || response || {}; const candidate = payload?.task_id ?? payload?.taskId ?? payload?.task?.task_id ?? payload?.task?.taskId ?? null; @@ -1871,6 +1931,7 @@ import voice from '@/core/utils/voice'; }; this.packingRequirements = ''; const packingReqMap = this.extractPackingRequirements(payload); + const pickReqMap = this.extractPickRequirements(payload); this.pickingView = { modeCode: view?.mode_code ?? '', modeName: view?.mode_name || '--', @@ -1886,6 +1947,7 @@ import voice from '@/core/utils/voice'; totalQty: Number(item?.total_qty || 0), storeRemark: item?.store_remark || '', packingRequirements: packingReqMap[itemStockId] || '', + pickRequirements: item?.pick_requirements || pickReqMap[itemStockId] || '', boxAllocations: (Array.isArray(item?.box_allocations) ? item.box_allocations : []).map(alloc => ({ boxId: alloc?.box_id ?? '', boxNo: alloc?.box_no ?? '--', @@ -1904,6 +1966,10 @@ import voice from '@/core/utils/voice'; this.itemImageListCache = {}; // 后台批量预加载所有条码,避免切换时逐个请求 this.preloadAllItemBarcodes(); + // 进入任务详情后仅播报当前展示商品的拣货要求(每个要求只播一次) + this.pickReqChain = null; + this.spokenPickReqSet = {}; + this.speakCurrentPickRequirement(); }, async requestWavePickTaskDetail() { const taskIdNumber = Number(this.taskId || 0); @@ -2215,16 +2281,23 @@ import voice from '@/core/utils/voice'; return promise; }, selectPickItem(index) { - this.selectedIndex = Number(index || 0); + const target = Number(index || 0); + if (target === this.selectedIndex) { + return; + } + this.selectedIndex = target; + this.speakCurrentPickRequirement(); }, handlePrevItem() { if (this.selectedIndex > 0) { this.selectedIndex -= 1; + this.speakCurrentPickRequirement(); } }, handleNextItem() { if (this.selectedIndex < this.filteredPickItems.length - 1) { this.selectedIndex += 1; + this.speakCurrentPickRequirement(); } }, previewSelectedItemImage() { @@ -2464,6 +2537,78 @@ import voice from '@/core/utils/voice'; white-space: nowrap; } + .pick-req-banner { + flex: none; + display: flex; + align-items: center; + gap: 6rpx; + background: #fef0f0; + border: 1rpx solid #fde2e2; + border-radius: 8rpx; + padding: 6rpx 16rpx; + } + + .pick-req-banner__label { + flex-shrink: 0; + font-size: 24rpx; + color: #e64242; + font-weight: 500; + } + + .pick-req-banner__value { + flex: 1; + min-width: 0; + font-size: 24rpx; + color: #e64242; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .pick-req-popup { + padding: 32rpx 24rpx 24rpx; + min-width: 560rpx; + max-width: 600rpx; + } + + .pick-req-popup__title { + font-size: 36rpx; + font-weight: 600; + color: #303133; + text-align: center; + margin-bottom: 24rpx; + } + + .pick-req-popup__body { + padding: 24rpx; + background: #fef0f0; + border-radius: 12rpx; + margin-bottom: 24rpx; + } + + .pick-req-popup__text { + font-size: 36rpx; + color: #e64242; + line-height: 1.8; + word-break: break-all; + white-space: pre-wrap; + text-align: center; + } + + .pick-req-popup__footer { + text-align: center; + } + + .pick-req-popup__close { + display: inline-block; + font-size: 30rpx; + color: #606266; + background: #f5f5f5; + border: 1rpx solid #dcdfe6; + border-radius: 10rpx; + padding: 14rpx 64rpx; + } + .packing-req-popup { padding: 32rpx 24rpx 24rpx; max-width: 600rpx;