diff --git a/src/pages/order/index.vue b/src/pages/order/index.vue index 1b9624e..6b4066d 100644 --- a/src/pages/order/index.vue +++ b/src/pages/order/index.vue @@ -861,6 +861,9 @@ export default { dprefixedBarcodeVerified: false, dprefixedAllScannedHandled: false, sharedBarcodeDprefixed: false, + // 单品单件波次列表复用模式:输入车号/波次号查询后开启, + // 开启后扫条码在波次列表内定位订单复核发货(不重新查询、不清列表) + dprefixedWaveList: false, // 免验自动推进(need_recheck=N 或已扫满时点击商品卡片触发发货链路) noRecheckAutoAdvanceHandled: false, // 散单复核后称重:保存成功后据此切下一个未复核订单 @@ -1199,8 +1202,12 @@ export default { } return } - // 已选中列表项时,回车走商品条码匹配流程;否则走关键词查询 - if (this.hasSelection) { + // 已选中列表项时,回车走商品条码匹配流程;否则走关键词查询。 + // 散单单品单件例外:波次列表复用模式下,扫条码在列表内定位对应订单整单复核发货 + // (支持扫描波次内任意订单商品条码,不受当前选中订单限制) + if (this.dprefixedWaveList || (this.hasSelection && this.scanListType === 'single' && this.isDprefixedWave)) { + this.handleDprefixedScanLocate() + } else if (this.hasSelection) { this.handleBarcodeMatch() } else { this.handleSearch() @@ -2197,9 +2204,82 @@ export default { document.removeEventListener('mouseup', this.onResizeEnd) } }, + // 提取订单行所有商品条码(含 items/stock/stocks/detail.items 明细行与订单行本身), + // 返回归一化(去空白 + 大写)后的去重数组,供条码定位订单使用 + extractOrderBarcodes(row) { + if (!row || typeof row !== 'object') return [] + const result = [] + const push = (r) => { + if (!r || typeof r !== 'object') return + const raw = this.getRowValue(r, [ + 'barcode', 'bar_code', 'goods_barcode', 'sku_barcode', 'barcodes', + ]) + for (const b of this.normalizeBarcodeList(raw)) { + const code = this.normalizeScanBarcode(b) + if (code) result.push(code) + } + } + // 订单行内商品明细(items / stock / stocks / detail.items) + const detailSource = this.getRowValue(row, ['detail']) + const inlineItems = Array.isArray(row?.items) + ? row.items + : Array.isArray(row?.stock) + ? row.stock + : Array.isArray(row?.stocks) + ? row.stocks + : detailSource && Array.isArray(detailSource.items) + ? detailSource.items + : null + if (Array.isArray(inlineItems)) inlineItems.forEach(push) + // 订单行本身(含 detail 包裹) + push(this.getScanOrderSource(row)) + return [...new Set(result)] + }, + // 判断查询关键词是否为商品条码(命中返回列表首行订单的商品条码)。 + // 仅「扫商品条码定位」才返回 true,输入车号/运单号查询返回 false, + // 用于 D 前缀单品单件是否自动复核的判定(applyScanResult 的 isBarcodeSearch) + isKeywordOrderBarcode(payload, query) { + const code = this.normalizeScanBarcode(query) + if (!code) return false + const list = Array.isArray(payload?.list) ? payload.list : [] + if (list.length === 0) return false + return this.extractOrderBarcodes(list[0]).includes(code) + }, + // 在散单列表中查找商品条码命中的订单行(扫描波次内任意商品条码定位对应订单) + findOrderByBarcode(list, code) { + const rows = Array.isArray(list) ? list : [] + for (const row of rows) { + if (this.extractOrderBarcodes(row).includes(code)) return row + } + return null + }, + // 散单单品单件:扫商品条码 → 在波次列表内定位对应订单并整单自动复核发货。 + // 支持扫描波次内任意订单的商品条码,不受「当前选中订单」限制;列表保持不变。 + handleDprefixedScanLocate() { + const barcode = this.keyword.trim() + if (!barcode) return + const code = this.normalizeScanBarcode(barcode) + const target = this.findOrderByBarcode(this.scanOrderList, code) + if (!target) { + uni.showToast({ title: '无记录', icon: 'none' }) + return + } + this.keyword = '' + // 已复核:不重复发货 + if (this.getWaveReviewStatus(target) === '已复核') { + uni.showToast({ title: '该订单已复核', icon: 'none', silentVoice: true }) + return + } + // 拦截/已拦截订单:只选中展示拦截信息,不自动复核发货 + const blocked = this.isOrderIntercepted(target) + this.dprefixedBarcodeVerified = !blocked + this.handleScanOrderClick(target) + }, async handleSearch() { const query = this.keyword.trim() console.log('[order-scan] handleSearch query=', query) + // 新查询:退出单品单件波次列表复用模式(由 applyScanResult 按结果重新判定) + this.dprefixedWaveList = false // 清空关键词:回到初始空状态 if (!query) { @@ -2216,7 +2296,9 @@ export default { this.reviewedKeepList = [] body = await scanReviewOrder({ keyword: query }) const payload = body?.data || body?.result || body || {} - this.applyScanResult(payload, true) + // 仅当查询词命中首行订单商品条码(扫商品条码定位)时才视为条码搜索, + // 避免输入车号/运单号查询时误触发 D 前缀单品单件自动复核 + this.applyScanResult(payload, this.isKeywordOrderBarcode(payload, query)) this.activeKeyword = query this.keyword = '' } catch (error) { @@ -2292,6 +2374,12 @@ export default { // 按即将选中的第一行判定(混单时仅定位到的 D 前缀订单触发自动复核,普通散单不受影响) const firstRow = this.scanOrderList.length > 0 ? this.scanOrderList[0] : null this.dprefixedBarcodeVerified = isBarcodeSearch && this.isDprefixedRow(firstRow) + // 单品单件波次列表复用模式:输入车号/波次号查询(非条码定位)且列表含 D 前缀订单时开启; + // 开启后扫条码在列表内定位订单复核发货,不重新查询、不清列表 + this.dprefixedWaveList = + !isBarcodeSearch && + this.scanListType === 'single' && + this.scanOrderList.some((row) => this.isDprefixedRow(row)) // 默认选中第一行,右侧立即展示其商品明细(不再需要手动点第一行) this.autoSelectFirstResult() @@ -2607,7 +2695,21 @@ export default { if (action === 'dprefixed') { // D前缀波次:复核后清空选中、回到列表等待下一个商品条码(保留左侧列表,已复核项本地标记) this.keyword = '' + const savedPickMode = this.currentPickMode this.clearSelection() + // 恢复拣货模式:波次列表复用模式下继续扫条码时,isDprefixedRow 的顶层兜底判定依赖它 + this.currentPickMode = savedPickMode + // 波次列表复用模式:发货后检查是否还有未复核订单,全部复核完则收尾回初始态 + if (this.dprefixedWaveList) { + const hasPending = this.scanOrderList.some( + (row) => + this.getWaveReviewStatus(row) === '未复核' && !this.isInterceptExcluded(row) + ) + if (!hasPending) { + this.finishAllReviewed() + return + } + } this.scheduleScanInputFocus(150) return } @@ -2676,6 +2778,7 @@ export default { this.scanListType = '' this.activeKeyword = '' this.keyword = '' + this.dprefixedWaveList = false this.clearSelection() this.scheduleScanInputFocus(150) }, @@ -2762,6 +2865,7 @@ export default { this.activeKeyword = '' this.keyword = '' this.reviewedKeepList = [] + this.dprefixedWaveList = false this.clearSelection() uni.showToast({ title: '已清空', icon: 'none', silentVoice: true }) }, @@ -4435,8 +4539,8 @@ export default { // 进入详情时播报免复核商品的打包要求(need_recheck=N 且含打包要求) this.speakNoRecheckPackRequirements(this.displayOrders) - // 自动发货模式:选中订单含拦截信息时自动弹出拦截信息弹窗 - if (this.settingShipMode === 'auto' && this.isOrderIntercepted(item)) { + // 选中订单含拦截信息时自动弹出拦截信息弹窗(自动/手动发货模式均弹) + if (this.isOrderIntercepted(item)) { this.openInterceptInfo(item) } @@ -4511,12 +4615,8 @@ export default { if (this.getWaveReviewStatus(wave) === '已复核') { this.markAllProductsScanned() } - // 团购波次含拦截单:进入时播报「有拦截订单」 + // 波次内含拦截单时自动弹出拦截信息弹窗(自动/手动发货模式均弹) if (this.getWaveInterceptLabel(wave)) { - uni.showToast({ title: '有拦截订单', icon: 'none' }) - } - // 自动发货模式:波次内含拦截单时自动弹出拦截信息弹窗 - if (this.settingShipMode === 'auto' && this.getWaveInterceptLabel(wave)) { this.openWaveInterceptInfo(wave) } },