From afd1672610a196034cb1210a766c05ba675f949b Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Sun, 22 Nov 2026 11:50:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(B2B=E5=A4=87=E8=B4=A7):=20=E5=95=86?= =?UTF-8?q?=E5=93=81=E8=A1=8C=E5=B1=95=E7=A4=BA=E5=9B=BE=E7=89=87=E4=B8=8E?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=E5=A2=9E=E5=BC=BA=EF=BC=8C=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8D=87=E8=87=B3=201.0.147?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - stockPreparationDetail 商品卡片新增商品缩略图(多图角标 1/N、点击预览多图、 无图占位/加载失败占位) - 商品名称只显示名称,条码统一由条码行展示;条码取值扩展 stock.barcodes / item_snapshot.barcode,超 3 个支持展开/收起 - 新增相机扫码按钮,扫码结果匹配商品条码标记已扫 - 扫码匹配 extractItemBarcodeCandidates 支持条码对象({barcode})与 item_snapshot.barcode - 编辑分箱 startEdit 保留 stock / item_snapshot 字段 - package.json 与 manifest.json 版本号 1.0.146 → 1.0.147 --- package.json | 2 +- src/manifest.json | 4 +- .../B2BOperation/stockPreparationDetail.vue | 311 +++++++++++++++++- 3 files changed, 303 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 835081a..b79e542 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wms-pda", - "version": "1.0.146", + "version": "1.0.147", "private": true, "description": "天豹云仓 WMS_PDA(uni-app Vue2 + @vue/cli 4.5)", "scripts": { diff --git a/src/manifest.json b/src/manifest.json index 47ebe11..f341bd4 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "WMS_PDA", "appid" : "__UNI__0B3DAD3", "description" : "多平台快速开发的UI框架", - "versionName" : "1.0.146", - "versionCode" : 1000146, + "versionName" : "1.0.147", + "versionCode" : 1000147, "transformPx" : false, "app-plus" : { "statusbar" : { diff --git a/src/pages/B2BOperation/stockPreparationDetail.vue b/src/pages/B2BOperation/stockPreparationDetail.vue index 6f6a250..c1e061a 100644 --- a/src/pages/B2BOperation/stockPreparationDetail.vue +++ b/src/pages/B2BOperation/stockPreparationDetail.vue @@ -38,9 +38,45 @@ 同一商品行 + 箱号不能重复;分箱数量合计需等于应拣数量(超量会被拦截)。 - - {{ formatItemName(it) }} - 已扫 + + + + + + + 加载失败 + + + + + + 1/{{ getItemImageCount(it) }} + + + + + + + {{ getItemNameWithBarcode(it) }} + + + + {{ isBarcodeExpanded(it) ? '收起' : '展开' }} + + + + + 已扫 + + + 应拣 @@ -79,8 +115,39 @@ - - {{ formatItemName(it) }} + + + + + + + 加载失败 + + + + + + 1/{{ getItemImageCount(it) }} + + + + + + + {{ getItemNameWithBarcode(it) }} + + + {{ isBarcodeExpanded(it) ? '收起' : '展开' }} + + + 应拣: @@ -269,6 +336,8 @@ photoSyncTimer: null, autoSaveTimer: null, lastSavedPackingKey: '', + barcodeExpandMap: {}, + imageErrorMap: {}, allowDirectBack: false, showCancelPrepConfirm: false, showFinishPrepConfirm: false, @@ -443,6 +512,8 @@ const sourceFields = [ item?.barcode, item?.barcodes, + item?.stock?.barcodes, + item?.item_snapshot?.barcode, item?.skuCode, item?.sku_code, item?.item_barcode, @@ -453,7 +524,9 @@ sourceFields.forEach(source => { const list = Array.isArray(source) ? source : [source]; list.forEach(s => { - const text = String(s || '').trim(); + // 条码对象(如 stock.barcodes 的 {id, barcode})取其 barcode 字段 + const raw = (s && typeof s === 'object') ? (s.barcode ?? s.value ?? s.code) : s; + const text = String(raw || '').trim(); if (!text) return; text.split(/[;,,、|\s]+/) .map(part => this.normalizeScanCode(part)) @@ -498,6 +571,20 @@ } return true; }, + // 相机扫码匹配商品条码 + handleItemScan() { + if (!this.editing) return; + uni.scanCode({ + onlyFromCamera: true, + scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'], + success: (res) => { + const code = this.normalizeUniScanResult(res); + if (!code) return; + this.markItemScannedByCode(code); + }, + fail: () => {} + }); + }, async fetchDetail() { this.loading = true; try { @@ -509,6 +596,7 @@ return; } this.detail = data; + this.imageErrorMap = {}; this.loadPhotos(); // 备货中:默认进入可编辑分箱 if (this.canEdit) { @@ -550,10 +638,69 @@ return []; }, formatItemName(item) { + // 只显示商品名称;商品条码统一由下方「条码」行展示,避免重复 const name = String(item?.item_name || '').trim(); - const code = String(item?.item_code || '').trim(); - if (name && code) return `${name}、${code}`; - return name || code || '--'; + return name || '--'; + }, + // 名称 + 顿号 + 条码(同一文本流,换行更自然) + getItemNameWithBarcode(item) { + const name = this.formatItemName(item); + if (this.getBarcodeCount(item) > 0) { + return `${name}、${this.getBarcodeDisplayText(item)}`; + } + return name; + }, + // 商品条码:优先取 stock.barcodes,其次 barcodes / barcode / item_snapshot.barcode + getBarcodeList(item) { + if (!item || typeof item !== 'object') return []; + const collected = []; + const push = (list) => { + if (Array.isArray(list)) { + list.forEach(b => { + const text = typeof b === 'string' ? b : (b?.barcode ?? b?.value ?? b?.code); + const code = String(text ?? '').trim(); + if (code) collected.push(code); + }); + } else if (typeof list === 'string' && list.trim()) { + list.split(/[;;,,\s]+/).forEach(s => { + const code = s.trim(); + if (code) collected.push(code); + }); + } + }; + push(item.stock?.barcodes); + if (collected.length === 0) push(item.barcodes); + if (collected.length === 0) push(item.barcode); + if (collected.length === 0) push(item.item_snapshot?.barcode); + return Array.from(new Set(collected)); + }, + getBarcodeCount(item) { + return this.getBarcodeList(item).length; + }, + hasMoreBarcodes(item) { + return this.getBarcodeCount(item) > 3; + }, + getBarcodeExpandKey(item) { + if (!item || typeof item !== 'object') return 'unknown'; + return String(item.order_item_id || item.stock_id || item.item_id || item.item_code || 'unknown'); + }, + isBarcodeExpanded(item) { + return !!this.barcodeExpandMap[this.getBarcodeExpandKey(item)]; + }, + toggleBarcodeExpand(item) { + const key = this.getBarcodeExpandKey(item); + this.$set(this.barcodeExpandMap, key, !this.barcodeExpandMap[key]); + }, + getBarcodeDisplayList(item) { + const list = this.getBarcodeList(item); + if (list.length > 3 && !this.isBarcodeExpanded(item)) { + return list.slice(0, 3); + } + return list; + }, + getBarcodeDisplayText(item) { + const list = this.getBarcodeDisplayList(item); + return list.length > 0 ? list.join(';') : '--'; }, getPickLocations(item) { const locs = item?.pick_locations; @@ -563,6 +710,40 @@ .filter(Boolean) .join('、'); }, + // 商品图片:优先取 stock.image_url + getItemImages(item) { + const raw = item?.stock?.image_url ?? item?.image_url; + if (Array.isArray(raw)) { + return raw.map(String).map(s => s.trim()).filter(Boolean); + } + if (typeof raw === 'string' && raw.trim()) { + return raw.split(/[;;,,\s]+/).map(s => s.trim()).filter(Boolean); + } + return []; + }, + getItemImageCount(item) { + return this.getItemImages(item).length; + }, + getItemFirstImage(item) { + return this.getItemImages(item)[0] || ''; + }, + getItemImageKey(item) { + return String(item?.order_item_id || item?.stock_id || item?.item_id || item?.item_code || 'unknown'); + }, + isItemImageError(item) { + return !!this.imageErrorMap[this.getItemImageKey(item)]; + }, + handleItemImageError(item) { + this.$set(this.imageErrorMap, this.getItemImageKey(item), true); + }, + previewItemImages(item, index) { + const urls = this.getItemImages(item); + if (!urls.length) return; + uni.previewImage({ + urls, + current: urls[index] || urls[0] + }); + }, getItemPackedQty(item) { const boxes = item?.boxes; if (!Array.isArray(boxes)) return 0; @@ -606,6 +787,8 @@ item_name: it.item_name, plan_qty: it.plan_qty, pick_locations: it.pick_locations || [], + stock: it.stock || null, + item_snapshot: it.item_snapshot || null, barcode: it.barcode, barcodes: it.barcodes, skuCode: it.skuCode, @@ -1213,9 +1396,20 @@ border: 1rpx solid #ebeef5; } + .goods-item__top { + display: flex; + align-items: flex-start; + margin-bottom: 12rpx; + } + + .goods-item__info { + flex: 1; + min-width: 0; + } + .goods-item__header { display: flex; - align-items: center; + align-items: flex-start; justify-content: space-between; margin-bottom: 12rpx; } @@ -1223,14 +1417,31 @@ .goods-item__name { flex: 1; min-width: 0; + } + + .goods-item__name-text { font-size: 36rpx; font-weight: bold; color: #303133; + word-break: break-all; + } + + .goods-item__actions { + flex-shrink: 0; + display: flex; + flex-direction: column; + align-items: flex-end; + margin-left: 12rpx; + } + + .goods-item__actions-top { + display: flex; + align-items: center; } .goods-item__scanned { flex-shrink: 0; - margin-left: 12rpx; + margin-top: 8rpx; padding: 2rpx 14rpx; font-size: 36rpx; line-height: 1.4; @@ -1239,6 +1450,20 @@ border-radius: 6rpx; } + .goods-item__scan-btn { + flex-shrink: 0; + margin-left: 12rpx; + width: 80rpx; + height: 80rpx; + display: flex; + align-items: center; + justify-content: center; + + &:active { + opacity: 0.7; + } + } + .goods-item__row { display: flex; align-items: center; @@ -1265,6 +1490,70 @@ color: #18a058; } + .goods-item__barcode-toggle { + flex-shrink: 0; + font-size: 36rpx; + color: #2979ff; + line-height: 1.4; + + &:active { + opacity: 0.7; + } + } + + .goods-item__images { + flex-shrink: 0; + margin-right: 16rpx; + } + + .goods-item__img-wrap { + position: relative; + width: 120rpx; + height: 120rpx; + } + + .goods-item__img { + width: 120rpx; + height: 120rpx; + border-radius: 8rpx; + background-color: #f5f7fa; + border: 1rpx solid #ebeef5; + } + + .goods-item__img--empty { + display: flex; + align-items: center; + justify-content: center; + } + + .goods-item__img--error { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + } + + .goods-item__img-error-text { + margin-top: 4rpx; + font-size: 20rpx; + color: #f56c6c; + } + + .goods-item__img-badge { + position: absolute; + right: 0; + bottom: 0; + padding: 2rpx 10rpx; + background: rgba(0, 0, 0, 0.5); + border-radius: 10rpx 0 8rpx 0; + pointer-events: none; + } + + .goods-item__img-badge-text { + font-size: 20rpx; + color: #ffffff; + } + .goods-item__boxes, .goods-item__locations { display: flex;