From 95651ccb192318937a41df4de769d5725ce8554c Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Mon, 10 Aug 2026 17:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E5=A4=8D?= =?UTF-8?q?=E6=A0=B8=E3=80=81=E5=95=86=E5=93=81=E6=9F=A5=E8=AF=A2=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order-review-comps/ReviewDetail.vue | 9 +- pages/work/order/order-review.vue | 55 ++++++- pages/work/product/detail.vue | 103 +++++++++---- pages/work/product/edit.vue | 135 ++++++++++++++---- pages/work/product/query.vue | 35 ++++- 5 files changed, 275 insertions(+), 62 deletions(-) diff --git a/pages/work/order/order-review-comps/ReviewDetail.vue b/pages/work/order/order-review-comps/ReviewDetail.vue index 5c09965..1f8e96c 100644 --- a/pages/work/order/order-review-comps/ReviewDetail.vue +++ b/pages/work/order/order-review-comps/ReviewDetail.vue @@ -749,11 +749,18 @@ import voice from '@/core/utils/voice'; .review-detail { display: flex; flex-direction: column; - height: 100%; + flex: 1; + min-height: 0; overflow: hidden; position: relative; } + /* u-popup 根元素默认带 flex:1(uview 全局样式),会参与本组件 flex 布局并与商品列表区平分空间, + 导致弹窗(v-if 渲染)弹出时底部合计行被顶到页面中间。这里让弹窗不参与 flex 分配(其内容为 fixed 定位,高度为 0,不占文档流)。 */ + ::v-deep .u-popup { + flex: none !important; + } + .content-layout { flex: 1; display: flex; diff --git a/pages/work/order/order-review.vue b/pages/work/order/order-review.vue index dcf1960..d1b0f2e 100644 --- a/pages/work/order/order-review.vue +++ b/pages/work/order/order-review.vue @@ -127,8 +127,8 @@ - - + + 称重 @@ -144,6 +144,7 @@ type="number" :value="weighWeight > 0 ? String(weighWeight) : ''" :focus="true" + :adjust-position="false" placeholder="请输入重量(g)" placeholder-style="color:#c0c4cc;font-size:36rpx" @input="handleWeighInput" @@ -161,8 +162,8 @@ - - + + 包材绑定 @@ -176,6 +177,7 @@ class="package-input" v-model="packageInputCode" :focus="packageBindingActivated" + :adjust-position="false" placeholder="扫描/输入包材条码" placeholder-style="color:#c0c4cc;font-size:32rpx" @confirm="handlePackageBindingInputConfirm" @@ -191,7 +193,7 @@ - + 复核设置 @@ -428,6 +430,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; showPrintModeDropdown: false, showSettingsPopup: false, showWeighPopup: false, + keyboardHeight: 0, weighWeight: 0, weighAfterReview: false, weighCancelled: false, @@ -573,6 +576,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; } }, onLoad(options) { + this.initKeyboardHeightListener(); this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult }); @@ -615,6 +619,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; this.safeDispatchBroadcast('pause'); }, onUnload() { + this.destroyKeyboardHeightListener(); this.safeDispatchBroadcast('stop'); uni.$off('orderInterceptCompleted', this.handleInterceptCompleted); if (this._debugMode) { @@ -626,6 +631,43 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; } }, methods: { + initKeyboardHeightListener() { + // H5 端:监听 visualViewport 高度变化,差值即键盘高度(仅垫高弹窗内容,不整页上推) + // #ifdef H5 + if (typeof window !== 'undefined' && window.visualViewport) { + this._baseViewportHeight = window.visualViewport.height; + this._onViewportResize = () => { + const vh = window.visualViewport ? window.visualViewport.height : window.innerHeight; + const diff = this._baseViewportHeight - vh; + this.keyboardHeight = diff > 0 ? Math.round(diff) : 0; + }; + window.visualViewport.addEventListener('resize', this._onViewportResize); + } + // #endif + // App/小程序端:使用原生键盘高度回调 + // #ifndef H5 + this._keyboardHeightCb = (res) => { + this.keyboardHeight = (res && res.height) || 0; + }; + if (typeof uni.onKeyboardHeightChange === 'function') { + uni.onKeyboardHeightChange(this._keyboardHeightCb); + } + // #endif + }, + destroyKeyboardHeightListener() { + // #ifdef H5 + if (typeof window !== 'undefined' && window.visualViewport && this._onViewportResize) { + window.visualViewport.removeEventListener('resize', this._onViewportResize); + this._onViewportResize = null; + } + // #endif + // #ifndef H5 + if (this._keyboardHeightCb && typeof uni.offKeyboardHeightChange === 'function') { + uni.offKeyboardHeightChange(this._keyboardHeightCb); + this._keyboardHeightCb = null; + } + // #endif + }, buildBatchListParams(page = this.currentPage) { const where = { source: 0, @@ -3451,6 +3493,8 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; min-height: 0; overflow: hidden; position: relative; + display: flex; + flex-direction: column; } .detail-area--empty { @@ -3465,6 +3509,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue'; flex-direction: column; align-items: center; justify-content: center; + flex: 1; } .empty-text { diff --git a/pages/work/product/detail.vue b/pages/work/product/detail.vue index dc40852..1cb9cb8 100644 --- a/pages/work/product/detail.vue +++ b/pages/work/product/detail.vue @@ -155,6 +155,26 @@ 保质期管理: {{ getFlagValue(item, ['is_shelf_life_mgmt', 'is_expiry_management', 'expiry_management', 'is_expiry', 'manage_expiry']) }} + 批次管理: {{ getFlagValue(item, ['is_batch_mgmt', 'is_batch_management', 'batch_management', 'is_batch', 'manage_batch']) }} @@ -184,33 +204,35 @@ {{ getFlagValue(item, ['enable_box_spec', 'enable_box_rule', 'is_box_rule', 'box_rule_enabled', 'use_box_rule', 'enabled_box_rule']) }} @@ -328,6 +350,17 @@ export default { } return false; }, + isShelfLifeMgmtEnabled(item) { + if (!item || typeof item !== 'object') { + return false; + } + + const val = item.is_shelf_life_mgmt ?? item.is_expiry_management ?? item.expiry_management ?? item.is_expiry ?? item.manage_expiry; + if (val === true || val === 1 || val === '1' || val === 'Y' || val === 'y' || val === '是' || String(val).toLowerCase() === 'true') { + return true; + } + return false; + }, getValue(item, fieldKeys) { if (!item || typeof item !== 'object' || !Array.isArray(fieldKeys)) { return '--'; @@ -713,6 +746,22 @@ export default { color: #303133; } +.shelf-life-block { + margin: 12rpx 0 16rpx; + padding: 20rpx; + border: 2rpx solid #dcdfe6; + border-radius: 12rpx; + background: #f8fafc; +} + +.box-spec-block { + margin: 12rpx 0 16rpx; + padding: 20rpx; + border: 2rpx solid #dcdfe6; + border-radius: 12rpx; + background: #f8fafc; +} + .info-row { display: flex; align-items: center; diff --git a/pages/work/product/edit.vue b/pages/work/product/edit.vue index 0fb82c0..7c65e04 100644 --- a/pages/work/product/edit.vue +++ b/pages/work/product/edit.vue @@ -57,6 +57,20 @@ + + + + + + + + + + + + + + @@ -79,27 +93,29 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -189,6 +205,10 @@ export default { is_sn_mgmt: false, is_shelf_life_mgmt: false, is_batch_mgmt: false, + shelf_life_days: '', + inbound_min_days: '', + outbound_min_days: '', + remaining_threshold_days: '', length: '', width: '', height: '', @@ -249,6 +269,10 @@ export default { this.formData.is_sn_mgmt = this.toBooleanFlag(cached.is_sn_mgmt); this.formData.is_shelf_life_mgmt = this.toBooleanFlag(cached.is_shelf_life_mgmt); this.formData.is_batch_mgmt = this.toBooleanFlag(cached.is_batch_mgmt); + this.formData.shelf_life_days = this.normalizeInputValue(cached.shelf_life_days); + this.formData.inbound_min_days = this.normalizeInputValue(cached.inbound_min_days); + this.formData.outbound_min_days = this.normalizeInputValue(cached.outbound_min_days); + this.formData.remaining_threshold_days = this.normalizeInputValue(cached.remaining_threshold_days); this.formData.length = this.normalizeInputValue(cached.length); this.formData.width = this.normalizeInputValue(cached.width); this.formData.height = this.normalizeInputValue(cached.height); @@ -988,6 +1012,9 @@ export default { toApiFlag(value) { return value ? 1 : 0; }, + toYesNoFlag(value) { + return value ? 'Y' : 'N'; + }, normalizeImageListForUpload(item) { if (!item || typeof item !== 'object') { return []; @@ -1247,6 +1274,31 @@ export default { } } + // 保质期校验:启用保质期管理时,保质期天数、入库最小天数、出库最小天数、剩余有效期均为必填且必须大于0 + const shelfLifeMgmtEnabled = this.toBooleanFlag(this.formData.is_shelf_life_mgmt); + if (shelfLifeMgmtEnabled) { + const shelfLifeFields = [ + { key: 'shelf_life_days', label: '保质期天数' }, + { key: 'inbound_min_days', label: '入库最小天数' }, + { key: 'outbound_min_days', label: '出库最小天数' }, + { key: 'remaining_threshold_days', label: '剩余有效期' } + ]; + + for (let i = 0; i < shelfLifeFields.length; i++) { + const field = shelfLifeFields[i]; + const valueText = String(this.formData[field.key] || '').trim(); + if (!valueText) { + this.showToastMessage(`${field.label}不能为空`); + return; + } + const numericValue = Number(valueText); + if (!Number.isFinite(numericValue) || numericValue <= 0) { + this.showToastMessage(`${field.label}必须大于0`); + return; + } + } + } + this.saving = true; try { const storeId = this.resolveStoreId(this.rawItem || {}); @@ -1280,9 +1332,13 @@ export default { prohibited_type_name: String(this.formData.prohibited_type_name || '').trim(), gross_weight: grossWeight, net_weight: String(this.formData.net_weight || '').trim(), - is_sn_mgmt: this.toApiFlag(this.formData.is_sn_mgmt), - is_shelf_life_mgmt: this.toApiFlag(this.formData.is_shelf_life_mgmt), - is_batch_mgmt: this.toApiFlag(this.formData.is_batch_mgmt), + is_sn_mgmt: this.toYesNoFlag(this.formData.is_sn_mgmt), + is_shelf_life_mgmt: this.toYesNoFlag(this.formData.is_shelf_life_mgmt), + is_batch_mgmt: this.toYesNoFlag(this.formData.is_batch_mgmt), + shelf_life_days: Number(this.formData.shelf_life_days) || 0, + inbound_min_days: Number(this.formData.inbound_min_days) || 0, + outbound_min_days: Number(this.formData.outbound_min_days) || 0, + remaining_threshold_days: Number(this.formData.remaining_threshold_days) || 0, length: String(this.formData.length || ''), width: String(this.formData.width || ''), height: String(this.formData.height || ''), @@ -1362,9 +1418,13 @@ export default { }, gross_weight: grossWeight, net_weight: String(this.formData.net_weight || '').trim(), - is_sn_mgmt: this.toApiFlag(this.formData.is_sn_mgmt), - is_shelf_life_mgmt: this.toApiFlag(this.formData.is_shelf_life_mgmt), - is_batch_mgmt: this.toApiFlag(this.formData.is_batch_mgmt), + is_sn_mgmt: this.toYesNoFlag(this.formData.is_sn_mgmt), + is_shelf_life_mgmt: this.toYesNoFlag(this.formData.is_shelf_life_mgmt), + is_batch_mgmt: this.toYesNoFlag(this.formData.is_batch_mgmt), + shelf_life_days: Number(this.formData.shelf_life_days) || 0, + inbound_min_days: Number(this.formData.inbound_min_days) || 0, + outbound_min_days: Number(this.formData.outbound_min_days) || 0, + remaining_threshold_days: Number(this.formData.remaining_threshold_days) || 0, length: String(this.formData.length || ''), width: String(this.formData.width || ''), height: String(this.formData.height || ''), @@ -1454,6 +1514,27 @@ export default { color: #303133; } +.shelf-life-block { + margin: 12rpx 0 16rpx; + padding: 8rpx 20rpx 20rpx; + border: 2rpx solid #dcdfe6; + border-radius: 12rpx; + background: #f8fafc; +} + +.box-spec-block { + margin: 12rpx 0 16rpx; + padding: 8rpx 20rpx 20rpx; + border: 2rpx solid #dcdfe6; + border-radius: 12rpx; + background: #f8fafc; +} + +::v-deep .shelf-life-block .u-form-item__body, +::v-deep .box-spec-block .u-form-item__body { + padding: 8rpx 0; +} + .picker-display { min-height: 72rpx; padding: 0 6rpx; diff --git a/pages/work/product/query.vue b/pages/work/product/query.vue index 21dbb44..a169e41 100644 --- a/pages/work/product/query.vue +++ b/pages/work/product/query.vue @@ -1599,13 +1599,44 @@ urls }); }, - goProductDetail(item) { + async goProductDetail(item) { if (!item || typeof item !== 'object') { return; } + // 进入详情前,按 id 精确拉取完整商品数据,避免列表合并/异步补充导致部分详情字段缺失 + const itemId = this.normalizePositiveId(item.id || item.stock_id); + let detailItem = item; + if (itemId) { + try { + const res = await this.$http('stock.warehouse.list', { + with_stock: true, + where: { + id: { + operator: 'eq', + value: itemId, + type: 'number' + } + }, + pagination: { + page: 1, + pageSize: 1 + } + }); + if (res && Number(res.code) === 200) { + const fetchedList = this.extractListFromResponse(res); + if (fetchedList && fetchedList.length) { + // 以完整商品数据为准,并保留列表项中的条码/图片等补充字段 + detailItem = { ...item, ...fetchedList[0] }; + } + } + } catch (error) { + console.warn('[ProductQuery] 获取商品完整详情失败:', error); + } + } + const cacheKey = `product_detail_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`; - uni.setStorageSync(cacheKey, item); + uni.setStorageSync(cacheKey, detailItem); uni.navigateTo({ url: `/pages/work/product/detail?cacheKey=${cacheKey}` });