WMS_PDA/pages/replenishment/replenishShorts.vue

549 lines
13 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="replenish-shorts-page">
<view class="status-bar"></view>
<view class="page-header">
<view class="header-side header-side--left" @click="handleBack">
<u-icon name="arrow-left" size="18" color="#303133"></u-icon>
<text class="header-action-text">返回</text>
</view>
<text class="header-title">分拣缺货补货</text>
<view class="header-side header-side--right" @click="handleRefresh">
<text class="header-action-text">刷新</text>
</view>
</view>
<!-- 汇总统计栏 -->
<view v-if="summary" class="summary-bar">
<view class="summary-bar__item">
<text class="summary-bar__item-label">SKU总数</text>
<text class="summary-bar__item-value">{{ getSummaryVal(summary.total_skus) }}</text>
</view>
<view class="summary-bar__item">
<text class="summary-bar__item-label">缺货SKU</text>
<text class="summary-bar__item-value summary-bar__item-value--warning">{{ getSummaryVal(summary.total_shortage_skus) }}</text>
</view>
<view class="summary-bar__item">
<text class="summary-bar__item-label">建议补货总量</text>
<text class="summary-bar__item-value summary-bar__item-value--primary">{{ formatQty(summary.total_replenishment_needed) }}</text>
</view>
<view class="summary-bar__item">
<text class="summary-bar__item-label">真实缺货SKU</text>
<text class="summary-bar__item-value summary-bar__item-value--danger">{{ getSummaryVal(summary.total_true_shortage_skus) }}</text>
</view>
</view>
<view class="page-body">
<!-- 加载状态 -->
<view v-if="loading" class="loading-state">
<u-loading-icon mode="circle" size="36"></u-loading-icon>
<text class="loading-state__text">加载中...</text>
</view>
<!-- 空数据 -->
<view v-else-if="list.length === 0" class="empty-card">
<u-icon name="info-circle" size="72" color="#c0c4cc"></u-icon>
<text class="empty-card__title">暂无缺货数据</text>
<text class="empty-card__desc">当前仓库所有SKU分拣区库存充足,无需补货。</text>
</view>
<!-- 数据列表:卡片模式 -->
<scroll-view v-else class="card-scroll" scroll-y @scrolltolower="loadMore">
<view class="card-list">
<view
v-for="(item, index) in list"
:key="item.stock_id || index"
class="card-item"
>
<!-- 卡片内容:标签名在左,数值在右,斑马纹 -->
<view class="card-item__body">
<view class="card-metric card-metric--0">
<text class="card-metric__label">SKU编码</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value card-metric__value--code">{{ item.stock_code || item.stock_id || '-' }}</text>
</view>
<view class="card-metric card-metric--1">
<text class="card-metric__label">商品名称</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value card-metric__value--name">{{ item.stock_name || '-' }}</text>
</view>
<view class="card-metric card-metric--0">
<text class="card-metric__label">分拣区库存</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value">{{ formatQty(item.pick_zone_quantity) }}</text>
</view>
<view class="card-metric card-metric--1">
<text class="card-metric__label">存货区库存</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value">{{ formatQty(item.storage_zone_quantity) }}</text>
</view>
<view class="card-metric card-metric--0">
<text class="card-metric__label">订单需求</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value">{{ formatQty(item.total_demand) }}</text>
</view>
<view class="card-metric card-metric--1">
<text class="card-metric__label">缺口</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value card-metric__value--danger">{{ formatQty(item.shortage) }}</text>
</view>
<view class="card-metric card-metric--0">
<text class="card-metric__label">建议补货</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value card-metric__value--primary">{{ formatQty(item.replenishment_needed) }}</text>
</view>
<view class="card-metric card-metric--1">
<text class="card-metric__label">补货状态</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value" :class="replenishStatusClass(item)">{{ replenishStatusText(item.replenishment_status) }}</text>
</view>
<view class="card-metric card-metric--0">
<text class="card-metric__label">补货库位</text>
<view class="card-metric__divider"></view>
<text class="card-metric__value card-metric__value--spaces">{{ formatLocations(item.replenishment_locations) }}</text>
</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>
</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>
</view>
</view>
</template>
<script>
export default {
data() {
return {
loading: false,
loadingMore: false,
list: [],
summary: null,
total: 0,
page: 1,
pageSize: 20,
hasMore: true,
sort: {
sortField: 'shortage',
sortOrder: 'DESC'
}
};
},
onLoad() {
this.fetchData();
},
methods: {
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;
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;
}
}
}
};
</script>
<style lang="scss" scoped>
.replenish-shorts-page {
height: 100vh;
display: flex;
flex-direction: column;
background: #f5f7fa;
overflow: hidden;
}
.status-bar {
height: var(--status-bar-height);
background: #ffffff;
}
.page-header {
height: 88rpx;
padding: 0 24rpx;
display: flex;
align-items: center;
justify-content: space-between;
background: #ffffff;
border-bottom: 1rpx solid #ebeef5;
box-sizing: border-box;
flex-shrink: 0;
}
.header-side {
min-width: 112rpx;
display: flex;
align-items: center;
}
.header-side--left {
justify-content: flex-start;
}
.header-side--right {
justify-content: flex-end;
}
.header-title {
flex: 1;
padding: 0 16rpx;
font-size: 34rpx;
font-weight: 600;
color: #303133;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-action-text {
margin-left: 8rpx;
font-size: 28rpx;
color: #303133;
line-height: 1;
}
.header-side--right .header-action-text {
margin-left: 0;
color: #2979ff;
}
/* ===== 汇总统计栏 ===== */
.summary-bar {
display: flex;
align-items: stretch;
padding: 16rpx 16rpx;
background: #ffffff;
border-bottom: 1rpx solid #ebeef5;
gap: 8rpx;
flex-shrink: 0;
}
.summary-bar__item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 6rpx;
padding: 12rpx 8rpx;
background: #f5f7fa;
border-radius: 12rpx;
}
.summary-bar__item-value {
font-size: 36rpx;
font-weight: 700;
color: #303133;
line-height: 1.2;
font-variant-numeric: tabular-nums;
}
.summary-bar__item-value--danger {
color: #f56c6c;
}
.summary-bar__item-value--primary {
color: #2979ff;
}
.summary-bar__item-value--warning {
color: #e6a23c;
}
.summary-bar__item-label {
font-size: 22rpx;
color: #909399;
line-height: 1;
}
/* ===== 页面主体 ===== */
.page-body {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
padding: 0;
}
.loading-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 0;
gap: 24rpx;
}
.loading-state__text {
font-size: 28rpx;
color: #909399;
}
.empty-card {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 48rpx;
gap: 24rpx;
}
.empty-card__title {
font-size: 32rpx;
font-weight: 500;
color: #303133;
}
.empty-card__desc {
font-size: 26rpx;
color: #909399;
text-align: center;
line-height: 1.6;
}
/* ===== 卡片列表 ===== */
.card-scroll {
flex: 1;
overflow: hidden;
}
.card-list {
padding: 16rpx;
display: flex;
flex-direction: column;
gap: 16rpx;
}
.card-item {
background: #ffffff;
border-radius: 16rpx;
padding: 24rpx 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
}
.card-item__body {
display: flex;
flex-direction: column;
}
.card-metric {
display: flex;
align-items: center;
padding: 16rpx 16rpx;
}
.card-metric--1 {
background: #f8f9fb;
border-radius: 6rpx;
}
.card-metric__label {
font-size: 26rpx;
color: #909399;
line-height: 1;
flex-shrink: 0;
width: 150rpx;
}
.card-metric__divider {
width: 2rpx;
height: 28rpx;
background: #e4e7ed;
flex-shrink: 0;
margin: 0 16rpx;
}
.card-metric__value {
font-size: 28rpx;
font-weight: 600;
color: #303133;
line-height: 1.2;
font-variant-numeric: tabular-nums;
text-align: right;
max-width: 60%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.card-metric__value--code {
font-weight: 700;
font-size: 30rpx;
}
.card-metric__value--name {
font-weight: 400;
font-size: 26rpx;
color: #606266;
}
.card-metric__value--danger {
color: #f56c6c;
}
.card-metric__value--primary {
color: #2979ff;
}
.card-metric__value--warning {
color: #e6a23c;
}
.card-metric__value--spaces {
font-weight: 400;
color: #606266;
max-width: 60%;
white-space: normal;
word-break: break-all;
line-height: 1.4;
font-size: 24rpx;
}
/* ===== 加载更多 ===== */
.loadmore-state {
display: flex;
align-items: center;
justify-content: center;
padding: 24rpx 0;
gap: 12rpx;
}
.loadmore-state__text {
font-size: 24rpx;
color: #909399;
}
.no-more-tip {
padding: 24rpx 0;
text-align: center;
}
.no-more-tip__text {
font-size: 24rpx;
color: #c0c4cc;
}
.safe-area-bottom {
height: 20rpx;
}
/* ===== 底部统计栏 ===== */
.bottom-bar {
flex-shrink: 0;
padding: 16rpx 24rpx;
background: #ffffff;
border-top: 1rpx solid #ebeef5;
text-align: center;
}
.bottom-bar__text {
font-size: 24rpx;
color: #909399;
}
</style>