diff --git a/pages/replenishment/replenishShorts.vue b/pages/replenishment/replenishShorts.vue index 6be5959..7652a87 100644 --- a/pages/replenishment/replenishShorts.vue +++ b/pages/replenishment/replenishShorts.vue @@ -47,12 +47,13 @@ - + @@ -105,26 +106,31 @@ - - - - 加载更多... - - - - - 没有更多了 - - - - 共 {{ getSummaryVal(summary.total_skus) }} 条,缺货 {{ getSummaryVal(summary.total_shortage_skus) }},建议补货 {{ formatQty(summary.total_replenishment_needed) }} - + + + 上一页 + + + 第 {{ page }}/{{ totalPages }} 页,共 {{ getSummaryVal(summary.total_skus) }} 条 + + + 下一页 + + @@ -135,46 +141,61 @@ data() { return { loading: false, - loadingMore: false, list: [], summary: null, total: 0, page: 1, pageSize: 20, - hasMore: true, sort: { sortField: 'shortage', sortOrder: 'DESC' } }; }, + computed: { + totalPages() { + return Math.max(1, Math.ceil(this.total / this.pageSize)); + } + }, onLoad() { this.fetchData(); }, methods: { + goProductQuery(item) { + const keyword = item.stock_name || item.stock_code || item.stock_id || ''; + const stockId = item.stock_id || ''; + uni.navigateTo({ + url: `/pages/work/product/query?keyword=${encodeURIComponent(keyword)}&stock_id=${encodeURIComponent(stockId)}` + }); + }, handleBack() { uni.navigateBack({ delta: 1 }); }, handleRefresh() { this.page = 1; - this.hasMore = true; this.list = []; this.fetchData(); uni.showToast({ title: '已刷新', icon: 'none' }); }, - loadMore() { - if (this.loadingMore || !this.hasMore) return; + goNextPage() { + if (this.page >= this.totalPages || this.loading) return; this.page += 1; - this.fetchData(true); + this.fetchData(); + }, + goPrevPage() { + if (this.page <= 1 || this.loading) return; + this.page -= 1; + this.fetchData(); }, getSummaryVal(val) { return val ?? 0; }, formatLocations(locations) { if (!Array.isArray(locations) || locations.length === 0) return '-'; - return locations.map(loc => - `${loc.space_code}(${loc.available_quantity})` - ).join('、'); + return locations.map(loc => { + const spaceLabel = loc.space_name || loc.name || loc.custom_name || loc.space_code || '-'; + return `${spaceLabel}(${loc.available_quantity})`; + }).join('、'); }, replenishStatusText(status) { const map = { @@ -197,12 +218,8 @@ const num = Number(val); return isNaN(num) ? '-' : num.toLocaleString(); }, - async fetchData(isLoadMore = false) { - if (isLoadMore) { - this.loadingMore = true; - } else { - this.loading = true; - } + async fetchData() { + this.loading = true; try { const params = { @@ -218,31 +235,19 @@ const res = await this.$http('storage.management.replenishmentDemand', params); - const dataList = Array.isArray(res.list) ? res.list : []; - const total = Number(res.pagination?.total ?? dataList.length); - const summaryData = res.summary ?? null; - - if (isLoadMore) { - this.list = this.list.concat(dataList); - } else { - this.list = dataList; - this.summary = summaryData; - } - this.total = total; - this.hasMore = this.list.length < total; + this.list = Array.isArray(res.list) ? res.list : []; + this.total = Number(res.pagination?.total ?? this.list.length); + this.summary = res.summary ?? null; } catch (error) { console.error('[replenishShorts] 请求失败:', error); uni.showToast({ title: error?.message || error?.msg || '请求失败', icon: 'none' }); - if (!isLoadMore) { - this.list = []; - this.total = 0; - } + this.list = []; + this.total = 0; } finally { this.loading = false; - this.loadingMore = false; } } } @@ -435,7 +440,7 @@ .card-metric { display: flex; align-items: center; - padding: 16rpx 16rpx; + padding: 18rpx 16rpx; } .card-metric--1 { @@ -444,8 +449,8 @@ } .card-metric__label { - font-size: 26rpx; - color: #909399; + font-size: 30rpx; + color: #303133; line-height: 1; flex-shrink: 0; width: 150rpx; @@ -460,27 +465,26 @@ } .card-metric__value { - font-size: 28rpx; + font-size: 32rpx; font-weight: 600; color: #303133; - line-height: 1.2; + line-height: 1.4; font-variant-numeric: tabular-nums; - text-align: right; - max-width: 60%; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + text-align: left; + flex: 1; + min-width: 0; + word-break: break-all; } .card-metric__value--code { font-weight: 700; - font-size: 30rpx; + font-size: 34rpx; } .card-metric__value--name { font-weight: 400; - font-size: 26rpx; - color: #606266; + font-size: 30rpx; + color: #303133; } .card-metric__value--danger { @@ -497,12 +501,12 @@ .card-metric__value--spaces { font-weight: 400; - color: #606266; + color: #303133; max-width: 60%; white-space: normal; word-break: break-all; line-height: 1.4; - font-size: 24rpx; + font-size: 28rpx; } /* ===== 加载更多 ===== */ @@ -539,11 +543,32 @@ padding: 16rpx 24rpx; background: #ffffff; border-top: 1rpx solid #ebeef5; - text-align: center; + } + + .bottom-bar__pagination { + display: flex; + align-items: center; + justify-content: center; + gap: 24rpx; } .bottom-bar__text { font-size: 24rpx; color: #909399; } + + .pagination-btn { + padding: 12rpx 24rpx; + font-size: 26rpx; + color: #2979ff; + background: #f0f5ff; + border-radius: 8rpx; + line-height: 1; + transition: opacity 0.2s; + } + + .pagination-btn--disabled { + color: #c0c4cc; + background: #f5f7fa; + } \ No newline at end of file diff --git a/pages/work/product/query.vue b/pages/work/product/query.vue index 77fbde5..09fc72e 100644 --- a/pages/work/product/query.vue +++ b/pages/work/product/query.vue @@ -229,7 +229,8 @@ mode: 'nonBatch', sectionKey: '', top: 0 - } + }, + routeStockId: '' } }, computed: { @@ -264,6 +265,7 @@ onResult: this.handleBroadcastResult }); this.safeDispatchBroadcast('start'); + this.routeStockId = options?.stock_id || ''; const routeKeyword = this.normalizeKeyword(options?.keyword || options?.barcode || options?.code || ''); if (routeKeyword) { this.keyword = routeKeyword; @@ -1018,35 +1020,49 @@ this.scheduleRefreshStorageSectionMetas(); }, buildQueryParams(keyword) { - return { + const params = { keyword, with_stock: true, is_batch: this.queryMode === 'batch' }; + if (this.routeStockId) { + params.stock_id = this.routeStockId; + } + return params; }, buildWarehouseListWhereParams(keyword) { const normalized = this.normalizeKeyword(keyword); - if (!normalized) { + if (!normalized && !this.routeStockId) { return {}; } - if (this.isBarcodeLike(normalized)) { - return { - barcode: { - operator: 'like', - value: normalized, - type: 'string' - } + const where = {}; + + if (this.routeStockId) { + where.stock_id = { + operator: 'eq', + value: this.routeStockId, + type: 'number' }; } - return { - item_name: { - operator: 'like', - value: normalized, - type: 'string' + if (normalized) { + if (this.isBarcodeLike(normalized)) { + where.barcode = { + operator: 'like', + value: normalized, + type: 'string' + }; + } else { + where.item_name = { + operator: 'like', + value: normalized, + type: 'string' + }; } - }; + } + + return where; }, buildWarehouseListQueryParams(keyword) { return {