修改复核发货的推荐包材的绑定,面单补打功能
This commit is contained in:
parent
815b82528d
commit
9342ce0c56
@ -386,6 +386,14 @@ export default {
|
|||||||
isSystemApi: true
|
isSystemApi: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
pendingOrder: {
|
||||||
|
list: {
|
||||||
|
path: "order.pendingOrder.list",
|
||||||
|
auth: true,
|
||||||
|
method: "POST",
|
||||||
|
isSystemApi: true
|
||||||
|
}
|
||||||
|
},
|
||||||
recheckOrder: {
|
recheckOrder: {
|
||||||
recheckOrderList: {
|
recheckOrderList: {
|
||||||
path: "order.recheckOrder.recheckOrderList",
|
path: "order.recheckOrder.recheckOrderList",
|
||||||
|
|||||||
@ -446,8 +446,8 @@ import voice from '@/core/utils/voice';
|
|||||||
|
|
||||||
uni.showLoading({ title: '查询订单中...' });
|
uni.showLoading({ title: '查询订单中...' });
|
||||||
try {
|
try {
|
||||||
// 1. 查询订单
|
// 1. 查询订单(按快递单号)
|
||||||
const scanResponse = await this.$http('order.recheckOrder.scanOrder', this.buildScanOrderParams(normalizedKeyword));
|
const scanResponse = await this.$http('order.pendingOrder.list', this.buildScanOrderParams(normalizedKeyword));
|
||||||
if (scanResponse?.flag === 'failure') {
|
if (scanResponse?.flag === 'failure') {
|
||||||
const errMsg = String(scanResponse?.message || scanResponse?.msg || '订单查询失败');
|
const errMsg = String(scanResponse?.message || scanResponse?.msg || '订单查询失败');
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
@ -456,8 +456,33 @@ import voice from '@/core/utils/voice';
|
|||||||
this.speakVoice('无记录');
|
this.speakVoice('无记录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const payload = this.extractScanOrderPayload(scanResponse);
|
|
||||||
const orderIds = this.extractOrderIdsFromResult(payload);
|
let orderIds;
|
||||||
|
if (this.reprintMode === 'wave') {
|
||||||
|
// 整波模式:先取波次号,再查整个波次的所有订单
|
||||||
|
const waveNo = this.extractWaveNoFromList(scanResponse);
|
||||||
|
if (!waveNo) {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '未查询到波次号', icon: 'none' });
|
||||||
|
this.addPrintMsg('未查询到波次号');
|
||||||
|
this.speakVoice('无记录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.addPrintMsg(`查询到波次: ${waveNo}`);
|
||||||
|
const waveResponse = await this.$http('order.pendingOrder.list', this.buildWaveNoParams(waveNo));
|
||||||
|
if (waveResponse?.flag === 'failure') {
|
||||||
|
const errMsg = String(waveResponse?.message || waveResponse?.msg || '波次订单查询失败');
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: errMsg, icon: 'none' });
|
||||||
|
this.addPrintMsg(`波次查询失败: ${errMsg}`);
|
||||||
|
this.speakVoice('无记录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
orderIds = this.extractOrderIdsFromPendingList(waveResponse);
|
||||||
|
} else {
|
||||||
|
// 单张模式:直接取当前订单ID
|
||||||
|
orderIds = this.extractOrderIdsFromPendingList(scanResponse);
|
||||||
|
}
|
||||||
if (!orderIds.length) {
|
if (!orderIds.length) {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({ title: '未查询到可补打的订单', icon: 'none' });
|
uni.showToast({ title: '未查询到可补打的订单', icon: 'none' });
|
||||||
@ -504,48 +529,39 @@ import voice from '@/core/utils/voice';
|
|||||||
},
|
},
|
||||||
/* ===== 补打辅助方法 ===== */
|
/* ===== 补打辅助方法 ===== */
|
||||||
buildScanOrderParams(keyword) {
|
buildScanOrderParams(keyword) {
|
||||||
return { keyword: this.normalizeKeyword(keyword) };
|
return {
|
||||||
},
|
where: {
|
||||||
extractScanOrderPayload(response) {
|
waybill_codes: {
|
||||||
const candidates = [response?.data?.data, response?.data, response?.result, response];
|
operator: 'eq',
|
||||||
for (let i = 0; i < candidates.length; i += 1) {
|
type: 'text',
|
||||||
const current = candidates[i];
|
value: this.normalizeKeyword(keyword)
|
||||||
if (current && typeof current === 'object') return current;
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
extractOrderIdsFromResult(payload) {
|
|
||||||
const listType = String(payload?.list_type || payload?.listType || '').trim();
|
|
||||||
const ids = [];
|
|
||||||
|
|
||||||
if (listType === 'single') {
|
|
||||||
const list = Array.isArray(payload?.list) ? payload.list : [];
|
|
||||||
list.forEach(item => {
|
|
||||||
const id = Number(item?.id ?? item?.order_id ?? item?.orderId ?? 0);
|
|
||||||
if (id > 0) ids.push(id);
|
|
||||||
});
|
|
||||||
} else if (listType === 'group') {
|
|
||||||
const waves = Array.isArray(payload?.waves || payload?.list) ? (payload?.waves || payload?.list) : [];
|
|
||||||
waves.forEach(wave => {
|
|
||||||
if (Array.isArray(wave?.order_ids)) {
|
|
||||||
wave.order_ids.forEach(id => { if (Number(id) > 0) ids.push(Number(id)); });
|
|
||||||
} else if (Array.isArray(wave?.orderIds)) {
|
|
||||||
wave.orderIds.forEach(id => { if (Number(id) > 0) ids.push(Number(id)); });
|
|
||||||
} else {
|
|
||||||
const subList = Array.isArray(wave?.list || wave?.items) ? (wave?.list || wave?.items) : [];
|
|
||||||
subList.forEach(item => {
|
|
||||||
const id = Number(item?.id ?? item?.order_id ?? item?.orderId ?? 0);
|
|
||||||
if (id > 0) ids.push(id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
} else {
|
};
|
||||||
// detail 模式
|
},
|
||||||
const orderId = Number(payload?.order_id ?? payload?.orderId ?? payload?.order?.id ?? 0);
|
buildWaveNoParams(waveNo) {
|
||||||
if (orderId > 0) ids.push(orderId);
|
return {
|
||||||
}
|
where: {
|
||||||
|
wave_no: {
|
||||||
return ids;
|
operator: 'eq',
|
||||||
|
type: 'text',
|
||||||
|
value: waveNo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
extractOrderIdsFromPendingList(response) {
|
||||||
|
const list = response?.data?.list || response?.data?.data?.list || response?.list;
|
||||||
|
if (!Array.isArray(list)) return [];
|
||||||
|
return list
|
||||||
|
.map(item => Number(item?.id || 0))
|
||||||
|
.filter(id => id > 0);
|
||||||
|
},
|
||||||
|
extractWaveNoFromList(response) {
|
||||||
|
const list = response?.data?.list || response?.data?.data?.list || response?.list;
|
||||||
|
if (!Array.isArray(list) || !list.length) return '';
|
||||||
|
const first = list.find(item => item && item.wave_no);
|
||||||
|
return first ? String(first.wave_no).trim() : '';
|
||||||
},
|
},
|
||||||
extractOrderPrintPayload(response) {
|
extractOrderPrintPayload(response) {
|
||||||
const candidates = [response?.data?.data, response?.data, response?.result, response];
|
const candidates = [response?.data?.data, response?.data, response?.result, response];
|
||||||
|
|||||||
@ -2116,8 +2116,24 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
|
|||||||
}
|
}
|
||||||
} else if (this.scannedPackageCode) {
|
} else if (this.scannedPackageCode) {
|
||||||
finalPackageCode = this.scannedPackageId || this.scannedPackageCode;
|
finalPackageCode = this.scannedPackageId || this.scannedPackageCode;
|
||||||
} else if (this.suggestedPkg?.id) {
|
} else if (this.suggestedPkg) {
|
||||||
finalPackageCode = this.suggestedPkg.id;
|
// 推荐包材兜底:优先使用 ID,如果后端没返回 ID 则用 code 搜索
|
||||||
|
finalPackageCode = this.suggestedPkg.id || this.suggestedPkg.material_id || '';
|
||||||
|
if (!finalPackageCode && this.suggestedPkg.code) {
|
||||||
|
try {
|
||||||
|
const res = await this.$http('setting.packageMaterial.search', { keyword: this.suggestedPkg.code });
|
||||||
|
const list = Array.isArray(res?.data) ? res.data : [];
|
||||||
|
const matched = list.find(item => String(item.material_code || '') === this.suggestedPkg.code) || list[0];
|
||||||
|
if (matched) {
|
||||||
|
finalPackageCode = String(matched.id || '');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('[packageBinding] 搜索推荐包材失败:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!finalPackageCode) {
|
||||||
|
uni.showToast({ title: '未找到推荐包材的 ID,包材未绑定', icon: 'none' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 并发提交:复核确认 + 包材绑定
|
// 并发提交:复核确认 + 包材绑定
|
||||||
const promises = [this.callConfirmRecheckInternal()];
|
const promises = [this.callConfirmRecheckInternal()];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user