修改散单拣货详情页
This commit is contained in:
parent
6f5495c097
commit
745a556a7e
@ -269,6 +269,14 @@ export default {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
isSystemApi: true
|
isSystemApi: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
recheckOrder: {
|
||||||
|
scanOrder: {
|
||||||
|
path: "order.recheckOrder.scanOrder",
|
||||||
|
auth: true,
|
||||||
|
method: "POST",
|
||||||
|
isSystemApi: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
print: {
|
print: {
|
||||||
|
|||||||
@ -7,6 +7,31 @@
|
|||||||
</template>
|
</template>
|
||||||
</page-nav>
|
</page-nav>
|
||||||
|
|
||||||
|
<view class="search-filter">
|
||||||
|
<view class="search-box">
|
||||||
|
<view class="search-box-inner">
|
||||||
|
<u-search
|
||||||
|
v-model="keyword"
|
||||||
|
placeholder="请输入快递单号/车号"
|
||||||
|
:bg-color="'#f5f5f5'"
|
||||||
|
shape="round"
|
||||||
|
:show-action="false"
|
||||||
|
@search="handleSearch"
|
||||||
|
@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>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<scroll-view class="detail-scroll" scroll-y>
|
<scroll-view class="detail-scroll" scroll-y>
|
||||||
<view v-if="displayOrderList.length === 0" class="empty-state">
|
<view v-if="displayOrderList.length === 0" class="empty-state">
|
||||||
<u-icon name="list" size="86" color="#c0c4cc"></u-icon>
|
<u-icon name="list" size="86" color="#c0c4cc"></u-icon>
|
||||||
@ -74,6 +99,7 @@
|
|||||||
return {
|
return {
|
||||||
title: '拣货详情(未复核)',
|
title: '拣货详情(未复核)',
|
||||||
grabCount: 0,
|
grabCount: 0,
|
||||||
|
keyword: '',
|
||||||
onlyMine: false,
|
onlyMine: false,
|
||||||
currentUserId: '',
|
currentUserId: '',
|
||||||
showPrintPopup: false,
|
showPrintPopup: false,
|
||||||
@ -85,13 +111,30 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
displayOrderList() {
|
displayOrderList() {
|
||||||
if (!this.onlyMine) {
|
let list = this.onlyMine
|
||||||
return this.orderList;
|
? this.orderList.filter(item => item.isMine)
|
||||||
|
: this.orderList;
|
||||||
|
|
||||||
|
const keyword = this.normalizeKeyword(this.keyword).toLowerCase();
|
||||||
|
if (!keyword) {
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
return this.orderList.filter(item => item.isMine);
|
|
||||||
|
list = list.filter(item => {
|
||||||
|
const waybillCode = this.normalizeKeyword(item?.waybillCode).toLowerCase();
|
||||||
|
const cartNo = this.normalizeKeyword(item?.cartNo).toLowerCase();
|
||||||
|
return waybillCode.includes(keyword) || cartNo.includes(keyword);
|
||||||
|
});
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
this.safeDispatchBroadcast('setCallbacks', {
|
||||||
|
onResult: this.handleBroadcastResult
|
||||||
|
});
|
||||||
|
this.safeDispatchBroadcast('start');
|
||||||
|
|
||||||
this.currentUserId = String(this.$store?.getters?.user?.id || this.$store?.getters?.user?.user_id || '');
|
this.currentUserId = String(this.$store?.getters?.user?.id || this.$store?.getters?.user?.user_id || '');
|
||||||
const hasGrabCountParam = options && Object.prototype.hasOwnProperty.call(options, 'grabCount');
|
const hasGrabCountParam = options && Object.prototype.hasOwnProperty.call(options, 'grabCount');
|
||||||
const parsedGrabCount = Number(options?.grabCount || 0);
|
const parsedGrabCount = Number(options?.grabCount || 0);
|
||||||
@ -100,7 +143,218 @@
|
|||||||
: 5;
|
: 5;
|
||||||
this.orderList = this.buildMockOrderList(this.grabCount);
|
this.orderList = this.buildMockOrderList(this.grabCount);
|
||||||
},
|
},
|
||||||
|
onShow() {
|
||||||
|
this.safeDispatchBroadcast('setCallbacks', {
|
||||||
|
onResult: this.handleBroadcastResult
|
||||||
|
});
|
||||||
|
this.safeDispatchBroadcast('resume');
|
||||||
|
},
|
||||||
|
onHide() {
|
||||||
|
this.safeDispatchBroadcast('pause');
|
||||||
|
},
|
||||||
|
onUnload() {
|
||||||
|
this.safeDispatchBroadcast('stop');
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
safeDispatchBroadcast(action, payload) {
|
||||||
|
try {
|
||||||
|
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||||||
|
if (task && typeof task.catch === 'function') {
|
||||||
|
task.catch(error => {
|
||||||
|
console.warn(`[ScatterPickingDetail] broadcast/${action} 调用失败:`, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`[ScatterPickingDetail] broadcast/${action} 调用异常:`, error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
normalizeKeyword(value) {
|
||||||
|
return String(value || '').replace(/\s+/g, '');
|
||||||
|
},
|
||||||
|
normalizeScanResult(scanResult) {
|
||||||
|
if (!scanResult) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof scanResult === 'string') {
|
||||||
|
return this.normalizeKeyword(scanResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof scanResult.result === 'string') {
|
||||||
|
return this.normalizeKeyword(scanResult.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(scanResult.result)) {
|
||||||
|
const firstResult = scanResult.result.find(item => item);
|
||||||
|
if (typeof firstResult === 'string') {
|
||||||
|
return this.normalizeKeyword(firstResult);
|
||||||
|
}
|
||||||
|
if (firstResult && typeof firstResult.data === 'string') {
|
||||||
|
return this.normalizeKeyword(firstResult.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof scanResult.data === 'string') {
|
||||||
|
return this.normalizeKeyword(scanResult.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
handleBroadcastResult(result) {
|
||||||
|
const scanText = this.normalizeScanResult(result);
|
||||||
|
if (!scanText) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.keyword = scanText;
|
||||||
|
this.handleSearch();
|
||||||
|
},
|
||||||
|
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'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
clearSearch() {
|
||||||
|
this.keyword = '';
|
||||||
|
},
|
||||||
|
buildScanOrderParams(keyword) {
|
||||||
|
const value = this.normalizeKeyword(keyword);
|
||||||
|
return {
|
||||||
|
keyword: value,
|
||||||
|
value,
|
||||||
|
waybill_no: value,
|
||||||
|
waybillCode: value,
|
||||||
|
waybill_code: value,
|
||||||
|
cart_code: value,
|
||||||
|
cartCode: 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 orderId = Number(payload?.order_id || order?.order_id || order?.id || 0);
|
||||||
|
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,
|
||||||
|
waybillNo,
|
||||||
|
order,
|
||||||
|
items: Array.isArray(payload?.items) ? payload.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 (result?.matchType === 'cart') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '车号命中,已定位订单',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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'))}`,
|
||||||
|
`unreviewedCount=${encodeURIComponent(String(order?.unreviewed_count || order?.unreviewedCount || 0))}`,
|
||||||
|
`waybillNo=${encodeURIComponent(String(result?.waybillNo || '--'))}`,
|
||||||
|
`matchType=${encodeURIComponent(String(result?.matchType || ''))}`
|
||||||
|
];
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
},
|
||||||
toggleOnlyMine() {
|
toggleOnlyMine() {
|
||||||
this.onlyMine = !this.onlyMine;
|
this.onlyMine = !this.onlyMine;
|
||||||
},
|
},
|
||||||
@ -205,11 +459,88 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.detail-scroll {
|
.detail-scroll {
|
||||||
height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
|
height: calc(100vh - 120rpx - 112rpx - env(safe-area-inset-bottom));
|
||||||
padding: 20rpx 24rpx 0;
|
padding: 20rpx 24rpx 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search-filter {
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 20rpx 24rpx;
|
||||||
|
border: 1rpx solid #f0f0f0;
|
||||||
|
border-top: none;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box-inner {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .search-box-inner .u-search {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .search-box-inner .u-search__content {
|
||||||
|
padding-right: 200rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .search-box-inner .u-search__content__close {
|
||||||
|
margin-right: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-actions {
|
||||||
|
position: absolute;
|
||||||
|
right: 24rpx;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
height: 68rpx;
|
||||||
|
display: flex;
|
||||||
|
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;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: 0.88;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-btn__text {
|
||||||
|
font-size: 30rpx;
|
||||||
|
color: #2979ff;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.record-list {
|
.record-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user