diff --git a/core/request/index.js b/core/request/index.js index 2e96497..6c556f2 100644 --- a/core/request/index.js +++ b/core/request/index.js @@ -16,6 +16,7 @@ export default function http( let api = getApiPath(url); console.log(api); const token = uni.getStorageSync('token'); + console.log('[Request] token:', token); if (api.auth && !token) { store.dispatch('logout'); uni.hideLoading(); @@ -27,6 +28,7 @@ export default function http( Request.interceptor.request((config, cancel) => { token && Request.setConfig(config => { config.header.authorization = `Bearer ${token}` + console.log('[Request] Authorization:', config.header.authorization); }) if (toastBefore !== '') { uni.showLoading({ diff --git a/pages/work/product/query.vue b/pages/work/product/query.vue index a589d40..64f488c 100644 --- a/pages/work/product/query.vue +++ b/pages/work/product/query.vue @@ -47,7 +47,37 @@ - + + + + + + + + + + + 暂无商品数据 @@ -56,119 +86,143 @@ - - {{ item.item_name || item.product_name || item.name || '未命名商品' }} - - - - - - - - + + {{ item.item_name || item.product_name || item.name || '未命名商品' }} + + + + - + + + + + + + - - - - +{{ getExtraImageCount(item) }} + + + + + +{{ getExtraImageCount(item) }} + - - - - 货主: - {{ getStoreOwnerText(item) }} + + + 货主: + {{ getStoreOwnerText(item) }} + + + 商品编码: + {{ item.goods_code || item.item_code || '--' }} + + + 条码: + {{ getBarcodeText(item) }} + + + SKU规格: + {{ item.sku_property || '--' }} + + + 批次号: + {{ getBatchNumberText(item) }} + - - 商品编码: - {{ item.goods_code || item.item_code || '--' }} + + - - 条码: - {{ getBarcodeText(item) }} - - - SKU规格: - {{ item.sku_property || '--' }} - - - 批次号: - {{ getBatchNumberText(item) }} - - - - - - - - - 库位 - 库存 - 可移库存 - + + - {{ getStorageSpaceText(storageItem) }} - {{ getStorageQuantityText(storageItem) }} - {{ getStorageAvailableText(storageItem) }} + + 库位 + 库存 + 可移库存 + + + + + {{ getStorageSpaceText(storageItem) }} + {{ getStorageQuantityText(storageItem) }} + {{ getStorageAvailableText(storageItem) }} + + - - - - - 批次号 - 库位 - 库存 - 可移库存 - + + - {{ getBatchNumberBySource(storageItem, item) }} - {{ getStorageSpaceText(storageItem) }} - {{ getStorageQuantityText(storageItem) }} - {{ getStorageAvailableText(storageItem) }} + + 批次号 + 库位 + 库存 + 可移库存 + + + + + {{ getBatchNumberBySource(storageItem, item) }} + {{ getStorageSpaceText(storageItem) }} + {{ getStorageQuantityText(storageItem) }} + {{ getStorageAvailableText(storageItem) }} + + @@ -177,7 +231,8 @@ 没有更多了 - + + @@ -195,7 +250,17 @@ list: [], rawList: [], restoreScrollTop: 0, - listScrollTopCache: 0 + listScrollTopCache: 0, + storageScrollLeftMap: {}, + storageSectionMetas: [], + storageHeaderHeight: 0, + pageHeaderHeight: 0, + floatingStorageHeader: { + visible: false, + mode: 'nonBatch', + sectionKey: '', + top: 0 + } } }, onLoad() { @@ -215,6 +280,7 @@ const top = cachedTop > 0 ? cachedTop : 0; this.restoreScrollTop = top; this.listScrollTopCache = top; + this.refreshStorageSectionMetas(); }); }, onHide() { @@ -240,6 +306,116 @@ handleListScroll(event) { const top = event && event.detail ? Number(event.detail.scrollTop || 0) : 0; this.listScrollTopCache = top; + this.updateFloatingStorageHeader(top); + }, + getStorageSectionKey(item, index, mode = 'nonBatch') { + if (!item || typeof item !== 'object') { + return `${mode}_${index}`; + } + + return `${mode}_${item.id || item.goods_code || item.item_code || item.barcode || index}`; + }, + getStorageScrollLeft(sectionKey) { + return Number(this.storageScrollLeftMap[sectionKey] || 0); + }, + handleStorageHorizontalScroll(sectionKey, event) { + const scrollLeft = event && event.detail ? Number(event.detail.scrollLeft || 0) : 0; + if (this.getStorageScrollLeft(sectionKey) === scrollLeft) { + return; + } + + this.$set(this.storageScrollLeftMap, sectionKey, scrollLeft); + if (this.floatingStorageHeader.visible && this.floatingStorageHeader.sectionKey === sectionKey) { + this.floatingStorageHeader = { + ...this.floatingStorageHeader, + sectionKey + }; + } + }, + getStorageHeadStyle(sectionKey) { + const scrollLeft = this.getStorageScrollLeft(sectionKey); + return { + transform: `translateX(-${scrollLeft}px)` + }; + }, + refreshStorageSectionMetas() { + this.$nextTick(() => { + const query = uni.createSelectorQuery().in(this); + query.select('.page-header').boundingClientRect(); + query.select('.list-content').boundingClientRect(); + query.select('.storage-head-fixed').boundingClientRect(); + query.selectAll('.item-summary').boundingClientRect(); + query.selectAll('.storage-section').boundingClientRect(); + query.exec(result => { + const pageHeaderRect = result && result[0] ? result[0] : null; + const listRect = result && result[1] ? result[1] : null; + const headerRect = result && result[2] ? result[2] : null; + const summaryRects = (result && result[3]) || []; + const sectionRects = (result && result[4]) || []; + this.pageHeaderHeight = pageHeaderRect && pageHeaderRect.height ? Number(pageHeaderRect.height) : 0; + if (!listRect || !Array.isArray(sectionRects) || !sectionRects.length) { + this.storageSectionMetas = []; + this.storageHeaderHeight = headerRect && headerRect.height ? Number(headerRect.height) : 0; + this.updateFloatingStorageHeader(this.listScrollTopCache); + return; + } + + const headerHeight = headerRect && headerRect.height ? Number(headerRect.height) : 0; + let sectionCursor = 0; + const metas = []; + (this.list || []).forEach((item, index) => { + const hasStorage = this.queryMode === 'batch' + ? this.getBatchStorageList(item).length + : this.getStorageList(item).length; + if (!hasStorage) { + return; + } + + const rect = sectionRects[sectionCursor++]; + if (!rect) { + return; + } + + metas.push({ + key: this.getStorageSectionKey(item, index, this.queryMode), + mode: this.queryMode, + top: this.listScrollTopCache + Number(rect.top || 0) - Number(listRect.top || 0), + height: Number(rect.height || 0), + headerHeight, + summaryHeight: Number((summaryRects[index] && summaryRects[index].height) || 0) + }); + }); + + this.storageHeaderHeight = headerHeight; + this.storageSectionMetas = metas; + this.updateFloatingStorageHeader(this.listScrollTopCache); + }); + }); + }, + updateFloatingStorageHeader(scrollTop = 0) { + const passedMetas = this.storageSectionMetas.filter(meta => { + const summaryHeight = Number(meta.summaryHeight || 0); + const startTop = meta.top - summaryHeight; + return scrollTop >= startTop; + }); + const activeMeta = passedMetas.length ? passedMetas[passedMetas.length - 1] : null; + + if (!activeMeta) { + this.floatingStorageHeader = { + visible: false, + mode: this.queryMode, + sectionKey: '', + top: 0 + }; + return; + } + + this.floatingStorageHeader = { + visible: true, + mode: activeMeta.mode, + sectionKey: activeMeta.key, + top: this.pageHeaderHeight + Math.max(Number(activeMeta.summaryHeight || 0), 0) + }; }, normalizeKeyword(value) { return String(value || '').replace(/\s+/g, ''); @@ -459,6 +635,7 @@ : this.filterByNameContains(sourceList, keyword); this.list = this.applyQueryModeFilter(filteredByKeyword); + this.refreshStorageSectionMetas(); }, buildQueryParams(keyword) { return { @@ -476,6 +653,7 @@ const keyword = this.normalizeKeyword(this.keyword); if (!keyword) { this.list = this.applyQueryModeFilter(this.rawList); + this.refreshStorageSectionMetas(); return; } @@ -663,6 +841,13 @@ if (!keyword) { this.rawList = []; this.list = []; + this.storageSectionMetas = []; + this.floatingStorageHeader = { + visible: false, + mode: this.queryMode, + sectionKey: '', + top: 0 + }; console.log('[ProductQuery] 搜索内容为空,结果已清空'); return; } @@ -867,14 +1052,37 @@ } } + .list-content-wrap { + flex: 1; + min-height: 0; + position: relative; + display: flex; + flex-direction: column; + overflow: hidden; + } + .list-content { flex: 1; min-height: 0; - height: auto; + height: 100%; position: relative; z-index: 0; } + .floating-storage-head { + position: fixed; + left: 24rpx; + right: 24rpx; + overflow: hidden; + border: 1rpx solid #dfe7f5; + border-bottom: 0; + border-radius: 10rpx 10rpx 0 0; + background: #edf4ff; + box-sizing: border-box; + z-index: 40; + pointer-events: none; + } + .list-wrap { padding: 20rpx 8rpx; } @@ -889,6 +1097,16 @@ position: relative; } + .item-summary { + position: sticky; + top: 0; + background: #fff; + padding-bottom: 10rpx; + margin-bottom: 4rpx; + border-radius: 12rpx 12rpx 0 0; + box-shadow: 0 6rpx 14rpx rgba(15, 23, 42, 0.06); + } + .item-main-row { display: flex; align-items: center; @@ -1012,6 +1230,17 @@ margin-top: 10rpx; padding-top: 10rpx; border-top: 1rpx solid #eef1f6; + position: relative; + } + + .storage-head-fixed { + position: relative; + overflow: hidden; + border: 1rpx solid #dfe7f5; + border-bottom: 0; + border-radius: 10rpx 10rpx 0 0; + background: #edf4ff; + box-sizing: border-box; } .storage-scroll { @@ -1023,6 +1252,11 @@ box-sizing: border-box; } + .storage-scroll--body { + border-top: 0; + border-radius: 0 0 10rpx 10rpx; + } + .storage-table { background: #f8faff; overflow: visible; @@ -1031,6 +1265,11 @@ vertical-align: top; } + .storage-table--head-table { + background: #edf4ff; + will-change: transform; + } + .storage-table--non-batch { min-width: 680rpx; } @@ -1054,9 +1293,8 @@ .storage-table__head { background: #edf4ff; border-bottom: 1rpx solid #dbe6f7; - position: sticky; - top: 0; - z-index: 8; + position: relative; + z-index: 1; box-shadow: 0 2rpx 6rpx rgba(219, 230, 247, 0.65); } diff --git a/pages/work/storage/receiving/components/ProductInfoEditor.vue b/pages/work/storage/receiving/components/ProductInfoEditor.vue index a607474..37ef8b0 100644 --- a/pages/work/storage/receiving/components/ProductInfoEditor.vue +++ b/pages/work/storage/receiving/components/ProductInfoEditor.vue @@ -102,7 +102,8 @@ - + 箱 @@ -333,6 +334,7 @@ emitTimer: null, isInitializing: false, initialized: false, + boxQuantityManuallyEdited: false, }; }, computed: { @@ -398,6 +400,7 @@ } this.formData = newFormData; + this.boxQuantityManuallyEdited = false; // 初始化商品图片 if (data.product_snapshot?.images) { @@ -406,8 +409,12 @@ })); } - // 计算箱数但不触发 emitFormData - this.calculateBoxQuantity(false); + // 无已有箱数时默认自动计算;有值时保留原值,允许后续手动修改 + if (newFormData.box_quantity === null || newFormData.box_quantity === undefined || newFormData.box_quantity === '') { + this.calculateBoxQuantity(false, { + force: true + }); + } try { console.log("清除") setTimeout(() => { @@ -503,9 +510,32 @@ this.calculateBoxQuantity(true); }, + // 箱数输入处理 + handleBoxQuantityBlur() { + const boxQuantity = String(this.formData.box_quantity || '').trim(); + if (!boxQuantity) { + this.boxQuantityManuallyEdited = false; + this.calculateBoxQuantity(true, { + force: true + }); + return; + } + + this.boxQuantityManuallyEdited = true; + this.emitFormData(); + }, + // 计算箱数 - calculateBoxQuantity(shouldEmit = true) { + calculateBoxQuantity(shouldEmit = true, options = {}) { console.log("计算箱数", shouldEmit); + const force = !!options.force; + if (this.boxQuantityManuallyEdited && !force) { + if (shouldEmit) { + this.emitFormData(); + } + return; + } + let actualQuantity = parseFloat(this.formData.actual_quantity); let boxesPerPallet = parseFloat(this.formData.boxes_per_pallet);