修改复核发货、分拣缺货补货页面

This commit is contained in:
zm2000 2026-08-28 17:51:05 +08:00
parent b543d6e977
commit 512ed452e4
3 changed files with 441 additions and 28 deletions

View File

@ -2,12 +2,18 @@
<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>
<view class="header-side header-side--left">
<view class="header-side__btn" @click="handleBack">
<u-icon name="arrow-left" size="18" color="#303133"></u-icon>
</view>
<view class="header-side__btn header-side__btn--store" @click="openStoreDrawer">
<text class="header-side__btn-text">货主</text>
<view v-if="selectedStoreIds.length" class="header-side__btn-badge">{{ selectedStoreIds.length }}</view>
</view>
</view>
<text class="header-title">分拣缺货补货</text>
<view class="header-side header-side--right" @click="handleRefresh">
<view class="header-btn-refresh">刷新</view>
<view class="header-side header-side--right">
<view class="header-btn-refresh" @click="handleRefresh">刷新</view>
</view>
</view>
@ -39,7 +45,7 @@
class="search-bar__input"
type="text"
v-model="searchKeyword"
placeholder="输入商品名称搜索..."
placeholder="输入商品名称/条码搜索..."
placeholder-style="color: #c0c4cc; font-size: 34rpx;"
confirm-type="search"
/>
@ -94,6 +100,16 @@
<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 card-metric__value--name">{{ item.store_name || '-' }}</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">{{ formatBarcodes(item.barcodes) }}</text>
</view>
<view class="card-metric card-metric--0">
<text class="card-metric__label">出货数量</text>
<view class="card-metric__divider"></view>
@ -117,7 +133,16 @@
<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>
<text class="card-metric__value card-metric__value--spaces">
<text
v-for="(loc, i) in item.replenishment_locations || []"
:key="i"
class="card-metric__value--spaces-item"
>
<text v-if="i > 0" class="card-metric__value--spaces-sep">、</text>{{ formatSpaceLabel(loc) }}<text class="card-metric__value--spaces-qty">({{ loc.available_quantity }})</text>
</text>
<text v-if="!item.replenishment_locations || item.replenishment_locations.length === 0">-</text>
</text>
</view>
</view>
</view>
@ -130,25 +155,86 @@
<!-- 底部统计栏 -->
<view v-if="summary" class="bottom-bar">
<view class="bottom-bar__pagination">
<view
class="pagination-btn"
:class="{ 'pagination-btn--disabled': page <= 1 }"
@click="goPrevPage"
>
上一页
<template v-if="hasSearch">
<text class="bottom-bar__text">共 {{ filteredList.length }} 条(搜索结果)</text>
</template>
<template v-else>
<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>
</template>
</view>
</view>
</view>
<!-- 货主抽屉弹窗 -->
<view class="store-drawer-layer">
<u-popup :show="storeDrawerVisible" mode="left" :closeable="false" border-radius="0" :safeAreaInsetTop="true" bg-color="transparent" @close="handleStoreDrawerClose">
<view class="store-drawer">
<view class="store-drawer__header">
<text class="store-drawer__title">选择货主</text>
<view class="store-drawer__close" @click="handleStoreDrawerClose">
<u-icon name="close" color="#909399" size="18"></u-icon>
</view>
<text class="bottom-bar__text">
第 {{ page }}/{{ totalPages }} 页,共 {{ getSummaryVal(summary.total_skus) }} 条
</text>
</view>
<!-- 搜索框 -->
<view class="store-drawer__search">
<u-input
v-model="storeSearchText"
placeholder="输入货主名称搜索"
:border="'none'"
prefixIcon="search"
prefixIconStyle="color: #909399; font-size: 18px"
clearable
></u-input>
</view>
<view v-if="storeLoading" class="store-drawer__loading">
<u-loading-icon mode="circle" size="28"></u-loading-icon>
<text class="store-drawer__loading-text">加载中...</text>
</view>
<scroll-view v-else class="store-drawer__list" scroll-y>
<view
class="pagination-btn"
:class="{ 'pagination-btn--disabled': page >= totalPages }"
@click="goNextPage"
v-for="store in filteredStores"
:key="getStoreId(store)"
class="store-drawer__item"
:class="{ 'store-drawer__item--active': isStoreSelected(store) }"
@click="toggleStore(store)"
>
下一页
<text class="store-drawer__item-name">{{ getStoreName(store) }}</text>
<u-icon v-if="isStoreSelected(store)" name="checkbox-mark" color="#07c160" size="20"></u-icon>
</view>
<u-empty v-if="filteredStores.length === 0" mode="data" text="暂无货主"></u-empty>
</scroll-view>
<!-- 底部操作栏 -->
<view class="store-drawer__footer">
<view class="store-drawer__footer-info">
<text class="store-drawer__footer-text">已选 {{ pendingSelectedStoreIds.length }} 个货主</text>
<text v-if="pendingSelectedStoreIds.length" class="store-drawer__footer-clear" @click="clearStoreSelection">清空</text>
</view>
<view class="store-drawer__footer-btns">
<view class="store-drawer__footer-btn store-drawer__footer-btn--reset" @click="resetStoreSelection">重置</view>
<view class="store-drawer__footer-btn store-drawer__footer-btn--confirm" @click="applyStoreSelection">确定</view>
</view>
</view>
</view>
</u-popup>
</view>
</view>
</template>
@ -163,6 +249,12 @@
total: 0,
page: 1,
pageSize: 20,
storeDrawerVisible: false,
storeList: [],
storeLoading: false,
storeSearchText: '',
selectedStoreIds: [],
pendingSelectedStoreIds: [],
searchKeyword: '',
sort: {
sortField: 'shortage',
@ -174,21 +266,99 @@
totalPages() {
return Math.max(1, Math.ceil(this.total / this.pageSize));
},
hasSearch() {
return Boolean(this.searchKeyword.trim());
},
filteredList() {
const keyword = this.searchKeyword.trim();
if (!keyword) {
return this.list;
}
const kw = keyword.toLowerCase();
return this.list.filter(item => {
const name = String(item.stock_name || '').toLowerCase();
return name.includes(keyword.toLowerCase());
if (name.includes(kw)) return true;
const barcodes = Array.isArray(item.barcodes) ? item.barcodes : [];
return barcodes.some(b => {
const code = String(b.barcode || b.code || b.custom_code || '').toLowerCase();
return code.includes(kw);
});
});
},
filteredStores() {
const keyword = String(this.storeSearchText || '').trim().toLowerCase();
if (!keyword) {
return this.storeList;
}
return this.storeList.filter(store => {
const name = String(this.getStoreName(store) || '').toLowerCase();
return name.includes(keyword);
});
}
},
onLoad() {
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('start');
this.fetchData();
},
onShow() {
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('resume');
},
onHide() {
this.safeDispatchBroadcast('pause');
},
onUnload() {
this.safeDispatchBroadcast('stop');
},
methods: {
safeDispatchBroadcast(action, payload) {
try {
const task = this.$store.dispatch(`broadcast/${action}`, payload);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn(`[ReplenishShorts] broadcast/${action} 调用失败:`, error);
});
}
} catch (error) {
console.warn(`[ReplenishShorts] broadcast/${action} 调用异常:`, error);
}
},
normalizeUniScanResult(scanResult) {
if (!scanResult) {
return '';
}
if (typeof scanResult === 'string') {
return scanResult.trim();
}
if (typeof scanResult.result === 'string') {
return scanResult.result.trim();
}
if (Array.isArray(scanResult.result)) {
const firstResult = scanResult.result.find(item => item);
if (typeof firstResult === 'string') {
return firstResult.trim();
}
if (firstResult && typeof firstResult.data === 'string') {
return firstResult.data.trim();
}
}
if (typeof scanResult.data === 'string') {
return scanResult.data.trim();
}
return '';
},
handleBroadcastResult(result) {
const rawCode = this.normalizeUniScanResult(result);
if (!rawCode) {
return;
}
this.searchKeyword = rawCode;
},
goProductQuery(item) {
const keyword = item.stock_name || item.stock_code || item.stock_id || '';
const stockId = item.stock_id || '';
@ -197,6 +367,59 @@
url: `/pages/work/product/query?stock_id=${encodeURIComponent(stockId)}`
});
},
async openStoreDrawer() {
this.storeDrawerVisible = true;
this.pendingSelectedStoreIds = [...this.selectedStoreIds];
if (this.storeList.length > 0 || this.storeLoading) return;
this.storeLoading = true;
try {
const res = await this.$http('common.store', {});
this.storeList = Array.isArray(res && res.stores) ? res.stores : [];
} catch (error) {
console.error('[replenishShorts] 加载货主失败:', error);
uni.showToast({ title: error?.message || error?.msg || '加载货主失败', icon: 'none' });
} finally {
this.storeLoading = false;
}
},
getStoreId(store) {
return store?.value ?? store?.id ?? store?.store_id ?? store?.storeId;
},
getStoreName(store) {
return store?.label || store?.name || store?.store_name || '-';
},
isStoreSelected(store) {
const id = this.getStoreId(store);
if (id === undefined || id === null) return false;
return this.pendingSelectedStoreIds.some(sel => String(sel) === String(id));
},
toggleStore(store) {
const id = this.getStoreId(store);
if (id === undefined || id === null) return;
const index = this.pendingSelectedStoreIds.findIndex(sel => String(sel) === String(id));
if (index >= 0) {
this.pendingSelectedStoreIds.splice(index, 1);
} else {
this.pendingSelectedStoreIds.push(id);
}
},
clearStoreSelection() {
this.pendingSelectedStoreIds = [];
},
resetStoreSelection() {
this.pendingSelectedStoreIds = [];
this.storeSearchText = '';
},
applyStoreSelection() {
this.selectedStoreIds = [...this.pendingSelectedStoreIds];
this.storeDrawerVisible = false;
this.page = 1;
this.list = [];
this.fetchData();
},
handleStoreDrawerClose() {
this.storeDrawerVisible = false;
},
handleBack() {
uni.navigateBack({ delta: 1 });
},
@ -219,12 +442,12 @@
getSummaryVal(val) {
return val ?? 0;
},
formatLocations(locations) {
if (!Array.isArray(locations) || locations.length === 0) return '-';
return locations.map(loc => {
const spaceLabel = loc.space_name || loc.name || loc.custom_name || loc.space_code || '-';
return `${spaceLabel}(${loc.available_quantity})`;
}).join('、');
formatSpaceLabel(loc) {
return loc.space_name || loc.name || loc.custom_name || loc.space_code || '-';
},
formatBarcodes(barcodes) {
if (!Array.isArray(barcodes) || barcodes.length === 0) return '-';
return barcodes.map(b => b.barcode || b.code || b.custom_code || '').filter(Boolean).join('、');
},
replenishStatusText(status) {
const map = {
@ -261,6 +484,9 @@
sortOrder: this.sort.sortOrder
}
};
if (this.selectedStoreIds.length > 0) {
params.store_id = this.selectedStoreIds.map(id => Number(id));
}
const res = await this.$http('storage.management.replenishmentDemand', params);
@ -313,12 +539,52 @@
min-width: 112rpx;
display: flex;
align-items: center;
gap: 16rpx;
}
.header-side--left {
justify-content: flex-start;
}
.header-side__btn {
display: flex;
align-items: center;
gap: 6rpx;
padding: 12rpx 16rpx;
border-radius: 8rpx;
background: #f5f7fa;
}
.header-side__btn--store {
background: #07c160;
padding: 12rpx 28rpx;
margin-left: 32rpx;
}
.header-side__btn--store .header-side__btn-text {
color: #ffffff;
font-size: 30rpx;
}
.header-side__btn-badge {
min-width: 28rpx;
height: 28rpx;
padding: 0 6rpx;
border-radius: 14rpx;
background: #ff4d4f;
color: #ffffff;
font-size: 20rpx;
line-height: 28rpx;
text-align: center;
box-sizing: border-box;
}
.header-side__btn-text {
font-size: 26rpx;
color: #303133;
line-height: 1;
}
.header-side--right {
justify-content: flex-end;
}
@ -439,6 +705,7 @@
/* ===== 页面主体 ===== */
.page-body {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
@ -486,6 +753,7 @@
/* ===== 卡片列表 ===== */
.card-scroll {
flex: 1;
min-height: 0;
overflow: hidden;
}
@ -584,6 +852,10 @@
font-size: 28rpx;
}
.card-metric__value--spaces-qty {
font-weight: 700;
}
/* ===== 加载更多 ===== */
.loadmore-state {
display: flex;
@ -646,4 +918,141 @@
color: #c0c4cc;
background: #f5f7fa;
}
/* ===== 货主抽屉 ===== */
.store-drawer-layer {
position: fixed;
top: 0;
left: 0;
width: 0;
height: 0;
overflow: visible;
z-index: 9999;
}
.store-drawer {
width: 560rpx;
height: calc(100vh - var(--status-bar-height));
display: flex;
flex-direction: column;
background: #ffffff;
}
.store-drawer__header {
height: 88rpx;
padding: 0 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1rpx solid #ebeef5;
flex-shrink: 0;
}
.store-drawer__close {
display: flex;
align-items: center;
justify-content: center;
padding: 8rpx;
}
.store-drawer__title {
font-size: 32rpx;
font-weight: bold;
color: #303133;
}
.store-drawer__loading {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 16rpx;
}
.store-drawer__loading-text {
font-size: 26rpx;
color: #909399;
}
.store-drawer__list {
flex: 1;
min-height: 0;
}
.store-drawer__search {
padding: 16rpx 24rpx;
border-bottom: 1rpx solid #f0f2f5;
flex-shrink: 0;
}
.store-drawer__item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
padding: 28rpx 32rpx;
border-bottom: 1rpx solid #f0f2f5;
}
.store-drawer__item--active {
background: #f0f9f0;
}
.store-drawer__item-name {
font-size: 30rpx;
color: #303133;
line-height: 1.4;
word-break: break-all;
}
.store-drawer__footer {
flex-shrink: 0;
padding: 20rpx 24rpx;
border-top: 1rpx solid #ebeef5;
background: #ffffff;
}
.store-drawer__footer-info {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
}
.store-drawer__footer-text {
font-size: 26rpx;
color: #909399;
}
.store-drawer__footer-clear {
font-size: 26rpx;
color: #2979ff;
}
.store-drawer__footer-btns {
display: flex;
gap: 16rpx;
}
.store-drawer__footer-btn {
flex: 1;
height: 72rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8rpx;
font-size: 30rpx;
line-height: 1;
}
.store-drawer__footer-btn--reset {
background: #f5f7fa;
color: #606266;
}
.store-drawer__footer-btn--confirm {
background: #07c160;
color: #ffffff;
}
</style>

View File

@ -60,8 +60,9 @@
class="record-value"
:class="getReviewStatusText(item) === '已复核' ? 'record-value--reviewed' : (isIntercepted(item) ? 'record-value--intercepted-unreviewed' : 'record-value--unreviewed')"
>{{ getReviewStatusText(item) }}</text>
<!-- 波次序号:散单模式(listType==='single')下 pick_mode 为 2/3 时也显示;其它模式仅 pick_mode 非 2/3 时显示 -->
<text
v-if="item.waveIndex && Number(pickMode) !== 3 && Number(pickMode) !== 2"
v-if="item.waveIndex && (listType === 'single' || (Number(pickMode) !== 3 && Number(pickMode) !== 2))"
class="record-value record-value--wave-index"
:class="{ 'record-value--wave-index-reviewed': getReviewStatusText(item) === '已复核' }"
>[{{ item.waveIndex }}]</text>
@ -69,7 +70,8 @@
class="record-value record-value--id"
:class="{ 'record-value--id-reviewed': getReviewStatusText(item) === '已复核' }"
>{{ listType === 'single' ? (item.waybillNo || '--') : (item.waveNo || '--') }}</text>
<text v-if="item.boxNo && Number(pickMode) !== 3" class="record-value record-value--box-no">{{ item.boxNo }}号篮</text>
<!-- 篮号:与详情页一致,pick_mode 为 2(单品单件)/3(先拣后分)时均隐藏 -->
<text v-if="item.boxNo && Number(pickMode) !== 3 && Number(pickMode) !== 2" class="record-value record-value--box-no">{{ item.boxNo }}号篮</text>
<view class="record-print-col">
<text v-if="getPrintStatusText(item) === '已打印'" class="record-value record-value--printed">已打印</text>
<text

View File

@ -100,6 +100,7 @@
</view>
<view class="list-card-image-wrap" @click.stop="previewListGoodsImage(item)">
<u-image
:key="'goods-img-' + index + '-' + (item.imageUrl || 'noimg')"
class="list-card-image"
:src="item.imageUrl || ''"
mode="aspectFill"
@ -156,6 +157,7 @@
<view class="multi-match-card" @click="handleMultiMatchSelect()">
<view class="multi-match-thumb">
<u-image
:key="'multi-match-img-' + (multiMatchFirst.imageUrl || 'noimg')"
class="multi-match-image"
:src="multiMatchFirst.imageUrl || ''"
mode="aspectFill"