修改分拣缺货补货页面

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>
<!-- 数据列表:卡片模式 -->
<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
v-for="(item, index) in list"
:key="item.stock_id || index"
class="card-item"
@click="goProductQuery(item)"
>
<!-- 卡片内容:标签名在左,数值在右,斑马纹 -->
<view class="card-item__body">
@ -105,26 +106,31 @@
</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>
</scroll-view>
<!-- 底部统计栏 -->
<view v-if="summary" class="bottom-bar">
<text class="bottom-bar__text">
共 {{ getSummaryVal(summary.total_skus) }} 条,缺货 {{ getSummaryVal(summary.total_shortage_skus) }},建议补货 {{ formatQty(summary.total_replenishment_needed) }}
</text>
<view class="bottom-bar__pagination">
<view
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>
@ -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;
}
</style>

View File

@ -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 {