修改分拣缺货补货、复核发货页面
This commit is contained in:
parent
93826c96ff
commit
e7086daddc
@ -4,11 +4,10 @@
|
||||
<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 class="header-btn-refresh">刷新</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -32,6 +31,24 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<view class="search-bar">
|
||||
<view class="search-bar__input-wrap">
|
||||
<u-icon name="search" size="20" color="#909399"></u-icon>
|
||||
<input
|
||||
class="search-bar__input"
|
||||
type="text"
|
||||
v-model="searchKeyword"
|
||||
placeholder="输入商品名称搜索..."
|
||||
placeholder-style="color: #c0c4cc; font-size: 34rpx;"
|
||||
confirm-type="search"
|
||||
/>
|
||||
<text v-if="searchKeyword" class="search-bar__clear" @click="searchKeyword = ''">
|
||||
<u-icon name="close-circle-fill" size="20" color="#c0c4cc"></u-icon>
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="page-body">
|
||||
<!-- 加载状态 -->
|
||||
<view v-if="loading" class="loading-state">
|
||||
@ -40,17 +57,17 @@
|
||||
</view>
|
||||
|
||||
<!-- 空数据 -->
|
||||
<view v-else-if="list.length === 0" class="empty-card">
|
||||
<view v-else-if="filteredList.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>
|
||||
<text class="empty-card__title">{{ list.length === 0 ? '暂无缺货数据' : '未找到匹配的商品' }}</text>
|
||||
<text class="empty-card__desc">{{ list.length === 0 ? '当前仓库所有SKU分拣区库存充足,无需补货。' : '请尝试其他搜索关键词' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 数据列表:卡片模式 -->
|
||||
<scroll-view v-else class="card-scroll" scroll-y>
|
||||
<view class="card-list">
|
||||
<view
|
||||
v-for="(item, index) in list"
|
||||
v-for="(item, index) in filteredList"
|
||||
:key="item.stock_id || index"
|
||||
class="card-item"
|
||||
@click="goProductQuery(item)"
|
||||
@ -62,40 +79,40 @@
|
||||
<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--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" :class="replenishStatusClass(item)">{{ replenishStatusText(item.replenishment_status) }}</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>
|
||||
<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>
|
||||
<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>
|
||||
<text class="card-metric__value">{{ formatQty(item.pick_zone_quantity) }}</text>
|
||||
</view>
|
||||
<view class="card-metric card-metric--0">
|
||||
<text class="card-metric__label">建议补货</text>
|
||||
<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>
|
||||
<text class="card-metric__value">{{ formatQty(item.storage_zone_quantity) }}</text>
|
||||
</view>
|
||||
<view class="card-metric card-metric--1">
|
||||
<text class="card-metric__label">补货状态</text>
|
||||
<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>
|
||||
<text class="card-metric__value card-metric__value--primary">{{ formatQty(item.replenishment_needed) }}</text>
|
||||
</view>
|
||||
<view class="card-metric card-metric--0">
|
||||
<text class="card-metric__label">补货库位</text>
|
||||
@ -146,6 +163,7 @@
|
||||
total: 0,
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
searchKeyword: '',
|
||||
sort: {
|
||||
sortField: 'shortage',
|
||||
sortOrder: 'DESC'
|
||||
@ -155,6 +173,16 @@
|
||||
computed: {
|
||||
totalPages() {
|
||||
return Math.max(1, Math.ceil(this.total / this.pageSize));
|
||||
},
|
||||
filteredList() {
|
||||
const keyword = this.searchKeyword.trim();
|
||||
if (!keyword) {
|
||||
return this.list;
|
||||
}
|
||||
return this.list.filter(item => {
|
||||
const name = String(item.stock_name || '').toLowerCase();
|
||||
return name.includes(keyword.toLowerCase());
|
||||
});
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@ -164,8 +192,9 @@
|
||||
goProductQuery(item) {
|
||||
const keyword = item.stock_name || item.stock_code || item.stock_id || '';
|
||||
const stockId = item.stock_id || '';
|
||||
uni.setStorageSync('replenish_query_keyword', keyword);
|
||||
uni.navigateTo({
|
||||
url: `/pages/work/product/query?keyword=${encodeURIComponent(keyword)}&stock_id=${encodeURIComponent(stockId)}`
|
||||
url: `/pages/work/product/query?stock_id=${encodeURIComponent(stockId)}`
|
||||
});
|
||||
},
|
||||
handleBack() {
|
||||
@ -313,9 +342,13 @@
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.header-side--right .header-action-text {
|
||||
margin-left: 0;
|
||||
color: #2979ff;
|
||||
.header-btn-refresh {
|
||||
padding: 14rpx 28rpx;
|
||||
background: #2979ff;
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
border-radius: 8rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* ===== 汇总统计栏 ===== */
|
||||
@ -367,6 +400,42 @@
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* ===== 搜索框 ===== */
|
||||
.search-bar {
|
||||
padding: 12rpx 16rpx;
|
||||
background: #ffffff;
|
||||
border-bottom: 1rpx solid #ebeef5;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.search-bar__input-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
background: #f5f7fa;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.search-bar__input {
|
||||
flex: 1;
|
||||
font-size: 34rpx;
|
||||
color: #303133;
|
||||
height: 48rpx;
|
||||
line-height: 48rpx;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.search-bar__clear {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 6rpx;
|
||||
}
|
||||
|
||||
/* ===== 页面主体 ===== */
|
||||
.page-body {
|
||||
flex: 1;
|
||||
@ -444,7 +513,7 @@
|
||||
}
|
||||
|
||||
.card-metric--1 {
|
||||
background: #f8f9fb;
|
||||
background: #f0f2f5;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
@ -488,7 +557,11 @@
|
||||
}
|
||||
|
||||
.card-metric__value--danger {
|
||||
color: #f56c6c;
|
||||
background-color: #f56c6c;
|
||||
color: #ffffff;
|
||||
padding: 18rpx 12rpx;
|
||||
margin: -18rpx 0;
|
||||
border-radius: 0 6rpx 6rpx 0;
|
||||
}
|
||||
|
||||
.card-metric__value--primary {
|
||||
@ -540,7 +613,7 @@
|
||||
/* ===== 底部统计栏 ===== */
|
||||
.bottom-bar {
|
||||
flex-shrink: 0;
|
||||
padding: 16rpx 24rpx;
|
||||
padding: 24rpx 24rpx;
|
||||
background: #ffffff;
|
||||
border-top: 1rpx solid #ebeef5;
|
||||
}
|
||||
@ -553,13 +626,13 @@
|
||||
}
|
||||
|
||||
.bottom-bar__text {
|
||||
font-size: 24rpx;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.pagination-btn {
|
||||
padding: 12rpx 24rpx;
|
||||
font-size: 26rpx;
|
||||
padding: 18rpx 36rpx;
|
||||
font-size: 30rpx;
|
||||
color: #2979ff;
|
||||
background: #f0f5ff;
|
||||
border-radius: 8rpx;
|
||||
|
||||
@ -251,6 +251,7 @@ import voice from '@/core/utils/voice';
|
||||
showMultiMatchPopup: false,
|
||||
multiMatchFirst: {},
|
||||
pendingScanCode: '',
|
||||
_dismissedMultiMatchCodes: [],
|
||||
_lastScanCode: '',
|
||||
_lastScanTime: 0
|
||||
};
|
||||
@ -381,6 +382,53 @@ import voice from '@/core/utils/voice';
|
||||
|
||||
// 多个商品匹配时,弹出底部抽屉显示第一个商品详情
|
||||
if (matchIndices.length > 1) {
|
||||
// 如果用户之前关闭过该条码的弹窗,不再弹出,自动分配到未扫完的商品
|
||||
if (this._dismissedMultiMatchCodes.includes(code)) {
|
||||
// 从匹配列表中找第一个未扫完的商品
|
||||
let matchIndex = -1;
|
||||
for (let i = 0; i < matchIndices.length; i++) {
|
||||
const idx = matchIndices[i];
|
||||
const item = this.goodsList[idx];
|
||||
if ((item?.scannedQty || 0) < (item?.planQty || 0)) {
|
||||
matchIndex = idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matchIndex === -1) {
|
||||
uni.showToast({ title: '所有匹配商品已复核完成', icon: 'none' });
|
||||
return true;
|
||||
}
|
||||
this.currentGoodsIndex = matchIndex;
|
||||
const matchedItem = this.goodsList[matchIndex];
|
||||
const maxQty = matchedItem?.planQty || 0;
|
||||
const currentScanned = matchedItem?.scannedQty || 0;
|
||||
const addQty = Math.min(this.scanQty || 1, maxQty - currentScanned);
|
||||
const newScanned = Math.min(currentScanned + addQty, maxQty);
|
||||
this.$emit('updateScannedQty', matchIndex, newScanned);
|
||||
const allDone = this.goodsList.every((item, idx) => {
|
||||
const qty = idx === matchIndex ? newScanned : (item.scannedQty || 0);
|
||||
return qty >= (item.planQty || 0);
|
||||
});
|
||||
if (allDone) {
|
||||
voice.speak('数据一致');
|
||||
}
|
||||
// 已扫数量达到计划数量时,标记为已匹配(显示绿底和"已匹配"状态)
|
||||
if (newScanned >= maxQty) {
|
||||
const matchedId = String(matchedItem?.id || '');
|
||||
if (matchedId) {
|
||||
this.matchedGoodsId = matchedId;
|
||||
if (typeof this.$set === 'function') {
|
||||
this.$set(this.matchedGoodsState, matchedId, true);
|
||||
} else {
|
||||
this.matchedGoodsState[matchedId] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((this.scanQty || 1) > 1) {
|
||||
this.$emit('resetScanQty');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const firstIdx = matchIndices[0];
|
||||
this.multiMatchFirst = { ...this.goodsList[firstIdx] };
|
||||
this.pendingScanCode = code;
|
||||
@ -527,6 +575,7 @@ import voice from '@/core/utils/voice';
|
||||
this.showMultiMatchPopup = false;
|
||||
this.multiMatchFirst = {};
|
||||
this.pendingScanCode = '';
|
||||
this._dismissedMultiMatchCodes = [];
|
||||
this._lastScanCode = '';
|
||||
this._lastScanTime = 0;
|
||||
},
|
||||
@ -535,6 +584,10 @@ import voice from '@/core/utils/voice';
|
||||
*/
|
||||
handleMultiMatchClose() {
|
||||
this.showMultiMatchPopup = false;
|
||||
// 将当前条码加入已忽略列表,关闭后不再弹窗提示
|
||||
if (this.pendingScanCode && !this._dismissedMultiMatchCodes.includes(this.pendingScanCode)) {
|
||||
this._dismissedMultiMatchCodes.push(this.pendingScanCode);
|
||||
}
|
||||
this.pendingScanCode = '';
|
||||
},
|
||||
handleMultiMatchSelect(index) {
|
||||
|
||||
@ -266,7 +266,12 @@
|
||||
});
|
||||
this.safeDispatchBroadcast('start');
|
||||
this.routeStockId = options?.stock_id || '';
|
||||
const routeKeyword = this.normalizeKeyword(options?.keyword || options?.barcode || options?.code || '');
|
||||
// 优先从存储中读取关键字(解决 URL 传参中文乱码问题)
|
||||
const storageKeyword = uni.getStorageSync('replenish_query_keyword') || '';
|
||||
const routeKeyword = this.normalizeKeyword(storageKeyword || options?.keyword || options?.barcode || options?.code || '');
|
||||
if (storageKeyword) {
|
||||
uni.removeStorageSync('replenish_query_keyword');
|
||||
}
|
||||
if (routeKeyword) {
|
||||
this.keyword = routeKeyword;
|
||||
}
|
||||
@ -706,19 +711,15 @@
|
||||
}
|
||||
});
|
||||
|
||||
if (!warehouseItemMap.size) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 找到 mergedList 中对应的商品
|
||||
// 找到 mergedList 中需要获取图片的商品
|
||||
const itemsToFetch = [];
|
||||
mergedList.forEach(item => {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
const id = item.id;
|
||||
if (id && warehouseItemMap.has(id)) {
|
||||
const id = item.id || item.stock_id;
|
||||
if (id && (warehouseItemMap.has(id) || !warehouseItemMap.size)) {
|
||||
itemsToFetch.push({ item, id });
|
||||
}
|
||||
});
|
||||
@ -772,6 +773,75 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 从 stock.warehouse.getBarcodes 接口获取商品条码
|
||||
* @param {Array} mergedList 合并后的商品列表
|
||||
*/
|
||||
async fetchProductBarcodes(mergedList) {
|
||||
if (!Array.isArray(mergedList) || !mergedList.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const itemsToFetch = mergedList.filter(item => {
|
||||
if (!item || typeof item !== 'object') return false;
|
||||
const id = item.id || item.stock_id;
|
||||
return !!id;
|
||||
});
|
||||
|
||||
if (!itemsToFetch.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[ProductQuery] 开始获取商品条码,数量:', itemsToFetch.length);
|
||||
|
||||
const results = await Promise.allSettled(
|
||||
itemsToFetch.map((item) => {
|
||||
const id = item.id || item.stock_id;
|
||||
return this.$http('stock.warehouse.getBarcodes', { id: Number(id) });
|
||||
})
|
||||
);
|
||||
|
||||
itemsToFetch.forEach((item, index) => {
|
||||
const result = results[index];
|
||||
if (result.status === 'rejected') {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = result.value;
|
||||
if (!response || response.code !== 200) {
|
||||
return;
|
||||
}
|
||||
|
||||
const barcodeList = this.extractBarcodeListFromResponse(response);
|
||||
const allBarcodes = (barcodeList || [])
|
||||
.map(entry => {
|
||||
if (!entry) return '';
|
||||
if (typeof entry === 'string') return entry.trim();
|
||||
if (typeof entry !== 'object') return '';
|
||||
return String(entry.barcode || entry.code || '').trim();
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
if (allBarcodes.length > 0) {
|
||||
item.barcodes = allBarcodes;
|
||||
console.log(`[ProductQuery] 商品 id=${item.id || item.stock_id} 获取到 ${allBarcodes.length} 个条码`);
|
||||
}
|
||||
});
|
||||
},
|
||||
extractBarcodeListFromResponse(response) {
|
||||
const candidates = [
|
||||
response?.data,
|
||||
response?.data?.data,
|
||||
response?.list,
|
||||
response
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
if (Array.isArray(candidates[i])) {
|
||||
return candidates[i];
|
||||
}
|
||||
}
|
||||
return [];
|
||||
},
|
||||
getBarcodeText(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return '--';
|
||||
@ -1032,20 +1102,12 @@
|
||||
},
|
||||
buildWarehouseListWhereParams(keyword) {
|
||||
const normalized = this.normalizeKeyword(keyword);
|
||||
if (!normalized && !this.routeStockId) {
|
||||
if (!normalized) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const where = {};
|
||||
|
||||
if (this.routeStockId) {
|
||||
where.stock_id = {
|
||||
operator: 'eq',
|
||||
value: this.routeStockId,
|
||||
type: 'number'
|
||||
};
|
||||
}
|
||||
|
||||
if (normalized) {
|
||||
if (this.isBarcodeLike(normalized)) {
|
||||
where.barcode = {
|
||||
@ -1055,7 +1117,7 @@
|
||||
};
|
||||
} else {
|
||||
where.item_name = {
|
||||
operator: 'like',
|
||||
operator: this.routeStockId ? 'eq' : 'like',
|
||||
value: normalized,
|
||||
type: 'string'
|
||||
};
|
||||
@ -1599,7 +1661,16 @@
|
||||
|
||||
if (searchOk || warehouseOk || listOk) {
|
||||
const detailList = listOk ? this.extractListFromResponse(listRes) : [];
|
||||
const mergedList = this.mergeProductResultLists(nextList, warehouseList, detailList);
|
||||
let mergedList = this.mergeProductResultLists(nextList, warehouseList, detailList);
|
||||
|
||||
// 从分拣缺货补货进入时,根据 stock_id 精确匹配
|
||||
if (this.routeStockId) {
|
||||
const targetStockId = Number(this.routeStockId);
|
||||
mergedList = mergedList.filter(item => {
|
||||
const id = Number(item.id || item.stock_id);
|
||||
return id === targetStockId;
|
||||
});
|
||||
}
|
||||
|
||||
// 异步获取商品图片(不阻塞主流程)
|
||||
this.fetchProductImages(mergedList, warehouseList).then(() => {
|
||||
@ -1609,6 +1680,11 @@
|
||||
console.warn('[ProductQuery] 获取商品图片异常:', error);
|
||||
});
|
||||
|
||||
// 异步获取商品条码(不阻塞主流程)
|
||||
this.fetchProductBarcodes(mergedList).catch(error => {
|
||||
console.warn('[ProductQuery] 获取商品条码异常:', error);
|
||||
});
|
||||
|
||||
this.rawList = mergedList;
|
||||
this.updateDisplayListByMode(mergedList, keyword, isBarcodeKeyword);
|
||||
console.log('[ProductQuery] 搜索结果数量:', this.list.length);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user