修改复核发货的推荐包材的绑定,面单补打功能

This commit is contained in:
zm2000 2026-07-02 15:35:10 +08:00
parent 815b82528d
commit 9342ce0c56
3 changed files with 87 additions and 47 deletions

View File

@ -386,6 +386,14 @@ export default {
isSystemApi: true
}
},
pendingOrder: {
list: {
path: "order.pendingOrder.list",
auth: true,
method: "POST",
isSystemApi: true
}
},
recheckOrder: {
recheckOrderList: {
path: "order.recheckOrder.recheckOrderList",

View File

@ -446,8 +446,8 @@ import voice from '@/core/utils/voice';
uni.showLoading({ title: '查询订单中...' });
try {
// 1. 查询订单
const scanResponse = await this.$http('order.recheckOrder.scanOrder', this.buildScanOrderParams(normalizedKeyword));
// 1. 查询订单(按快递单号)
const scanResponse = await this.$http('order.pendingOrder.list', this.buildScanOrderParams(normalizedKeyword));
if (scanResponse?.flag === 'failure') {
const errMsg = String(scanResponse?.message || scanResponse?.msg || '订单查询失败');
uni.hideLoading();
@ -456,8 +456,33 @@ import voice from '@/core/utils/voice';
this.speakVoice('无记录');
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) {
uni.hideLoading();
uni.showToast({ title: '未查询到可补打的订单', icon: 'none' });
@ -504,48 +529,39 @@ import voice from '@/core/utils/voice';
},
/* ===== 补打辅助方法 ===== */
buildScanOrderParams(keyword) {
return { keyword: this.normalizeKeyword(keyword) };
},
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 {};
},
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);
});
return {
where: {
waybill_codes: {
operator: 'eq',
type: 'text',
value: this.normalizeKeyword(keyword)
}
});
} else {
// detail 模式
const orderId = Number(payload?.order_id ?? payload?.orderId ?? payload?.order?.id ?? 0);
if (orderId > 0) ids.push(orderId);
}
return ids;
}
};
},
buildWaveNoParams(waveNo) {
return {
where: {
wave_no: {
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) {
const candidates = [response?.data?.data, response?.data, response?.result, response];

View File

@ -2116,8 +2116,24 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
}
} else if (this.scannedPackageCode) {
finalPackageCode = this.scannedPackageId || this.scannedPackageCode;
} else if (this.suggestedPkg?.id) {
finalPackageCode = this.suggestedPkg.id;
} else if (this.suggestedPkg) {
// 推荐包材兜底:优先使用 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()];