From 1c9cf4d3de65464e6e14c84c35e77140e1e46ce6 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 21 Sep 2026 02:28:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=93=E5=8C=85=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=AE=A2=E5=8D=95=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?key=20+=20=E5=9B=A2=E5=8D=95=E5=A4=8D=E6=A0=B8=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - workbench.queryOrder 返回 key(服务端缓存订单上下文,展示字段不再回传) - workbench.packOrder 只接收 key(移除 delivery_order_code/wave_no/items_* 等订单入参) - 团单完全核对后,扫码恢复为运单查询(检查下一单),不再停留在验货模式 - 重复扫描正在打包的同一单(团单比波次/散单比运单号):不显示已打包、不重新复核、不重复上报,提示正在打包 - 复核完成/开始打包后移除商品行右键/长按免验事件 - 退件拆包页(returns)更新 --- src/api/index.ts | 13 +- src/pages/packaging/index.vue | 99 +- src/pages/returns/index.vue | 3465 ++++++++++++++++++++++++++++++++- 3 files changed, 3529 insertions(+), 48 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index fb65ef4..2d16df0 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -131,6 +131,8 @@ export function removeWorkbenchMember(data: { /** * 工作台条码查询订单(免登录、免鉴权,以工作台 token 鉴权) * - 入参 token(工作台 token)+ barcode(条码/运单号);仓库与工作台由服务端从 token 解析注入 + * - 返回 data.key:服务端缓存的订单上下文 key(开始打包时回传给 workbench.packOrder), + * 其余返回字段仅用于展示,不再作为打包参数回传 * - 散单 isSandan=1 附 order.intercept_flag/pack_flag;团购 isSandan=0 附 batch 波次信息 */ export function queryPackOrder(token: string, barcode: string) { @@ -143,19 +145,18 @@ export function queryPackOrder(token: string, barcode: string) { /** * 工作台打包上报(免登录、免鉴权,以工作台 token 鉴权) - * - 入参 token + 发货单号(必填)等;仓库与工作台由服务端从 token 解析注入 + * - 入参 token + key(workbench.queryOrder 返回的订单上下文 key,必填); + * 仓库与工作台由服务端从 token 解析注入 + * - 订单数据由服务端按 key 从查询时缓存的上下文中解析,客户端不再回传订单信息 * - 散单按 order_id、团购按 wave_no 去重后创建打包任务(wms_pack_task) */ export function packOrder(data: { token: string - delivery_order_code: string - wave_no?: string + /** workbench.queryOrder 返回的订单上下文 key(服务端缓存) */ + key: string status?: number /** 打包时间(Unix 秒,后端按秒转 datetime) */ pack_time?: number - wave_total_orders?: number - items_count?: number - items_total?: number users?: Array<{ wms_account_id?: number | null id?: number | null diff --git a/src/pages/packaging/index.vue b/src/pages/packaging/index.vue index 9fad543..6cbdb82 100644 --- a/src/pages/packaging/index.vue +++ b/src/pages/packaging/index.vue @@ -96,8 +96,8 @@ :key="index" class="pack-detail-row" :class="{ 'pack-detail-row--scanned': isGroupOrder && isItemScanned(item) }" - @longpress="handleLongPressProduct(item)" - @contextmenu.prevent="handleLongPressProduct(item)" + @longpress="!groupVerifyDone && handleLongPressProduct(item)" + @contextmenu.prevent="!groupVerifyDone && handleLongPressProduct(item)" > {{ index + 1 }} @@ -436,7 +436,11 @@ export default { currentOrderCode: '', currentWaybillCode: '', currentDeliveryOrderCode: '', + // 服务端缓存的订单上下文 key(queryOrder 返回,开始打包时回传 packOrder) + currentOrderKey: '', currentOrderRaw: null, + // 本次查询与正在打包的订单是否一致(团单比波次、散单比运单号),一致时不显示"已打包" + sameOrderQuery: false, precheckPassed: false, packStarted: false, packReporting: false, @@ -522,6 +526,14 @@ export default { groupVerifiedCount() { return this.scannedKindCount }, + // 团单是否已完全核对(全部商品均已核实) + groupVerifyCompleted() { + return this.totalKindCount > 0 && this.groupVerifiedCount >= this.totalKindCount + }, + // 核实已完成或已开始打包:商品行右键/长按免验事件移除 + groupVerifyDone() { + return this.groupVerifyCompleted || this.packStarted + }, hasPackRecord() { return !!(this.currentOrderRaw || this.currentOrderCode || this.detailList.length > 0) }, @@ -673,8 +685,14 @@ export default { this.scheduleScanInputFocus(150) return } - // 已绑定:团单等待复核中,所有条码输入均作为商品条码校验(切换订单请先取消核实) - if (this.isGroupOrder && this.precheckPassed && this.detailList.length > 0) { + // 已绑定:团单待核实中,所有条码输入均作为商品条码校验(切换订单请先取消核实) + // 完全核对(自动开始打包)后,扫码恢复为运单查询,用于检查下一个订单 + if ( + this.isGroupOrder && + this.precheckPassed && + this.detailList.length > 0 && + !this.groupVerifyCompleted + ) { this.matchProductBarcode(kw) return } @@ -771,6 +789,8 @@ export default { this.currentWaveNo = wave?.wave_no || order?.wave_no || '' this.currentWaybillCode = order?.waybill_code || order?.barcode || '' this.currentDeliveryOrderCode = order?.delivery_order_code || '' + this.currentOrderKey = + order?.key || order?.order_key || order?.orderKey || wave?.key || wave?.order_key || '' this.waveTotalOrders = wave?.order_count ?? order?.order_count ?? '' this.productCount = Number(wave?.items_total) || Number(order?.items_total) || 0 this.currentOrderCode = @@ -813,15 +833,46 @@ export default { const batch = raw?.batch && typeof raw.batch === 'object' ? raw.batch : {} const items = Array.isArray(raw?.items) ? raw.items : [] + // 快照:查询前正在打包的订单标识(重复查询同一单时不显示"已打包"、无需重新复核) + const prevIsGroup = this.isGroupOrder + const prevWaybillCode = this.currentWaybillCode + const prevWaveNo = this.currentWaveNo + const prevPackStarted = this.packStarted + // 订单类型:isSandan=1 散单、0 团单(团单需扫码商品条码核验) const rawSandan = this.pickInfoField(raw, {}, ['isSandan', 'is_sandan']) + const newIsGroup = rawSandan !== '' && Number(rawSandan) === 0 this.isSandan = rawSandan === '' ? null : Number(rawSandan) + // 与正在打包的订单对比:团单比波次号、散单比运单号;一致即重复查询同一单 + const newWaveNo = + this.pickInfoField(batch, {}, ['wave_no', 'waveNo']) || + this.pickInfoField(order, {}, ['wave_no', 'waveNo']) + const newWaybill = + this.pickInfoField(raw, {}, ['waybill_code', 'waybillCode']) || + this.pickInfoField(raw, {}, ['barcode']) || + '' + this.sameOrderQuery = + prevIsGroup === newIsGroup && + (newIsGroup + ? Boolean(prevWaveNo) && + Boolean(newWaveNo) && + String(prevWaveNo) === String(newWaveNo) + : Boolean(prevWaybillCode) && + Boolean(newWaybill) && + String(prevWaybillCode) === String(newWaybill)) + // 记录当前订单上下文(用于预检/上报) this.currentOrderRaw = raw + // 订单上下文 key(服务端缓存):开始打包时回传 workbench.packOrder + this.currentOrderKey = + this.pickInfoField(raw, {}, ['key', 'order_key', 'orderKey']) || + this.pickInfoField(order, {}, ['key', 'order_key', 'orderKey']) || + '' this.currentOrderCode = code || '' - this.packStarted = false - this.precheckPassed = false + // 重复查询正在打包的同一单:保持打包中状态,不要求重新复核/重复上报 + this.packStarted = this.sameOrderQuery && prevPackStarted + this.precheckPassed = this.packStarted // 运单号(散单展示用:waybill_code 优先,兜底 barcode) this.currentWaybillCode = @@ -871,6 +922,12 @@ export default { item.scannedQty = Number(item.qty) || 0 } }) + // 重复查询正在打包的同一单:全部商品恢复为已核实,不要求重新复核 + if (this.sameOrderQuery && this.packStarted) { + this.detailList.forEach((item) => { + item.scannedQty = Number(item.qty) || 0 + }) + } // ---- 预检与分流 ---- const precheck = this.packPrecheck() @@ -880,9 +937,15 @@ export default { return } this.precheckPassed = true + // 重复查询正在打包的同一单:保持打包中,不重复上报、不重新复核 + if (this.sameOrderQuery && this.packStarted) { + this.speak('正在打包') + uni.showToast({ title: '正在打包', icon: 'none' }) + return + } if (this.isGroupOrder) { - // 团单:无商品明细 或 全部商品免验 = 无需核实,直接提交开始打包 - if (this.detailList.length === 0 || this.groupVerifiedCount >= this.totalKindCount) { + // 团单:无商品明细 或 全部商品免验/已完全核对 = 无需核实,直接提交开始打包 + if (this.detailList.length === 0 || this.groupVerifyCompleted) { this.handleSubmitGroupPack() } return @@ -922,7 +985,7 @@ export default { return qty > 0 && scanned >= qty }, handleLongPressProduct(item) { - if (!item || !this.isGroupOrder) { + if (!item || !this.isGroupOrder || this.groupVerifyDone) { return } if (this.isItemScanned(item)) { @@ -949,7 +1012,7 @@ export default { if (!this.isGroupOrder || !this.precheckPassed || this.packStarted || this.packReporting) { return } - if (this.totalKindCount > 0 && this.groupVerifiedCount >= this.totalKindCount) { + if (this.groupVerifyCompleted) { this.handleSubmitGroupPack() } }, @@ -999,7 +1062,7 @@ export default { } const packStatus = order?.pack_status ?? order?.packStatus ?? batch?.pack_status ?? batch?.packStatus ?? '' - if (packStatus && String(packStatus) !== 'none') { + if (packStatus && String(packStatus) !== 'none' && !this.sameOrderQuery) { return { blocked: true, reason: '订单已打包,禁止打包', speakText: '已打包' } } return { blocked: false, reason: '', speakText: '' } @@ -1012,7 +1075,7 @@ export default { if (recheckStatus && !['fin', 'finished', '1'].includes(String(recheckStatus))) { return { blocked: true, reason: '订单未复核,禁止打包', speakText: '订单未复核,禁止打包' } } - if (Number(order?.pack_flag) === 1) { + if (Number(order?.pack_flag) === 1 && !this.sameOrderQuery) { return { blocked: true, reason: '订单已打包,禁止打包', speakText: '已打包' } } return { blocked: false, reason: '', speakText: '' } @@ -1025,16 +1088,16 @@ export default { if (!token) { return Promise.reject(new Error('工作台登录已失效')) } + if (!this.currentOrderKey) { + return Promise.reject(new Error('订单上下文缺失,请重新扫码查询')) + } const payload = { token: String(token), - delivery_order_code: - this.currentDeliveryOrderCode || this.currentOrderCode || this.currentWaveNo || '', + // 订单上下文 key(queryOrder 返回,服务端按 key 解析缓存中的订单信息) + key: this.currentOrderKey, status, // 打包时间:Unix 秒(后端按秒转 datetime,传毫秒会导致 start_time 年份溢出报错) pack_time: Math.floor(Date.now() / 1000), - wave_no: this.isGroupOrder && this.currentWaveNo ? this.currentWaveNo : undefined, - items_count: this.totalKindCount || undefined, - items_total: this.productCount || undefined, // 上报当前在线操作员(workbench.packOrder 的 users 参数,支持多人) users: this.workbenchMembers.length > 0 @@ -1113,7 +1176,9 @@ export default { this.currentOrderCode = '' this.currentWaybillCode = '' this.currentDeliveryOrderCode = '' + this.currentOrderKey = '' this.currentOrderRaw = null + this.sameOrderQuery = false this.precheckPassed = false this.packStarted = false }, diff --git a/src/pages/returns/index.vue b/src/pages/returns/index.vue index cae38f2..879e03b 100644 --- a/src/pages/returns/index.vue +++ b/src/pages/returns/index.vue @@ -2,18 +2,484 @@ - - - 退件 - 退件模块页面(待对接业务接口) + + + + + + 拆包工作台 + + + + + + + + 手动输入 + + + + + + 运单号 + {{ waybillCode || '等待扫描运单号' }} + + + + + 产品状态 + + 正常 + 破损 + + + + + + 商品条码 + {{ lastScannedBarcode || '—' }} + + + + + 数量 + + + + + + 货主 + {{ storeLabel || '—' }} + + + + + + + + + + + + + 📟 扫码指令 + + + {{ CMD_LABEL[cmd] }} + ● 当前 + + + {{ CMD[cmd] }} + + + + + + + + + 开单结果 + + + 拆包单号 + {{ unpackRecord.unpack_no || '—' }} + + + 运单号 + {{ unpackRecord.waybill_code || '—' }} + + + 拆包状态 + {{ statusLabel() }} + + + 原单退回 + {{ createResult.is_original_return ? '是' : '否' }} + + + 货主备注 + {{ createResult.store_remark || '—' }} + + + 扫描运单号创建拆包单 + + + + + + 原订单 {{ compareSummary.orderTypes }} 类 / {{ compareSummary.orderQty }} 件 + 已扫描 {{ compareSummary.unpackTypes }} 类 / {{ compareSummary.unpackQty }} 件 + + + 一致 {{ compareSummary.matched }} + 数量差异 {{ compareSummary.qtyDiff }} + 仅订单 {{ compareSummary.orderOnly }} + 仅拆包 {{ compareSummary.unpackOnly }} + + + + + + + 拆包明细({{ detailTotal }} 项) + + + + + 明细加载中... + + + + + 原单商品 + 订单 {{ compareSummary.orderQty }} 件 + + + + + {{ o.name }} + {{ o.code }} + {{ o.spec }} + + + 订单:{{ o.qty }} + 退回:{{ o.returned }} + 差异:{{ formatDiff(o.diff) }} + + + 无原单商品 + + + + + + + + + + — + + + + + + 拆包 + {{ row.__unpack.name || '未识别商品' }} + {{ row.__unpack.code || row.barcode || '—' }} + {{ row.__unpack.spec }} + + + + + + + − + {{ row.quantity }} + + + + + + + + {{ row.product_status === 'damaged' ? '破损' : '正常' }} + + + + + {{ row.remark || '备注' }} + + + + 暂无明细,扫描商品条码录入 + + + + + + + {{ detailPage }} / {{ detailMaxPage }} + + + + + + + + + 选择备注 + × + + + + {{ opt }} + × + + 暂无备注选项,可在下方新增 + + + + + + + + + + + + + 摄像头设置 + × + + 已选 {{ selectedCameraIds.length }} 个摄像头(保存后生效) + + 摄像头列表加载中... + + {{ selectedCameraIds.indexOf(cam.id) !== -1 ? '☑' : '☐' }} + {{ cameraLabel(cam) }} + + 暂无摄像头 + + + + + + + + + + + + {{ activeCamera ? cameraLabel(activeCamera) : '摄像头预览' }} + + + {{ activeCamera ? cameraLabel(activeCamera) : '选择' }} ▾ + + {{ floatFullscreen ? '⤡' : '⛶' }} + - + + + + + + {{ previewLoading ? '正在连接录像机…' : previewError || '无信号' }} + + + APP 端暂不支持实时预览,字幕推送不受影响 + + + + + + + 📷 预览 + + + + +