修改订单拣货。复核发货页面
This commit is contained in:
parent
34015dc564
commit
e956e36e71
@ -123,7 +123,7 @@
|
||||
<view class="list-card-row__bottom">
|
||||
<text class="list-card-name">{{ item.skuName || '--' }}</text>
|
||||
<text class="list-card-space">{{' '}}</text>
|
||||
<text class="list-card-tag" @click.stop="handleListBarcodeClick(item, index)">{{ item.barcode || '--' }}</text>
|
||||
<text class="list-card-tag">{{ item.barcode || '--' }}</text>
|
||||
<text class="list-card-space">{{' '}}</text>
|
||||
<text class="list-card-tag">{{ item.location || '--' }}</text>
|
||||
</view>
|
||||
@ -589,7 +589,9 @@ import voice from '@/core/utils/voice';
|
||||
|
||||
// 已复核完成的商品,不再增加数量
|
||||
if (currentScanned >= maxQty) {
|
||||
uni.showToast({ title: '该商品已复核完成', icon: 'none' });
|
||||
// 无需复核商品(need_recheck=N)提示"无需复核",避免与实际已复核订单混淆
|
||||
const msg = this.isNoRecheck(matchedItem) ? '该商品无需复核' : '该商品已复核完成';
|
||||
uni.showToast({ title: msg, icon: 'none' });
|
||||
voice.speak('超出订单数');
|
||||
return true;
|
||||
}
|
||||
@ -639,6 +641,11 @@ import voice from '@/core/utils/voice';
|
||||
handleBarcodeClick() {
|
||||
const item = this.currentGoods;
|
||||
if (!item) return;
|
||||
// 无需复核商品(need_recheck=N):无需扫码/无条码复核,提示"无需复核"而非"已复核完成"
|
||||
if (this.isNoRecheck(item)) {
|
||||
uni.showToast({ title: '该商品无需复核', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const skuName = item.skuName || '商品';
|
||||
const planQty = item.planQty || 0;
|
||||
const scannedQty = item.scannedQty || 0;
|
||||
@ -674,11 +681,6 @@ import voice from '@/core/utils/voice';
|
||||
uni.showToast({ title: `已标记为已复核(${planQty}/${planQty})`, icon: 'success' });
|
||||
voice.speak('数据一致');
|
||||
},
|
||||
handleListBarcodeClick(item, index) {
|
||||
if (this.isReadOnly) return;
|
||||
this.currentGoodsIndex = index;
|
||||
this.openNoBarcodePopup(item);
|
||||
},
|
||||
handleListLongPress(item, index) {
|
||||
if (this.isReadOnly) return;
|
||||
this.currentGoodsIndex = index;
|
||||
@ -686,6 +688,12 @@ import voice from '@/core/utils/voice';
|
||||
},
|
||||
openNoBarcodePopup(item) {
|
||||
if (!item) return;
|
||||
// 无需复核商品(need_recheck=N,如虚拟赠品):无需扫码/无条码复核,
|
||||
// 提示"无需复核"而非"已复核完成",避免与真实已复核订单混淆
|
||||
if (this.isNoRecheck(item)) {
|
||||
uni.showToast({ title: '该商品无需复核', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const skuName = item.skuName || '商品';
|
||||
const planQty = item.planQty || 0;
|
||||
const scannedQty = item.scannedQty || 0;
|
||||
|
||||
@ -197,7 +197,11 @@
|
||||
</scroll-view>
|
||||
<view class="bind-cart-actions">
|
||||
<view class="bind-cart-btn bind-cart-btn--cancel" @click="closeBindCartPopup">取消</view>
|
||||
<view class="bind-cart-btn bind-cart-btn--confirm" @click="confirmBindCart">确定</view>
|
||||
<view
|
||||
class="bind-cart-btn bind-cart-btn--confirm"
|
||||
:class="{ 'bind-cart-btn--disabled': bindCartSubmitting }"
|
||||
@click="confirmBindCart"
|
||||
>{{ bindCartSubmitting ? '绑定中...' : '确定' }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
@ -340,6 +344,8 @@ import voice from '@/core/utils/voice';
|
||||
bindCartList: [],
|
||||
selectedBindCartItem: null,
|
||||
bindCartQueryKeyword: '',
|
||||
bindCartSubmitting: false,
|
||||
bindCartSearchSeq: 0,
|
||||
boundCartStorageKey: 'order_picking_bound_cart_v1',
|
||||
showActionsPopup: false,
|
||||
showNoBarcodePopup: false,
|
||||
@ -967,6 +973,8 @@ import voice from '@/core/utils/voice';
|
||||
// 以输入框当前值作为查询关键字,避免 bindCartQueryKeyword 缓存旧值导致第二次手动查询仍显示第一次的数据
|
||||
const keyword = String(this.bindCartNoInput || '').trim();
|
||||
this.bindCartQueryKeyword = keyword;
|
||||
// 竞态保护:网络卡顿下先发出的慢请求返回时不覆盖最新一次查询的结果
|
||||
const seq = ++this.bindCartSearchSeq;
|
||||
this.bindCartListLoading = true;
|
||||
try {
|
||||
const response = keyword
|
||||
@ -979,6 +987,9 @@ import voice from '@/core/utils/voice';
|
||||
current_task_id: this.getCurrentTaskIdNumber() || ''
|
||||
}
|
||||
}, '', false);
|
||||
if (seq !== this.bindCartSearchSeq) {
|
||||
return;
|
||||
}
|
||||
const payload = response?.data?.data || response?.data || response?.result || response || {};
|
||||
const list = Array.isArray(payload?.list)
|
||||
? payload.list
|
||||
@ -1002,14 +1013,23 @@ import voice from '@/core/utils/voice';
|
||||
this.selectedBindCartItem = null;
|
||||
}
|
||||
} catch (error) {
|
||||
if (seq !== this.bindCartSearchSeq) {
|
||||
return;
|
||||
}
|
||||
this.bindCartList = [];
|
||||
this.selectedBindCartItem = null;
|
||||
this.showErrorModal(this.getApiErrorMessage(error, '查询拣货车失败'));
|
||||
} finally {
|
||||
this.bindCartListLoading = false;
|
||||
if (seq === this.bindCartSearchSeq) {
|
||||
this.bindCartListLoading = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
async confirmBindCart() {
|
||||
// 防重复提交:网络卡顿时连点“确定”只发一次绑定请求
|
||||
if (this.bindCartSubmitting) {
|
||||
return;
|
||||
}
|
||||
const cartNo = String(this.bindCartNoInput || this.getBindCartNo(this.selectedBindCartItem) || '').trim();
|
||||
if (!cartNo) {
|
||||
uni.showToast({
|
||||
@ -1026,54 +1046,139 @@ import voice from '@/core/utils/voice';
|
||||
});
|
||||
return;
|
||||
}
|
||||
let cartName = this.getBindCartName(this.selectedBindCartItem);
|
||||
let selectedCartId = Number(
|
||||
this.selectedBindCartItem?.id ||
|
||||
this.selectedBindCartItem?.cart_id ||
|
||||
this.selectedBindCartItem?.cartId ||
|
||||
0
|
||||
);
|
||||
if (!cartName) {
|
||||
try {
|
||||
const response = await this.$http('pickCart.scan', { cart_code: cartNo }, '', false);
|
||||
const payload = response?.data?.data || response?.data || response?.result || response || {};
|
||||
const scannedItem = payload?.cart || payload?.data || payload;
|
||||
cartName = this.getBindCartName(scannedItem);
|
||||
selectedCartId = Number(
|
||||
scannedItem?.id ||
|
||||
scannedItem?.cart_id ||
|
||||
scannedItem?.cartId ||
|
||||
selectedCartId ||
|
||||
0
|
||||
);
|
||||
} catch (error) {
|
||||
cartName = '';
|
||||
}
|
||||
}
|
||||
const bindPayload = {
|
||||
task_id: taskIdNumber
|
||||
};
|
||||
if (Number.isFinite(selectedCartId) && selectedCartId > 0) {
|
||||
bindPayload.cart_id = selectedCartId;
|
||||
}
|
||||
this.bindCartSubmitting = true;
|
||||
try {
|
||||
const bindResponse = await this.$http('pickCart.bindTaskCart', bindPayload, '', false);
|
||||
if (String(bindResponse?.flag || '').toLowerCase() === 'failure') {
|
||||
this.showErrorModal(bindResponse?.message || '绑定拣货车失败');
|
||||
let cartName = this.getBindCartName(this.selectedBindCartItem);
|
||||
let selectedCartId = Number(
|
||||
this.selectedBindCartItem?.id ||
|
||||
this.selectedBindCartItem?.cart_id ||
|
||||
this.selectedBindCartItem?.cartId ||
|
||||
0
|
||||
);
|
||||
if (!cartName) {
|
||||
try {
|
||||
const response = await this.$http('pickCart.scan', { cart_code: cartNo }, '', false);
|
||||
const payload = response?.data?.data || response?.data || response?.result || response || {};
|
||||
const scannedItem = payload?.cart || payload?.data || payload;
|
||||
cartName = this.getBindCartName(scannedItem);
|
||||
selectedCartId = Number(
|
||||
scannedItem?.id ||
|
||||
scannedItem?.cart_id ||
|
||||
scannedItem?.cartId ||
|
||||
selectedCartId ||
|
||||
0
|
||||
);
|
||||
} catch (error) {
|
||||
cartName = '';
|
||||
}
|
||||
}
|
||||
const bindPayload = {
|
||||
task_id: taskIdNumber
|
||||
};
|
||||
if (Number.isFinite(selectedCartId) && selectedCartId > 0) {
|
||||
bindPayload.cart_id = selectedCartId;
|
||||
}
|
||||
try {
|
||||
const bindResponse = await this.requestWithTimeout(
|
||||
this.$http('pickCart.bindTaskCart', bindPayload, '', false),
|
||||
20000
|
||||
);
|
||||
if (String(bindResponse?.flag || '').toLowerCase() === 'failure') {
|
||||
this.showErrorModal(bindResponse?.message || '绑定拣货车失败');
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
// 网络卡顿/响应超时时,后端可能已绑定成功,导致“后端已绑定但页面未显示”。
|
||||
// 回查服务端确认当前任务的实际绑定状态,已绑定则按成功处理并刷新页面显示。
|
||||
const serverMatched = await this.queryBoundCartFromServer(cartNo, taskIdNumber);
|
||||
if (serverMatched) {
|
||||
const serverCartNo = this.getBindCartNo(serverMatched);
|
||||
const serverCartName = this.getBindCartName(serverMatched);
|
||||
this.boundCartNo = serverCartNo || cartNo;
|
||||
this.boundCartName = serverCartName || cartName;
|
||||
this.persistBoundCartForCurrentTask(this.boundCartNo, this.boundCartName);
|
||||
this.bindCartPopupVisible = false;
|
||||
uni.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.showErrorModal(this.getApiErrorMessage(error, '绑定拣货车失败'));
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
this.showErrorModal(this.getApiErrorMessage(error, '绑定拣货车失败'));
|
||||
return;
|
||||
this.boundCartNo = cartNo;
|
||||
this.boundCartName = cartName;
|
||||
this.persistBoundCartForCurrentTask(cartNo, cartName);
|
||||
this.bindCartPopupVisible = false;
|
||||
uni.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
this.bindCartSubmitting = false;
|
||||
}
|
||||
this.boundCartNo = cartNo;
|
||||
this.boundCartName = cartName;
|
||||
this.persistBoundCartForCurrentTask(cartNo, cartName);
|
||||
this.bindCartPopupVisible = false;
|
||||
uni.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'none'
|
||||
},
|
||||
requestWithTimeout(requestPromise, timeoutMs = 20000) {
|
||||
// 旁路消费原 promise 的 settle,避免超时先触发后其晚到的 rejection 变成未处理异常
|
||||
requestPromise.then(() => {}, () => {});
|
||||
let timer = null;
|
||||
const timeoutPromise = new Promise((_, reject) => {
|
||||
timer = setTimeout(() => {
|
||||
reject(new Error('请求超时,请稍后重试'));
|
||||
}, timeoutMs);
|
||||
});
|
||||
const clearTimer = () => {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
};
|
||||
return Promise.race([requestPromise, timeoutPromise]).then(
|
||||
value => {
|
||||
clearTimer();
|
||||
return value;
|
||||
},
|
||||
error => {
|
||||
clearTimer();
|
||||
throw error;
|
||||
}
|
||||
);
|
||||
},
|
||||
async queryBoundCartFromServer(cartNo, taskIdNumber) {
|
||||
const normalizedCartNo = this.normalizeBarcodeText(cartNo);
|
||||
const taskIdStr = String(taskIdNumber || '').trim();
|
||||
if (!normalizedCartNo || !taskIdStr) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const response = await this.$http('pickCart.list', {
|
||||
pagination: { page: 1, pageSize: 20 },
|
||||
where: {
|
||||
keyword: '',
|
||||
status: '',
|
||||
current_task_id: taskIdStr
|
||||
}
|
||||
}, '', false);
|
||||
const payload = response?.data?.data || response?.data || response?.result || response || {};
|
||||
const list = Array.isArray(payload?.list)
|
||||
? payload.list
|
||||
: Array.isArray(payload?.rows)
|
||||
? payload.rows
|
||||
: Array.isArray(payload?.items)
|
||||
? payload.items
|
||||
: (Array.isArray(payload?.data) ? payload.data : []);
|
||||
const matched = list.find(item => {
|
||||
const itemCartNo = this.normalizeBarcodeText(this.getBindCartNo(item));
|
||||
const itemTaskId = String(
|
||||
item?.current_task_id || item?.task_id || item?.taskId || ''
|
||||
).trim();
|
||||
return Boolean(itemCartNo) && itemCartNo === normalizedCartNo && itemTaskId === taskIdStr;
|
||||
});
|
||||
return matched || null;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
restoreBasketDisplayMode() {
|
||||
try {
|
||||
@ -3136,6 +3241,11 @@ import voice from '@/core/utils/voice';
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.bind-cart-btn--disabled {
|
||||
opacity: 0.6;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.index-text {
|
||||
position: absolute;
|
||||
top: 6rpx;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user