From 3762a36433814c37826701cbfc861222f3b31440 Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Mon, 30 Mar 2026 15:23:28 +0800 Subject: [PATCH] feat: optimize product query and detail pages --- core/store/modules/broadcast.js | 21 +-- pages/work/product/detail.vue | 270 +++++++++++++++++++++++++++----- pages/work/product/query.vue | 181 +++++++++++++-------- 3 files changed, 352 insertions(+), 120 deletions(-) diff --git a/core/store/modules/broadcast.js b/core/store/modules/broadcast.js index 33adbc2..e7e2f78 100644 --- a/core/store/modules/broadcast.js +++ b/core/store/modules/broadcast.js @@ -80,7 +80,7 @@ const actions = { commit, state }) { - if (!state.initialized) { + if (!state || !state.initialized) { console.error('[Broadcast] 请先初始化模块'); return false; } @@ -109,7 +109,7 @@ const actions = { commit, state }) { - if (!state.enabled) { + if (!state || !state.enabled) { return true; } @@ -124,10 +124,12 @@ const actions = { * 暂停监听 */ pause({ - commit + commit, + state }) { return actions.stop({ - commit + commit, + state: state || {} }); }, @@ -155,7 +157,7 @@ const actions = { throw new Error('配置必须包含broadcastAction'); } - if (!state.enabled) { + if (!state || !state.enabled) { console.warn('[Broadcast] 广播功能已禁用,配置更新无效'); return false; } @@ -199,7 +201,7 @@ const actions = { throw new Error('Action不能为空'); } - if (!state.enabled) { + if (!state || !state.enabled) { console.warn('[Broadcast] 广播功能已禁用,Action更新无效'); return false; } @@ -222,11 +224,12 @@ const actions = { state }) { const scannerStatus = scanner.getStatus(); + const safeState = state || {}; return { ...scannerStatus, - moduleEnabled: state.enabled, - moduleInitialized: state.initialized, - moduleActive: state.active + moduleEnabled: !!safeState.enabled, + moduleInitialized: !!safeState.initialized, + moduleActive: !!safeState.active }; }, diff --git a/pages/work/product/detail.vue b/pages/work/product/detail.vue index c89423e..f68e534 100644 --- a/pages/work/product/detail.vue +++ b/pages/work/product/detail.vue @@ -5,47 +5,89 @@ - - - - + + + + 商品编码: + {{ item.goods_code || item.item_code || '--' }} + + + 条码: + {{ getBarcodeText(item) }} + + + - - {{ item.item_name || item.product_name || item.name || '未命名商品' }} + + 名称: + {{ item.item_name || item.product_name || item.name || '未命名商品' }} 货主: {{ getStoreOwnerText(item) }} - 商品编码: - {{ item.goods_code || item.item_code || '--' }} + 毛重: + {{ item.gross_weight || '--' }} - 条码: - {{ getBarcodeText(item) }} + 品牌: + {{ item.brand_name || '--' }} + + + 违禁品类型: + {{ (item.prohibited && item.prohibited.type_name) || '--' }} SKU规格: {{ item.sku_property || '--' }} - - 库存单位: - {{ item.stock_unit || '--' }} - 库存数量: {{ getValueOrDash(item.quantity) }} @@ -54,6 +96,46 @@ 锁定量: {{ getValueOrDash(item.locked_quantity) }} + + 可用库存: + {{ item.available_quantity || '--' }} + + + 锁定率: + {{ item.lock_rate_display || '--' }} + + + 库存单位: + {{ item.stock_unit || '--' }} + + + 标价: + + ¥{{ item.tag_price || '--' }} + + + + 零售价: + + ¥{{ item.retail_price || '--' }} + + + + ABC分类: + {{ item.level || '--' }} + + + 体积: + {{ item.box_volume || '--' }} + + + 创建时间: + {{ item.create_at_display || '--' }} + + + 更新时间: + {{ item.update_at_display || '--' }} + @@ -147,6 +229,13 @@ export default { const single = this.getImageUrl(item); return single ? [single] : []; }, + getImageThumbList(item) { + return this.getImageList(item).slice(0, 4); + }, + getExtraImageCount(item) { + const total = this.getImageList(item).length; + return total > 4 ? total - 4 : 0; + }, previewProductImage(item) { const urls = this.getImageList(item); if (!urls.length) { @@ -215,26 +304,16 @@ export default { padding: 20rpx; } -.image-section { - margin-bottom: 16rpx; +.detail-header { + padding-bottom: 18rpx; + border-bottom: 2rpx solid #e5e7eb; } -.main-image { - border-radius: 10rpx; - overflow: hidden; - background: #f5f7fa; +.info-section { + padding-top: 16rpx; } -.image-placeholder { - width: 100%; - height: 360rpx; - display: flex; - align-items: center; - justify-content: center; - background: #f5f7fa; -} - -.name-row { +.item-title-row { margin-bottom: 10rpx; } @@ -244,6 +323,112 @@ export default { color: #303133; } +.item-main-row { + display: flex; + align-items: center; +} + +.item-thumb { + width: 90rpx; + margin-right: 20rpx; + flex-shrink: 0; +} + +.goods-image { + border-radius: 10rpx; + overflow: hidden; + background: #f5f7fa; +} + +.goods-image-grid { + width: 90rpx; + height: 90rpx; + display: flex; + flex-wrap: wrap; + justify-content: space-between; + align-content: space-between; +} + +.grid-cell { + position: relative; + width: 44rpx; + height: 44rpx; + border-radius: 8rpx; + overflow: hidden; + background: #f5f7fa; +} + +.grid-image { + border-radius: 8rpx; + overflow: hidden; +} + +.image-placeholder { + width: 90rpx; + height: 90rpx; + display: flex; + align-items: center; + justify-content: center; + background: #f5f7fa; +} + +.image-placeholder-small { + width: 44rpx; + height: 44rpx; +} + +.more-mask { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.45); + display: flex; + align-items: center; + justify-content: center; +} + +.more-text { + font-size: 18rpx; + color: #fff; + font-weight: 600; +} + +.item-info { + flex: 1; + min-width: 0; +} + +.compact-row { + display: flex; + align-items: center; + line-height: 1.4; + margin-bottom: 2rpx; +} + +.compact-row:last-child { + margin-bottom: 0; +} + +.compact-label { + width: auto; + margin-right: 6rpx; + font-size: 24rpx; + color: #909399; + white-space: nowrap; + flex-shrink: 0; +} + +.compact-value { + flex: 1; + font-size: 24rpx; + color: #000; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + .info-row { display: flex; align-items: center; @@ -256,7 +441,8 @@ export default { } .label { - width: 120rpx; + width: auto; + margin-right: 6rpx; font-size: 24rpx; color: #909399; flex-shrink: 0; @@ -265,7 +451,7 @@ export default { .value { flex: 1; font-size: 24rpx; - color: #606266; + color: #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; diff --git a/pages/work/product/query.vue b/pages/work/product/query.vue index 6a7edfe..3b6493f 100644 --- a/pages/work/product/query.vue +++ b/pages/work/product/query.vue @@ -15,7 +15,7 @@ > - + 暂无商品数据 @@ -23,17 +23,19 @@ - + + + {{ item.item_name || item.product_name || item.name || '未命名商品' }} + - +