From d8437120bc4a1e2868cd4436665b82a707508564 Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Sun, 15 Nov 2026 18:15:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=95=86=E5=93=81/=E5=A4=8D=E6=A0=B8):=20?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=E8=B6=853=E4=B8=AA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=94=B6=E8=B5=B7=E5=B9=B6=E6=94=AF=E6=8C=81=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E6=94=B6=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 商品查询/商品详情/订单复核列表:商品条码超过 3 个时默认收起,仅显示前 3 个,右侧显示「展开/收起」 - 订单复核详情:展开/收起按钮移至条码文本前固定位置,避免条码过多时按钮被推到末尾;字号调整为 36rpx - 商品详情:展开后条码区域限制最大高度并支持内部滚动,同时动态测量固定头部高度撑开占位,避免溢出遮挡 - 商品查询:切换展开后刷新库存区定位,保证悬浮表头位置正确;字号调整为 36rpx --- .../order/order-review-comps/ReviewDetail.vue | 6 +- src/pages/work/product/detail.vue | 162 +++++++++++++++++- src/pages/work/product/query.vue | 128 +++++++++++++- 3 files changed, 287 insertions(+), 9 deletions(-) diff --git a/src/pages/work/order/order-review-comps/ReviewDetail.vue b/src/pages/work/order/order-review-comps/ReviewDetail.vue index 5989c2b..048731a 100644 --- a/src/pages/work/order/order-review-comps/ReviewDetail.vue +++ b/src/pages/work/order/order-review-comps/ReviewDetail.vue @@ -122,8 +122,8 @@ {{ item.skuName || '--' }} {{'、'}} - {{ displayBarcode(item) }} {{ isBarcodeExpanded(item) ? '收起' : '展开' }} + {{ displayBarcode(item) }} {{'、'}} {{ item.location || '--' }} @@ -1726,10 +1726,10 @@ import voice from '@/core/utils/voice'; } .barcode-toggle { - font-size: 32rpx; + font-size: 36rpx; color: #2979ff; line-height: 1.5; - margin-left: 12rpx; + margin-right: 12rpx; padding: 0 10rpx; } diff --git a/src/pages/work/product/detail.vue b/src/pages/work/product/detail.vue index 5d327eb..929d608 100644 --- a/src/pages/work/product/detail.vue +++ b/src/pages/work/product/detail.vue @@ -67,16 +67,30 @@ 商品编码: {{ item.item_code || item.goods_code || '--' }} - + 条码: - {{ getBarcodeText(item) }} + + + {{ getBarcodeDisplayText(item) }} + + {{ getBarcodeDisplayText(item) }} + {{ isBarcodeExpanded(item) ? '收起' : '展开' }} + - + @@ -276,7 +290,11 @@ export default { title: '商品详情', item: null, cacheKey: '', - onProductUpdated: null + onProductUpdated: null, + // 条码展开状态(按商品 id 记录),条码超过 3 个时默认收起 + barcodeExpandMap: {}, + // 固定头部实际高度(px),用于撑开占位,避免条码展开后遮挡下方内容 + headerPlaceholderHeight: 0 }; }, onLoad(options) { @@ -305,8 +323,13 @@ export default { const cached = uni.getStorageSync(this.cacheKey); if (cached && typeof cached === 'object') { this.item = cached; + this.refreshHeaderPlaceholderHeight(); } }, + onReady() { + // 页面首次渲染完成后测量固定头部高度,撑开占位 + this.refreshHeaderPlaceholderHeight(); + }, onShow() { // 从编辑页返回时,重新读取缓存,确保展示最新数据(含商品条码) if (this.cacheKey) { @@ -318,6 +341,7 @@ export default { }; } } + this.refreshHeaderPlaceholderHeight(); }, onUnload() { if (this.onProductUpdated) { @@ -404,6 +428,100 @@ export default { return String(val); }, + getBarcodeList(item) { + if (!item || typeof item !== 'object') { + return []; + } + + const barcodes = item.barcodes; + if (Array.isArray(barcodes)) { + return barcodes + .filter(code => code !== null && code !== undefined && code !== '') + .map(code => String(code).trim()) + .filter(Boolean); + } + + if (typeof barcodes === 'string' && barcodes.trim()) { + return barcodes + .split(/[;;,,\s]+/) + .map(code => code.trim()) + .filter(Boolean); + } + + const fallback = item.barcode || item.code; + if (Array.isArray(fallback)) { + return fallback + .filter(code => code !== null && code !== undefined && code !== '') + .map(code => String(code).trim()) + .filter(Boolean); + } + + if (typeof fallback === 'string' && fallback.trim()) { + return [fallback.trim()]; + } + + return []; + }, + 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.id + || item.stock_id + || item.goods_id + || item.item_id + || item.item_code + || item.goods_code + || item.barcode + || 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]); + // 展开/收起会改变固定头部高度,重新测量并撑开占位,避免遮挡下方内容 + this.refreshHeaderPlaceholderHeight(); + }, + refreshHeaderPlaceholderHeight() { + this.$nextTick(() => { + uni.createSelectorQuery().in(this).select('.detail-fixed-header').boundingClientRect(rect => { + if (rect && rect.height) { + this.headerPlaceholderHeight = Number(rect.height); + } + }).exec(); + }); + }, + 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); + if (list.length > 0) { + return list.join(';'); + } + + if (!item || typeof item !== 'object') { + return '--'; + } + + return item.barcode || item.code || '--'; + }, getBarcodeText(item) { if (!item || typeof item !== 'object') { return '--'; @@ -754,6 +872,42 @@ export default { word-break: break-all; } +.compact-row--barcode { + align-items: flex-start; +} + +.barcode-value { + display: flex; + align-items: flex-start; + flex-wrap: wrap; +} + +.barcode-text { + flex: 1; + min-width: 0; + font-size: 40rpx; + color: #000; + word-break: break-all; +} + +.barcode-scroll { + flex: 1; + min-width: 0; + max-height: 280rpx; +} + +.barcode-toggle { + flex-shrink: 0; + margin-left: 12rpx; + font-size: 36rpx; + color: #2979ff; + line-height: 1.4; + + &:active { + opacity: 0.7; + } +} + .detail-section-title { padding: 24rpx 0 12rpx; font-size: 35rpx; diff --git a/src/pages/work/product/query.vue b/src/pages/work/product/query.vue index 024e676..fd6d020 100644 --- a/src/pages/work/product/query.vue +++ b/src/pages/work/product/query.vue @@ -99,9 +99,16 @@ 编码: {{ item.item_code || item.goods_code || '--' }} - + 条码: - {{ getBarcodeText(item) }} + + {{ getBarcodeDisplayText(item) }} + {{ isBarcodeExpanded(item) ? '收起' : '展开' }} + SKU规格: @@ -336,6 +343,8 @@ productImageCache: {}, productBarcodeCache: {}, CACHE_TTL: 5 * 60 * 1000, + // 条码展开状态(按商品 id 记录),条码超过 3 个时默认收起 + barcodeExpandMap: {}, // 明细/库位切换时复用:避免重新搜索导致整页 loading 闪烁 searchListCache: [], warehouseListCache: [], @@ -1051,6 +1060,91 @@ } return []; }, + getBarcodeList(item) { + if (!item || typeof item !== 'object') { + return []; + } + + const barcodes = item.barcodes; + if (Array.isArray(barcodes)) { + return barcodes + .filter(code => code !== null && code !== undefined && code !== '') + .map(code => String(code).trim()) + .filter(Boolean); + } + + if (typeof barcodes === 'string' && barcodes.trim()) { + return barcodes + .split(/[;;,,\s]+/) + .map(code => code.trim()) + .filter(Boolean); + } + + const fallback = item.barcode || item.code; + if (Array.isArray(fallback)) { + return fallback + .filter(code => code !== null && code !== undefined && code !== '') + .map(code => String(code).trim()) + .filter(Boolean); + } + + if (typeof fallback === 'string' && fallback.trim()) { + return [fallback.trim()]; + } + + return []; + }, + 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.id + || item.stock_id + || item.goods_id + || item.item_id + || item.item_code + || item.goods_code + || item.barcode + || 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]); + // 展开/收起会改变商品摘要高度,刷新库存区定位信息,保证悬浮表头位置正确 + this.scheduleRefreshStorageSectionMetas(); + }, + 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); + if (list.length > 0) { + return list.join(';'); + } + + if (!item || typeof item !== 'object') { + return '--'; + } + + return item.barcode || item.code || '--'; + }, getBarcodeText(item) { if (!item || typeof item !== 'object') { return '--'; @@ -3028,6 +3122,36 @@ margin-bottom: 0; } + .item-row--barcode { + align-items: flex-start; + } + + .barcode-value { + display: flex; + align-items: flex-start; + flex-wrap: wrap; + } + + .barcode-text { + flex: 1; + min-width: 0; + font-size: 40rpx; + color: #000; + word-break: break-all; + } + + .barcode-toggle { + flex-shrink: 0; + margin-left: 12rpx; + font-size: 36rpx; + color: #2979ff; + line-height: 1.4; + + &:active { + opacity: 0.7; + } + } + .storage-section { margin-top: 20rpx; padding-top: 0;