修改拣货模块

This commit is contained in:
zm2000 2026-06-06 17:58:30 +08:00
parent 30067969c8
commit 1999865c88
2 changed files with 79 additions and 222 deletions

View File

@ -138,6 +138,37 @@
this.loadBatchWaveNoList();
},
methods: {
normalizeReviewAssignmentStatus(status) {
const rawValue = status ?? '';
const normalized = String(rawValue).trim();
const lowerValue = normalized.toLowerCase();
const statusMap = {
'0': '未复核',
unreviewed: '未复核',
pending: '未复核',
todo: '未复核',
'1': '部分复核',
partial: '部分复核',
partial_reviewed: '部分复核',
'partial-reviewed': '部分复核',
part_reviewed: '部分复核',
reviewing: '部分复核',
'2': '已复核',
reviewed: '已复核',
done: '已复核',
completed: '已复核',
complete: '已复核',
fin: '已复核',
finished: '已复核'
};
if (statusMap[lowerValue]) {
return statusMap[lowerValue];
}
if (['未复核', '部分复核', '已复核'].includes(normalized)) {
return normalized;
}
return normalized || '未复核';
},
buildBatchListParams(page = this.currentPage) {
return {
pagination: {
@ -197,7 +228,8 @@
const waveId = source.wave_id ?? source.waveId ?? source.id ?? '';
const pickerName = String(source.picker_name || source.pickerName || source.user_name || source.userName || '--').trim() || '--';
const totalOrderCount = Number(source.total_order_count ?? source.totalOrderCount ?? source.order_count ?? source.orderCount ?? source.total_count ?? source.totalCount ?? source.order_num ?? source.orderNum ?? 0);
const pendingCount = Number(source.pending_count ?? source.pendingCount ?? source.unreviewed_count ?? source.unreviewedCount ?? 0);
const pendingCount = Number(source.unreviewed_order_count ?? source.unreviewedOrderCount ?? source.pending_count ?? source.pendingCount ?? source.unreviewed_count ?? source.unreviewedCount ?? 0);
const reviewAssignmentStatus = this.normalizeReviewAssignmentStatus(source.review_assignment_status ?? source.reviewAssignmentStatus ?? source.status);
const assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim();
return {
id: String(rowId || ''),
@ -206,7 +238,7 @@
pickerName,
totalOrderCount: Number.isFinite(totalOrderCount) ? totalOrderCount : 0,
pendingCount: Number.isFinite(pendingCount) ? pendingCount : 0,
status: String(source.status || 'pending'),
status: reviewAssignmentStatus,
isMine: !!this.currentUserId && !!assigneeId && assigneeId === this.currentUserId
};
})
@ -521,13 +553,7 @@
});
},
getStatusText(status) {
const map = {
pending: '待拣货',
picking: '拣货中',
picked: '已拣货',
completed: '已完成'
};
return map[String(status || 'pending')] || '待拣货';
return this.normalizeReviewAssignmentStatus(status);
},
async showRecordDetail(item) {
const target = item && typeof item === 'object' ? item : null;

View File

@ -12,7 +12,7 @@
<view class="search-box-inner">
<u-search
v-model="keyword"
placeholder="请输入快递单号/车号"
placeholder="请输入波次号"
:bg-color="'#f5f5f5'"
shape="round"
:show-action="false"
@ -20,10 +20,6 @@
@clear="clearSearch"
></u-search>
<view class="search-actions">
<view class="scan-btn" @click="handleCameraScan">
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
</view>
<view class="search-divider"></view>
<view class="search-btn" @click="handleSearch">
<text class="search-btn__text">搜索</text>
</view>
@ -180,6 +176,37 @@
this.safeDispatchBroadcast('stop');
},
methods: {
normalizeReviewAssignmentStatus(status) {
const rawValue = status ?? '';
const normalized = String(rawValue).trim();
const lowerValue = normalized.toLowerCase();
const statusMap = {
'0': '未复核',
unreviewed: '未复核',
pending: '未复核',
todo: '未复核',
'1': '部分复核',
partial: '部分复核',
partial_reviewed: '部分复核',
'partial-reviewed': '部分复核',
part_reviewed: '部分复核',
reviewing: '部分复核',
'2': '已复核',
reviewed: '已复核',
done: '已复核',
completed: '已复核',
complete: '已复核',
fin: '已复核',
finished: '已复核'
};
if (statusMap[lowerValue]) {
return statusMap[lowerValue];
}
if (['未复核', '部分复核', '已复核'].includes(normalized)) {
return normalized;
}
return normalized || '未复核';
},
buildBatchListParams(page = this.currentPage) {
const where = {
wave_type: 2
@ -187,6 +214,10 @@
if (this.onlyMine && this.currentUserId) {
where.picker_id = this.currentUserId;
}
const keyword = this.normalizeKeyword(this.keyword);
if (keyword) {
where.wave_no = keyword;
}
return {
pagination: {
page: Math.max(1, Number(page || 1)),
@ -244,7 +275,8 @@
const pickerName = String(source.picker_name || source.pickerName || source.user_name || source.userName || '--').trim() || '--';
const cartNo = String(source.cart_code || source.cartCode || source.cart_no || source.cartNo || '--').trim() || '--';
const totalOrderCount = Number(source.total_order_count ?? source.totalOrderCount ?? source.order_count ?? source.orderCount ?? source.total_count ?? source.totalCount ?? source.order_num ?? source.orderNum ?? 0);
const unreviewedCount = Number(source.unreviewed_count ?? source.unreviewedCount ?? source.pending_count ?? source.pendingCount ?? 0);
const unreviewedCount = Number(source.unreviewed_order_count ?? source.unreviewedOrderCount ?? source.unreviewed_count ?? source.unreviewedCount ?? source.pending_count ?? source.pendingCount ?? 0);
const reviewAssignmentStatus = this.normalizeReviewAssignmentStatus(source.review_assignment_status ?? source.reviewAssignmentStatus ?? source.status);
const assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim();
return {
id: String(rowId || `batch-${this.currentPage}-${index + 1}`),
@ -254,7 +286,7 @@
cartNo,
totalOrderCount: Number.isFinite(totalOrderCount) ? totalOrderCount : 0,
unreviewedCount: Number.isFinite(unreviewedCount) ? unreviewedCount : 0,
status: String(source.status || 'pending'),
status: reviewAssignmentStatus,
waybillCode: String(source.waybill_no || source.waybillCode || source.waybill_code || ''),
isMine: !!this.currentUserId && !!assigneeId && assigneeId === this.currentUserId
};
@ -490,190 +522,13 @@
},
handleSearch() {
this.keyword = this.normalizeKeyword(this.keyword);
this.requestScanOrder(this.keyword);
},
handleCameraScan() {
uni.scanCode({
onlyFromCamera: true,
scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
success: (res) => {
const scanResult = this.normalizeScanResult(res);
if (!scanResult) {
uni.showToast({
title: '未识别到有效条码',
icon: 'none'
});
return;
}
this.keyword = scanResult;
this.handleSearch();
},
fail: (error) => {
const errMsg = String(error?.errMsg || '').toLowerCase();
if (errMsg.includes('cancel')) {
return;
}
uni.showToast({
title: '扫码失败,请重试',
icon: 'none'
});
}
});
this.currentPage = 1;
this.loadBatchWaveNoList(1);
},
clearSearch() {
this.keyword = '';
},
buildScanOrderParams(keyword) {
const value = this.normalizeKeyword(keyword);
return {
keyword: value
};
},
extractScanOrderPayload(response) {
const candidates = [
response?.data?.data,
response?.data,
response?.result,
response
];
for (let i = 0; i < candidates.length; i += 1) {
const current = candidates[i];
if (current && typeof current === 'object') {
return current;
}
}
return {};
},
normalizeScanOrderResult(payload) {
const order = payload?.order && typeof payload.order === 'object' ? payload.order : {};
const items = Array.isArray(payload?.items) ? payload.items : [];
const firstItem = items[0] && typeof items[0] === 'object' ? items[0] : {};
const orderId = Number(
payload?.order_id
|| payload?.orderId
|| order?.order_id
|| order?.orderId
|| order?.id
|| firstItem?.order_id
|| firstItem?.orderId
|| 0
);
const recheckStatus = String(
payload?.recheck_status
|| payload?.recheckStatus
|| order?.recheck_status
|| order?.recheckStatus
|| ''
).trim().toLowerCase();
const waybillNo = String(
payload?.waybill_no
|| order?.waybill_no
|| order?.waybillCode
|| order?.waybill_code
|| ''
).trim();
const matchType = String(payload?.match_type || '').trim();
const cartMatchView = payload?.cart_match_view && typeof payload.cart_match_view === 'object'
? payload.cart_match_view
: null;
return {
matchType,
cartMatchView,
orderId,
recheckStatus,
waybillNo,
order,
items,
expresses: Array.isArray(payload?.expresses) ? payload.expresses : [],
logs: Array.isArray(payload?.logs) ? payload.logs : []
};
},
handleScanOrderSuccess(result) {
const order = result?.order || {};
const orderId = Number(result?.orderId || 0);
if (!orderId) {
uni.showToast({
title: '未查询到订单',
icon: 'none'
});
return;
}
if (String(result?.recheckStatus || '').toLowerCase() === 'fin') {
uni.showModal({
title: '提示',
content: '该订单已复核完成,禁止再次进入',
showCancel: false,
success: () => {
uni.navigateBack({
delta: 1
});
}
});
return;
}
if (result?.matchType === 'cart') {
uni.showToast({
title: '车号命中,已定位订单',
icon: 'none'
});
}
const cacheKey = `scatter_scan_order_${Date.now()}_${orderId}`;
try {
uni.setStorageSync(cacheKey, {
items: Array.isArray(result?.items) ? result.items : [],
expresses: Array.isArray(result?.expresses) ? result.expresses : [],
logs: Array.isArray(result?.logs) ? result.logs : []
});
} catch (error) {
console.warn('[ScatterPickingDetail] 缓存 scanOrder 结果失败:', error);
}
const params = [
`recordId=${encodeURIComponent(String(orderId))}`,
`orderId=${encodeURIComponent(String(orderId))}`,
`waveNo=${encodeURIComponent(String(order?.wave_no || order?.waveNo || '--'))}`,
`pickerName=${encodeURIComponent(String(order?.picker_name || order?.pickerName || '--'))}`,
`cartNo=${encodeURIComponent(String(order?.cart_code || order?.cartCode || order?.cart_no || order?.cartNo || '--'))}`,
`status=${encodeURIComponent(String(order?.status || 'pending'))}`,
`recheckStatus=${encodeURIComponent(String(result?.recheckStatus || order?.recheck_status || ''))}`,
`unreviewedCount=${encodeURIComponent(String(order?.unreviewed_count || order?.unreviewedCount || 0))}`,
`waybillNo=${encodeURIComponent(String(result?.waybillNo || '--'))}`,
`matchType=${encodeURIComponent(String(result?.matchType || ''))}`,
`cacheKey=${encodeURIComponent(cacheKey)}`
];
this.$tools.routerTo(`/pages/work/order/scatter-pick-goods-detail?${params.join('&')}`);
},
async requestScanOrder(keyword) {
const normalizedKeyword = this.normalizeKeyword(keyword);
if (!normalizedKeyword) {
uni.showToast({
title: '请输入快递单号或车号',
icon: 'none'
});
return;
}
uni.showLoading({
title: '查询订单中...'
});
try {
const response = await this.$http('order.recheckOrder.scanOrder', this.buildScanOrderParams(normalizedKeyword));
const payload = this.extractScanOrderPayload(response);
const result = this.normalizeScanOrderResult(payload);
this.handleScanOrderSuccess(result);
} catch (error) {
const message = String(error?.message || error?.msg || error?.errMsg || '').trim();
uni.showToast({
title: message || '订单查询失败',
icon: 'none'
});
} finally {
uni.hideLoading();
}
this.currentPage = 1;
this.loadBatchWaveNoList(1);
},
toggleOnlyMine() {
this.onlyMine = !this.onlyMine;
@ -681,12 +536,7 @@
this.loadBatchWaveNoList(1);
},
getStatusText(status) {
const map = {
pending: '待拣货',
picking: '拣货中',
done: '已完成'
};
return map[status] || '待拣货';
return this.normalizeReviewAssignmentStatus(status);
},
extractPickQueryPayload(response) {
const candidates = [
@ -1001,25 +851,6 @@
align-items: center;
}
.scan-btn {
height: 68rpx;
padding: 0 8rpx 0 4rpx;
display: flex;
align-items: center;
justify-content: center;
&:active {
opacity: 0.88;
}
}
.search-divider {
width: 1rpx;
height: 28rpx;
background: #dcdfe6;
margin: 0 16rpx 0 10rpx;
}
.search-btn {
height: 68rpx;
padding: 0 8rpx;