修改分拣缺货补货页面

This commit is contained in:
zm2000 2026-07-05 18:20:19 +08:00
parent 8a7007ccb1
commit 93826c96ff
2 changed files with 120 additions and 79 deletions

View File

@ -47,12 +47,13 @@
</view> </view>
<!-- 数据列表:卡片模式 --> <!-- 数据列表:卡片模式 -->
<scroll-view v-else class="card-scroll" scroll-y @scrolltolower="loadMore"> <scroll-view v-else class="card-scroll" scroll-y>
<view class="card-list"> <view class="card-list">
<view <view
v-for="(item, index) in list" v-for="(item, index) in list"
:key="item.stock_id || index" :key="item.stock_id || index"
class="card-item" class="card-item"
@click="goProductQuery(item)"
> >
<!-- 卡片内容:标签名在左,数值在右,斑马纹 --> <!-- 卡片内容:标签名在左,数值在右,斑马纹 -->
<view class="card-item__body"> <view class="card-item__body">
@ -105,26 +106,31 @@
</view> </view>
</view> </view>
<!-- 加载更多 -->
<view v-if="loadingMore" class="loadmore-state">
<u-loading-icon mode="circle" size="28"></u-loading-icon>
<text class="loadmore-state__text">加载更多...</text>
</view>
<!-- 没有更多 -->
<view v-if="!hasMore && list.length > 0" class="no-more-tip">
<text class="no-more-tip__text">没有更多了</text>
</view>
<!-- 底部安全区 --> <!-- 底部安全区 -->
<view class="safe-area-bottom"></view> <view class="safe-area-bottom"></view>
</scroll-view> </scroll-view>
<!-- 底部统计栏 --> <!-- 底部统计栏 -->
<view v-if="summary" class="bottom-bar"> <view v-if="summary" class="bottom-bar">
<text class="bottom-bar__text"> <view class="bottom-bar__pagination">
共 {{ getSummaryVal(summary.total_skus) }} 条,缺货 {{ getSummaryVal(summary.total_shortage_skus) }},建议补货 {{ formatQty(summary.total_replenishment_needed) }} <view
</text> class="pagination-btn"
:class="{ 'pagination-btn--disabled': page <= 1 }"
@click="goPrevPage"
>
上一页
</view>
<text class="bottom-bar__text">
第 {{ page }}/{{ totalPages }} 页,共 {{ getSummaryVal(summary.total_skus) }} 条
</text>
<view
class="pagination-btn"
:class="{ 'pagination-btn--disabled': page >= totalPages }"
@click="goNextPage"
>
下一页
</view>
</view>
</view> </view>
</view> </view>
</view> </view>
@ -135,46 +141,61 @@
data() { data() {
return { return {
loading: false, loading: false,
loadingMore: false,
list: [], list: [],
summary: null, summary: null,
total: 0, total: 0,
page: 1, page: 1,
pageSize: 20, pageSize: 20,
hasMore: true,
sort: { sort: {
sortField: 'shortage', sortField: 'shortage',
sortOrder: 'DESC' sortOrder: 'DESC'
} }
}; };
}, },
computed: {
totalPages() {
return Math.max(1, Math.ceil(this.total / this.pageSize));
}
},
onLoad() { onLoad() {
this.fetchData(); this.fetchData();
}, },
methods: { 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() { handleBack() {
uni.navigateBack({ delta: 1 }); uni.navigateBack({ delta: 1 });
}, },
handleRefresh() { handleRefresh() {
this.page = 1; this.page = 1;
this.hasMore = true;
this.list = []; this.list = [];
this.fetchData(); this.fetchData();
uni.showToast({ title: '已刷新', icon: 'none' }); uni.showToast({ title: '已刷新', icon: 'none' });
}, },
loadMore() { goNextPage() {
if (this.loadingMore || !this.hasMore) return; if (this.page >= this.totalPages || this.loading) return;
this.page += 1; this.page += 1;
this.fetchData(true); this.fetchData();
},
goPrevPage() {
if (this.page <= 1 || this.loading) return;
this.page -= 1;
this.fetchData();
}, },
getSummaryVal(val) { getSummaryVal(val) {
return val ?? 0; return val ?? 0;
}, },
formatLocations(locations) { formatLocations(locations) {
if (!Array.isArray(locations) || locations.length === 0) return '-'; if (!Array.isArray(locations) || locations.length === 0) return '-';
return locations.map(loc => return locations.map(loc => {
`${loc.space_code}(${loc.available_quantity})` const spaceLabel = loc.space_name || loc.name || loc.custom_name || loc.space_code || '-';
).join('、'); return `${spaceLabel}(${loc.available_quantity})`;
}).join('、');
}, },
replenishStatusText(status) { replenishStatusText(status) {
const map = { const map = {
@ -197,12 +218,8 @@
const num = Number(val); const num = Number(val);
return isNaN(num) ? '-' : num.toLocaleString(); return isNaN(num) ? '-' : num.toLocaleString();
}, },
async fetchData(isLoadMore = false) { async fetchData() {
if (isLoadMore) { this.loading = true;
this.loadingMore = true;
} else {
this.loading = true;
}
try { try {
const params = { const params = {
@ -218,31 +235,19 @@
const res = await this.$http('storage.management.replenishmentDemand', params); const res = await this.$http('storage.management.replenishmentDemand', params);
const dataList = Array.isArray(res.list) ? res.list : []; this.list = Array.isArray(res.list) ? res.list : [];
const total = Number(res.pagination?.total ?? dataList.length); this.total = Number(res.pagination?.total ?? this.list.length);
const summaryData = res.summary ?? null; this.summary = 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) { } catch (error) {
console.error('[replenishShorts] 请求失败:', error); console.error('[replenishShorts] 请求失败:', error);
uni.showToast({ uni.showToast({
title: error?.message || error?.msg || '请求失败', title: error?.message || error?.msg || '请求失败',
icon: 'none' icon: 'none'
}); });
if (!isLoadMore) { this.list = [];
this.list = []; this.total = 0;
this.total = 0;
}
} finally { } finally {
this.loading = false; this.loading = false;
this.loadingMore = false;
} }
} }
} }
@ -435,7 +440,7 @@
.card-metric { .card-metric {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 16rpx 16rpx; padding: 18rpx 16rpx;
} }
.card-metric--1 { .card-metric--1 {
@ -444,8 +449,8 @@
} }
.card-metric__label { .card-metric__label {
font-size: 26rpx; font-size: 30rpx;
color: #909399; color: #303133;
line-height: 1; line-height: 1;
flex-shrink: 0; flex-shrink: 0;
width: 150rpx; width: 150rpx;
@ -460,27 +465,26 @@
} }
.card-metric__value { .card-metric__value {
font-size: 28rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
color: #303133; color: #303133;
line-height: 1.2; line-height: 1.4;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
text-align: right; text-align: left;
max-width: 60%; flex: 1;
overflow: hidden; min-width: 0;
text-overflow: ellipsis; word-break: break-all;
white-space: nowrap;
} }
.card-metric__value--code { .card-metric__value--code {
font-weight: 700; font-weight: 700;
font-size: 30rpx; font-size: 34rpx;
} }
.card-metric__value--name { .card-metric__value--name {
font-weight: 400; font-weight: 400;
font-size: 26rpx; font-size: 30rpx;
color: #606266; color: #303133;
} }
.card-metric__value--danger { .card-metric__value--danger {
@ -497,12 +501,12 @@
.card-metric__value--spaces { .card-metric__value--spaces {
font-weight: 400; font-weight: 400;
color: #606266; color: #303133;
max-width: 60%; max-width: 60%;
white-space: normal; white-space: normal;
word-break: break-all; word-break: break-all;
line-height: 1.4; line-height: 1.4;
font-size: 24rpx; font-size: 28rpx;
} }
/* ===== 加载更多 ===== */ /* ===== 加载更多 ===== */
@ -539,11 +543,32 @@
padding: 16rpx 24rpx; padding: 16rpx 24rpx;
background: #ffffff; background: #ffffff;
border-top: 1rpx solid #ebeef5; border-top: 1rpx solid #ebeef5;
text-align: center; }
.bottom-bar__pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 24rpx;
} }
.bottom-bar__text { .bottom-bar__text {
font-size: 24rpx; font-size: 24rpx;
color: #909399; 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;
}
</style> </style>

View File

@ -229,7 +229,8 @@
mode: 'nonBatch', mode: 'nonBatch',
sectionKey: '', sectionKey: '',
top: 0 top: 0
} },
routeStockId: ''
} }
}, },
computed: { computed: {
@ -264,6 +265,7 @@
onResult: this.handleBroadcastResult onResult: this.handleBroadcastResult
}); });
this.safeDispatchBroadcast('start'); this.safeDispatchBroadcast('start');
this.routeStockId = options?.stock_id || '';
const routeKeyword = this.normalizeKeyword(options?.keyword || options?.barcode || options?.code || ''); const routeKeyword = this.normalizeKeyword(options?.keyword || options?.barcode || options?.code || '');
if (routeKeyword) { if (routeKeyword) {
this.keyword = routeKeyword; this.keyword = routeKeyword;
@ -1018,35 +1020,49 @@
this.scheduleRefreshStorageSectionMetas(); this.scheduleRefreshStorageSectionMetas();
}, },
buildQueryParams(keyword) { buildQueryParams(keyword) {
return { const params = {
keyword, keyword,
with_stock: true, with_stock: true,
is_batch: this.queryMode === 'batch' is_batch: this.queryMode === 'batch'
}; };
if (this.routeStockId) {
params.stock_id = this.routeStockId;
}
return params;
}, },
buildWarehouseListWhereParams(keyword) { buildWarehouseListWhereParams(keyword) {
const normalized = this.normalizeKeyword(keyword); const normalized = this.normalizeKeyword(keyword);
if (!normalized) { if (!normalized && !this.routeStockId) {
return {}; return {};
} }
if (this.isBarcodeLike(normalized)) { const where = {};
return {
barcode: { if (this.routeStockId) {
operator: 'like', where.stock_id = {
value: normalized, operator: 'eq',
type: 'string' value: this.routeStockId,
} type: 'number'
}; };
} }
return { if (normalized) {
item_name: { if (this.isBarcodeLike(normalized)) {
operator: 'like', where.barcode = {
value: normalized, operator: 'like',
type: 'string' value: normalized,
type: 'string'
};
} else {
where.item_name = {
operator: 'like',
value: normalized,
type: 'string'
};
} }
}; }
return where;
}, },
buildWarehouseListQueryParams(keyword) { buildWarehouseListQueryParams(keyword) {
return { return {