diff --git a/core/request/apis.js b/core/request/apis.js index 834d78f..a120c7a 100644 --- a/core/request/apis.js +++ b/core/request/apis.js @@ -233,6 +233,15 @@ export default { method: "POST", isSystemApi: true } + }, + /** 库存管理 ↓ **/ + management: { + replenishmentDemand: { + path: "storage.management.replenishmentDemand", + auth: true, + method: "POST", + isSystemApi: true + } } }, stock: { diff --git a/pages/replenishment/replenishShorts.vue b/pages/replenishment/replenishShorts.vue index 45b5e97..6be5959 100644 --- a/pages/replenishment/replenishShorts.vue +++ b/pages/replenishment/replenishShorts.vue @@ -12,10 +12,119 @@ + + + + SKU总数 + {{ getSummaryVal(summary.total_skus) }} + + + 缺货SKU + {{ getSummaryVal(summary.total_shortage_skus) }} + + + 建议补货总量 + {{ formatQty(summary.total_replenishment_needed) }} + + + 真实缺货SKU + {{ getSummaryVal(summary.total_true_shortage_skus) }} + + + - - 页面建设中 - 当前已完成顶部栏布局,可继续补充分拣缺货补货业务内容。 + + + + 加载中... + + + + + + 暂无缺货数据 + 当前仓库所有SKU分拣区库存充足,无需补货。 + + + + + + + + + + SKU编码 + + {{ item.stock_code || item.stock_id || '-' }} + + + 商品名称 + + {{ item.stock_name || '-' }} + + + 分拣区库存 + + {{ formatQty(item.pick_zone_quantity) }} + + + 存货区库存 + + {{ formatQty(item.storage_zone_quantity) }} + + + 订单需求 + + {{ formatQty(item.total_demand) }} + + + 缺口 + + {{ formatQty(item.shortage) }} + + + 建议补货 + + {{ formatQty(item.replenishment_needed) }} + + + 补货状态 + + {{ replenishStatusText(item.replenishment_status) }} + + + 补货库位 + + {{ formatLocations(item.replenishment_locations) }} + + + + + + + + + 加载更多... + + + + + 没有更多了 + + + + + + + + + + 共 {{ getSummaryVal(summary.total_skus) }} 条,缺货 {{ getSummaryVal(summary.total_shortage_skus) }},建议补货 {{ formatQty(summary.total_replenishment_needed) }} + @@ -25,25 +134,116 @@ export default { data() { return { - refreshAt: '' + loading: false, + loadingMore: false, + list: [], + summary: null, + total: 0, + page: 1, + pageSize: 20, + hasMore: true, + sort: { + sortField: 'shortage', + sortOrder: 'DESC' + } }; }, onLoad() { - this.refreshPage(); + this.fetchData(); }, methods: { handleBack() { uni.navigateBack({ delta: 1 }); }, handleRefresh() { - this.refreshPage(); - uni.showToast({ - title: '已刷新', - icon: 'none' - }); + this.page = 1; + this.hasMore = true; + this.list = []; + this.fetchData(); + uni.showToast({ title: '已刷新', icon: 'none' }); }, - refreshPage() { - this.refreshAt = Date.now(); + loadMore() { + if (this.loadingMore || !this.hasMore) return; + this.page += 1; + this.fetchData(true); + }, + 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('、'); + }, + replenishStatusText(status) { + const map = { + true_shortage: '真实缺货', + replenishable: '可补货' + }; + return map[status] || status || '-'; + }, + replenishStatusClass(item) { + const status = item.replenishment_status; + if (status === 'replenishable') { + return 'card-metric__value--primary'; + } + if (status === 'true_shortage') { + return 'card-metric__value--danger'; + } + return ''; + }, + formatQty(val) { + const num = Number(val); + return isNaN(num) ? '-' : num.toLocaleString(); + }, + async fetchData(isLoadMore = false) { + if (isLoadMore) { + this.loadingMore = true; + } else { + this.loading = true; + } + + try { + const params = { + pagination: { + page: this.page, + pageSize: this.pageSize + }, + sort: { + sortField: this.sort.sortField, + sortOrder: this.sort.sortOrder + } + }; + + 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; + } catch (error) { + console.error('[replenishShorts] 请求失败:', error); + uni.showToast({ + title: error?.message || error?.msg || '请求失败', + icon: 'none' + }); + if (!isLoadMore) { + this.list = []; + this.total = 0; + } + } finally { + this.loading = false; + this.loadingMore = false; + } } } }; @@ -51,8 +251,11 @@ \ No newline at end of file