diff --git a/package.json b/package.json index b79e542..985be48 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wms-pda", - "version": "1.0.147", + "version": "1.0.148", "private": true, "description": "天豹云仓 WMS_PDA(uni-app Vue2 + @vue/cli 4.5)", "scripts": { diff --git a/src/manifest.json b/src/manifest.json index f341bd4..eb7e0a0 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "WMS_PDA", "appid" : "__UNI__0B3DAD3", "description" : "多平台快速开发的UI框架", - "versionName" : "1.0.147", - "versionCode" : 1000147, + "versionName" : "1.0.148", + "versionCode" : 1000148, "transformPx" : false, "app-plus" : { "statusbar" : { diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 2b9cd3c..8321ef7 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -3,9 +3,9 @@ - - - + + + {{ item.value }} {{ item.label }} @@ -176,8 +176,14 @@ - - {{ item.value }} + + {{ item.value }} {{ item.label }} @@ -216,6 +222,12 @@ '#8338EC', '#2EC4B6' ] + // 未移库临时库位 / 未移库临时库位可分配储位 的库位ID + const TEMP_SPACE_IDS = { + temp: 26937, + assignable: 26938 + } + // 看板统计相关的菜单识别(后台菜单名可能调整,保留关键字兜底) const isReviewShippingMenuName = name => name === '散单复核发货' || name === '订单复核' || @@ -270,6 +282,8 @@ hasOrderPickingMenu: false, hasClaimShippingMenu: false, unclaimedWaveCount: 0, + tempSpaceItemKindCount: 0, + tempSpaceAssignableCount: 0, showNoticePopup: false, quickActions: [], // 每页 9 个:3 列 × 3 行 @@ -391,9 +405,6 @@ noticeStats() { const stats = this.dashboardStats || null; const showUnclaimed = this.hasClaimShippingMenu && this.hasOrderPickingMenu; - if (!stats && !showUnclaimed) { - return []; - } const f = this.formatStatNumber; const items = []; @@ -409,6 +420,9 @@ if (stats && this.hasReviewShippingMenu) { items.push({ label: '已复核', value: f(stats.recheckedOrders) }); } + // 临时库位 / 临时库位可分配储位 的待移库商品种类数(仅走马灯与通知信息弹窗展示,顶部面板不展示) + items.push({ label: '未移库临时库位', value: f(this.tempSpaceItemKindCount), panel: false, spaceId: TEMP_SPACE_IDS.temp }); + items.push({ label: '未移库临时库位可分配储位', value: f(this.tempSpaceAssignableCount), panel: false, spaceId: TEMP_SPACE_IDS.assignable }); return items; }, @@ -426,6 +440,11 @@ return `${Math.max(8, len * 0.4)}s`; }, + // 顶部面板数据源:仅看板类统计,不含临时库位两项 + panelStatItems() { + return this.noticeStats.filter(item => item.panel !== false); + }, + noticeStatItems() { return this.noticeStats; } @@ -655,10 +674,11 @@ async loadUserInfo({ silent = false } = {}) { // 菜单加载会决定看板统计是否展示,必须先完成 await this.refreshQuickActions({ silent }); - // 两个统计接口互不依赖,并行请求 + // 各统计接口互不依赖,并行请求 await Promise.all([ this.loadDashboardStats(), - this.loadUnclaimedWaveCount() + this.loadUnclaimedWaveCount(), + this.loadTempSpaceStockCounts() ]); }, @@ -804,6 +824,73 @@ } }, + // 加载临时库位 / 临时库位可分配储位 的待移库商品种类数 + // 接口 storage.inventory.listBySpaceId,统计「库存 > 0」的商品种类数 + async loadTempSpaceStockCounts() { + const [tempCount, assignableCount] = await Promise.all([ + this.fetchSpaceStockKindCount(TEMP_SPACE_IDS.temp), + this.fetchSpaceStockKindCount(TEMP_SPACE_IDS.assignable) + ]); + this.tempSpaceItemKindCount = tempCount; + this.tempSpaceAssignableCount = assignableCount; + }, + + async fetchSpaceStockKindCount(spaceId) { + try { + const res = await this.$http( + 'storage.inventory.listBySpaceId', + { space_id: spaceId }, + '', + false + ); + const data = res && res.data && typeof res.data === 'object' ? res.data : {}; + const list = Array.isArray(data.list) ? data.list : []; + return list.filter(item => this.stockQuantityOf(item) > 0).length; + } catch (error) { + console.warn('[index] 临时库位待移库商品种类数加载失败:', error); + return 0; + } + }, + + // 库存 = 可用数量 + 锁定数量,都取不到时回退原始库存字段 + stockQuantityOf(item) { + if (!item || typeof item !== 'object') { + return null; + } + const locked = this.stockToNumberOrNull( + item.locked_quantity + ?? item.lock_quantity + ?? item.frozen_quantity + ?? item.freeze_quantity + ); + const available = this.stockToNumberOrNull( + item.available_quantity + ?? item.movable_quantity + ?? item.moveable_quantity + ?? item.can_move_quantity + ?? item.free_quantity + ?? item.usable_quantity + ); + if (available !== null || locked !== null) { + return (available === null ? 0 : available) + (locked === null ? 0 : locked); + } + return this.stockToNumberOrNull( + item.quantity + ?? item.actual_quantity + ?? item.stock + ?? item.total_quantity + ?? item.qty + ); + }, + + stockToNumberOrNull(value) { + if (value === null || value === undefined || value === '') { + return null; + } + const num = Number(value); + return Number.isNaN(num) ? null : num; + }, + formatStatNumber(value) { const num = Number(value); return Number.isFinite(num) ? num : '--'; @@ -1594,6 +1681,17 @@ this.showNoticePopup = false; }, + // 点击通知项跳转库位查询(带库位ID,并预置「库存>0」筛选) + goLocationInquiry(spaceId) { + const id = Number(spaceId); + if (!Number.isInteger(id) || id <= 0) { + return; + } + uni.navigateTo({ + url: `/pages/warehouse/locationInquiry?space_id=${encodeURIComponent(id)}&filter_type=stock` + }); + }, + toEditPage() { uni.navigateTo({ url: '/pages/home/edit-quick-actions' @@ -2359,6 +2457,17 @@ font-size: 34rpx; color: #909399; } + + &__value--link { + border-bottom: 4rpx solid #2979ff; + padding-bottom: 6rpx; + } + + &__item--link { + &:active { + background: #eef3ff; + } + } } /* 退出应用确认弹窗 */ diff --git a/src/pages/warehouse/locationInquiry.vue b/src/pages/warehouse/locationInquiry.vue index 29809b1..f283d0c 100644 --- a/src/pages/warehouse/locationInquiry.vue +++ b/src/pages/warehouse/locationInquiry.vue @@ -9,7 +9,9 @@ 库位查询 - + + 筛选 + @@ -36,7 +38,7 @@ @@ -72,11 +74,11 @@ - 总数量 + 库存 {{ goodsCount(goods) }} - 可移数量 + 可移库存 {{ goodsCopyCount(goods) }} @@ -93,8 +95,17 @@ + + + + 合计 + ({{ activeFilterLabel }}) + + {{ displayGoodsList.length }} + + - + 请选择库位 @@ -113,6 +124,40 @@ + + + + + + 筛选 + + + 全部 + 库存 > 0 + 可移库存 > 0 + 库存 > 0 且 可移库存 > 0 + + + 关闭 + + + @@ -130,7 +175,10 @@ export default { querying: false, queried: false, spaceInfo: null, - goodsList: [] + goodsList: [], + // 筛选(仅支持:可移库存 > 0 / 库存 > 0) + filterVisible: false, + filterType: '' } }, computed: { @@ -139,14 +187,55 @@ export default { const s = this.spaceInfo; if (!s) return '--'; return String(s.custom_name ?? s.customName ?? s.space_code ?? s.spaceCode ?? s.name ?? '--').trim() || '--'; + }, + // 过滤后的商品列表(不改动原始 goodsList) + displayGoodsList() { + if (!this.filterType) { + return this.goodsList; + } + if (this.filterType === 'both') { + return this.goodsList.filter(goods => { + const available = this.sortQuantityOf(goods, false); + const stock = this.sortQuantityOf(goods, true); + return available !== null && available > 0 && stock !== null && stock > 0; + }); + } + const isStock = this.filterType === 'stock'; + return this.goodsList.filter(goods => { + const v = this.sortQuantityOf(goods, isStock); + return v !== null && v > 0; + }); + }, + activeFilterLabel() { + if (this.filterType === 'available') { + return '可移库存 大于 0'; + } + if (this.filterType === 'stock') { + return '库存 大于 0'; + } + if (this.filterType === 'both') { + return '库存 大于 0 且 可移库存 大于 0'; + } + return ''; } }, onLoad(options = {}) { - // 支持通过 ?keyword=xxx 预填库位编码/条码并自动查询 - const preset = String(options.keyword || '').trim(); - if (preset) { - this.keyword = preset; - this.$nextTick(() => this.handleQuery()); + // 支持 ?space_id=xxx 直接按库位ID查询 + const presetId = String(options.space_id || '').trim(); + if (presetId) { + this.$nextTick(() => this.querySpace(presetId)); + } else { + // 支持通过 ?keyword=xxx 预填库位编码/条码并自动查询 + const preset = String(options.keyword || '').trim(); + if (preset) { + this.keyword = preset; + this.$nextTick(() => this.handleQuery()); + } + } + // 支持 ?filter_type=xxx 预置筛选条件(stock=库存>0 等) + const presetFilter = String(options.filter_type || '').trim(); + if (presetFilter) { + this.filterType = presetFilter; } this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult }); this.safeDispatchBroadcast('start'); @@ -200,6 +289,42 @@ export default { toast(title, icon = 'none') { uni.showToast({ title, icon }); }, + // 提取用于筛选的数值:stock=库存(可用 + 锁定),available=可移库存 + sortQuantityOf(goods, isStock) { + if (!goods || typeof goods !== 'object') { + return null; + } + if (isStock) { + // 库存 = 可用数量 + 锁定数量,都取不到时回退原始库存字段 + const locked = this.goodsLockedQuantity(goods); + const available = this.goodsAvailableQuantity(goods, locked); + if (available !== null || locked !== null) { + return (available === null ? 0 : available) + (locked === null ? 0 : locked); + } + return this.goodsToNumberOrNull( + goods.quantity + ?? goods.actual_quantity + ?? goods.stock + ?? goods.total_quantity + ?? goods.qty + ); + } + return this.goodsToNumberOrNull( + goods.available_quantity + ?? goods.movable_quantity + ?? goods.moveable_quantity + ?? goods.can_move_quantity + ?? goods.free_quantity + ?? goods.usable_quantity + ); + }, + openFilter() { + this.filterVisible = true; + }, + applyFilterType(type) { + this.filterType = type; + this.filterVisible = false; + }, handleBack() { const pages = getCurrentPages(); if (pages.length > 1) { @@ -236,13 +361,88 @@ export default { goodsStoreName(goods) { return String(goods?.store_name ?? '').trim() || '--'; }, + // 总数量:参考商品查询页,库存 = 可用数量 + 锁定数量,都取不到时回退原始库存字段 goodsCount(goods) { - const v = goods?.quantity; - return v === null || v === undefined || v === '' ? '--' : String(v); + if (!goods || typeof goods !== 'object') { + return '--'; + } + const locked = this.goodsLockedQuantity(goods); + const available = this.goodsAvailableQuantity(goods, locked); + if (available !== null || locked !== null) { + return String((available === null ? 0 : available) + (locked === null ? 0 : locked)); + } + return this.goodsValueOrDash( + goods.quantity + ?? goods.actual_quantity + ?? goods.stock + ?? goods.total_quantity + ?? goods.qty + ); }, + // 可移数量:参考商品查询页,直接取可用数量字段 goodsCopyCount(goods) { - const v = goods?.available_quantity; - return v === null || v === undefined || v === '' ? '--' : String(v); + if (!goods || typeof goods !== 'object') { + return '--'; + } + return this.goodsValueOrDash( + goods.available_quantity + ?? goods.movable_quantity + ?? goods.moveable_quantity + ?? goods.can_move_quantity + ?? goods.free_quantity + ?? goods.usable_quantity + ); + }, + goodsLockedQuantity(goods) { + if (!goods || typeof goods !== 'object') { + return null; + } + return this.goodsToNumberOrNull( + goods.locked_quantity + ?? goods.lock_quantity + ?? goods.frozen_quantity + ?? goods.freeze_quantity + ); + }, + goodsAvailableQuantity(goods, locked = null) { + if (!goods || typeof goods !== 'object') { + return null; + } + const available = this.goodsToNumberOrNull( + goods.available_quantity + ?? goods.movable_quantity + ?? goods.moveable_quantity + ?? goods.can_move_quantity + ?? goods.free_quantity + ?? goods.usable_quantity + ); + if (available !== null) { + return available; + } + const quantity = this.goodsToNumberOrNull( + goods.quantity + ?? goods.actual_quantity + ?? goods.stock + ?? goods.total_quantity + ?? goods.qty + ); + if (quantity !== null && locked !== null) { + return quantity - locked; + } + return null; + }, + goodsToNumberOrNull(value) { + if (value === null || value === undefined || value === '') { + return null; + } + const num = Number(value); + return Number.isNaN(num) ? null : num; + }, + goodsValueOrDash(value) { + if (value === null || value === undefined || value === '') { + return '--'; + } + return String(value); }, // 商品图片:优先取已拉取的 images 列表,其次商品/库存对象上的单图字段 goodsImage(goods) { @@ -581,8 +781,18 @@ export default { color: #333; } -.header__placeholder { - width: 80rpx; +.header__filter { + display: flex; + align-items: center; + justify-content: center; + background: #2979ff; + border-radius: 8rpx; +} + +.header__filter-text { + font-size: 36rpx; + color: #ffffff; + padding: 8rpx 20rpx; } .content_box { @@ -812,8 +1022,106 @@ export default { /* 底部安全区 */ .safe-area-bottom { - height: constant(safe-area-inset-bottom); - height: env(safe-area-inset-bottom); + height: calc(40rpx + constant(safe-area-inset-bottom)); + height: calc(40rpx + env(safe-area-inset-bottom)); +} + +/* 底部合计栏 */ +.total-bar { + flex-shrink: 0; + display: flex; + align-items: center; + justify-content: space-between; + padding: 20rpx 24rpx; + padding-bottom: calc(20rpx + constant(safe-area-inset-bottom)); + padding-bottom: calc(20rpx + env(safe-area-inset-bottom)); + background: #ffffff; + border-top: 1rpx solid #f0f0f0; +} + +.total-bar__label { + font-size: 36rpx; + color: #606266; +} + +.total-bar__left { + display: flex; + align-items: center; +} + +.total-bar__filter { + margin-left: 8rpx; + font-size: 34rpx; + color: #FF8C42; +} + +.total-bar__value { + font-size: 38rpx; + font-weight: bold; + color: #2979ff; +} + +/* 筛选弹窗 */ +.filter-panel { + background: #ffffff; + border-radius: 20px 20px 0 0; + overflow: hidden; + padding: 32rpx 24rpx 40rpx; + box-sizing: border-box; +} + +.filter-panel__header { + text-align: center; + padding-bottom: 20rpx; +} + +.filter-panel__title { + font-size: 40rpx; + font-weight: 600; + color: #333; +} + +.filter-panel__options { + display: flex; + flex-wrap: wrap; + margin: -8rpx; +} + +.filter-panel__option { + flex: 0 0 calc(50% - 16rpx); + margin: 8rpx; + box-sizing: border-box; + padding: 24rpx 0; + text-align: center; + background: #f6f8fb; + border-radius: 12rpx; + font-size: 36rpx; + color: #606266; +} + +.filter-panel__option--active { + background: #eaf2ff; + color: #2979ff; + font-weight: 600; +} + +.filter-panel__actions { + display: flex; + margin-top: 32rpx; +} + +.filter-panel__btn { + flex: 1; + height: 80rpx; + line-height: 80rpx; + text-align: center; + border-radius: 12rpx; + font-size: 36rpx; +} + +.filter-panel__btn--close { + background: #f6f8fb; + color: #606266; } /* 库位选择弹窗 */