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;