修改拆单、面单补打页面
This commit is contained in:
parent
5795083c3f
commit
941d9d30e9
@ -368,6 +368,12 @@ export default {
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
getPrintDataByWaybillCodes: {
|
||||
path: "order.print.getPrintDataByWaybillCodes",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
getOrderPrintData: {
|
||||
path: "order.print.getOrderPrintData",
|
||||
auth: true,
|
||||
@ -403,13 +409,13 @@ export default {
|
||||
},
|
||||
pendingOrder: {
|
||||
list: {
|
||||
path: "order.pendingOrder.list",
|
||||
path: "index.toOrder",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
detail: {
|
||||
path: "order.pendingOrder.detail",
|
||||
path: "order.detail",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
|
||||
4
env.js
4
env.js
@ -1,4 +1,4 @@
|
||||
// export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
|
||||
export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
|
||||
export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
|
||||
// export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
|
||||
export const API_URL = `${BASE_URL}/system` //后台接口域名
|
||||
export const IMG_URL = 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss
|
||||
|
||||
@ -336,49 +336,21 @@ export default {
|
||||
uni.showLoading({ title: '查询订单中...' });
|
||||
|
||||
try {
|
||||
// 1. 查询待处理订单列表,按快递单号匹配
|
||||
const listResponse = await this.$http('order.pendingOrder.list', {
|
||||
pagination: {
|
||||
page: 1,
|
||||
pageSize: 20
|
||||
},
|
||||
where: {
|
||||
waybill_codes: {
|
||||
operator: 'eq',
|
||||
type: 'text',
|
||||
value: normalizedKeyword
|
||||
}
|
||||
},
|
||||
sort: {
|
||||
sortField: 'updated_at',
|
||||
sortOrder: 'DESC'
|
||||
}
|
||||
// 1. 调用 common.toOrder 按快递单号获取订单ID
|
||||
const toOrderRes = await this.$http('common.toOrder', {
|
||||
waybill_code: normalizedKeyword
|
||||
});
|
||||
|
||||
if (listResponse?.flag === 'failure') {
|
||||
const errMsg = String(listResponse?.message || listResponse?.msg || '订单查询失败');
|
||||
if (toOrderRes?.flag === 'failure') {
|
||||
const errMsg = String(toOrderRes?.message || toOrderRes?.msg || '订单查询失败');
|
||||
uni.showToast({ title: errMsg, icon: 'none' });
|
||||
this.speakVoice('无记录');
|
||||
this.subOrderList = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const orderList = Array.isArray(listResponse?.data?.list) ? listResponse.data.list
|
||||
: Array.isArray(listResponse?.data) ? listResponse.data
|
||||
: [];
|
||||
if (!orderList.length) {
|
||||
uni.showToast({ title: '未查询到订单', icon: 'none' });
|
||||
this.speakVoice('无记录');
|
||||
this.subOrderList = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const matchedOrder = orderList.find(o =>
|
||||
String(o.waybill_code || o.waybillCode || '').replace(/\s+/g, '') === normalizedKeyword
|
||||
) || orderList[0];
|
||||
const orderId = matchedOrder?.id || matchedOrder?.order_id || '';
|
||||
|
||||
if (!orderId) {
|
||||
const orderId = Number(toOrderRes?.order_id);
|
||||
if (!orderId || orderId <= 0) {
|
||||
uni.showToast({ title: '未查询到订单', icon: 'none' });
|
||||
this.speakVoice('无记录');
|
||||
this.subOrderList = [];
|
||||
@ -387,10 +359,10 @@ export default {
|
||||
this.orderId = orderId;
|
||||
|
||||
// 2. 获取订单详情(含子单信息)
|
||||
const detailResponse = await this.$http('order.pendingOrder.detail', {
|
||||
const detailResponse = await this.$http('order.detail', {
|
||||
id: orderId,
|
||||
ids: [orderId],
|
||||
tableType: 'order'
|
||||
tableType: 'dispatch'
|
||||
});
|
||||
|
||||
if (detailResponse?.flag === 'failure') {
|
||||
@ -414,20 +386,22 @@ export default {
|
||||
}
|
||||
},
|
||||
normalizeOrderInfo(data) {
|
||||
const detail = data?.detail || {};
|
||||
const expresses = Array.isArray(data?.expresses) ? data.expresses : [];
|
||||
const mainExpress = expresses.find(e => String(e.business_key) === '1') || expresses[0] || {};
|
||||
return {
|
||||
id: data?.id || data?.order_id || '',
|
||||
waybillCode: data?.waybill_code || data?.waybillCode || '',
|
||||
orderNo: data?.order_no || data?.orderNo || ''
|
||||
id: detail?.id || '',
|
||||
waybillCode: mainExpress?.waybill_code || '',
|
||||
orderNo: detail?.delivery_order_code || ''
|
||||
};
|
||||
},
|
||||
normalizeSubOrders(data) {
|
||||
const list = Array.isArray(data?.sub_orders) ? data.sub_orders
|
||||
: Array.isArray(data?.subOrders) ? data.subOrders
|
||||
: Array.isArray(data?.children) ? data.children
|
||||
: [];
|
||||
return list.map(sub => ({
|
||||
id: sub?.id || sub?.sub_order_id || sub?.order_id || '',
|
||||
waybillCode: sub?.waybill_code || sub?.waybillCode || sub?.sub_waybill || ''
|
||||
const expresses = Array.isArray(data?.expresses) ? data.expresses : [];
|
||||
// 异步任务模式:business_key 从 2 开始为子单号
|
||||
const subExpresses = expresses.filter(e => Number(e.business_key) >= 2);
|
||||
return subExpresses.map(exp => ({
|
||||
id: exp?.id || '',
|
||||
waybillCode: exp?.waybill_code || ''
|
||||
}));
|
||||
},
|
||||
/* ===== 拆单操作 ===== */
|
||||
@ -465,26 +439,57 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const taskStatus = response?.data?.status || response?.status || '';
|
||||
const taskMessage = response?.data?.message || response?.message || '拆单成功';
|
||||
|
||||
uni.showToast({ title: taskMessage, icon: 'success' });
|
||||
this.speakVoice('拆单成功');
|
||||
|
||||
// 重新查询订单详情刷新子单列表
|
||||
// 分配子单号为异步任务,轮询等待子单号生成
|
||||
if (this.orderId) {
|
||||
try {
|
||||
const detailResponse = await this.$http('order.pendingOrder.detail', {
|
||||
id: this.orderId,
|
||||
ids: [this.orderId],
|
||||
tableType: 'order'
|
||||
});
|
||||
const data = detailResponse?.data || detailResponse?.result || {};
|
||||
this.orderInfo = this.normalizeOrderInfo(data);
|
||||
this.subOrderList = this.normalizeSubOrders(data);
|
||||
} catch (e) {
|
||||
console.warn('[splitOrder] 刷新子单列表失败:', e);
|
||||
let retryCount = 0;
|
||||
const maxRetries = 10;
|
||||
let subOrders = [];
|
||||
|
||||
while (retryCount < maxRetries) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1500));
|
||||
retryCount += 1;
|
||||
uni.showLoading({ title: `等待子单号生成中...(${retryCount}/${maxRetries})` });
|
||||
|
||||
try {
|
||||
const detailResponse = await this.$http('order.detail', {
|
||||
id: this.orderId,
|
||||
ids: [this.orderId],
|
||||
tableType: 'dispatch'
|
||||
});
|
||||
const data = detailResponse?.data || detailResponse?.result || {};
|
||||
subOrders = this.normalizeSubOrders(data);
|
||||
if (subOrders.length > 0) {
|
||||
this.orderInfo = this.normalizeOrderInfo(data);
|
||||
this.subOrderList = subOrders;
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[splitOrder] 轮询子单号失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
if (subOrders.length === 0) {
|
||||
// 最后一次尝试,获取当前数据
|
||||
try {
|
||||
const detailResponse = await this.$http('order.detail', {
|
||||
id: this.orderId,
|
||||
ids: [this.orderId],
|
||||
tableType: 'dispatch'
|
||||
});
|
||||
const data = detailResponse?.data || detailResponse?.result || {};
|
||||
this.orderInfo = this.normalizeOrderInfo(data);
|
||||
this.subOrderList = this.normalizeSubOrders(data);
|
||||
} catch (e) {
|
||||
console.warn('[splitOrder] 刷新子单列表失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
uni.showToast({ title: taskMessage, icon: 'success' });
|
||||
} else {
|
||||
uni.showToast({ title: taskMessage, icon: 'success' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[splitOrder] 拆单失败:', error);
|
||||
@ -522,8 +527,8 @@ export default {
|
||||
uni.showLoading({ title: '获取打印数据...' });
|
||||
|
||||
try {
|
||||
const printDataResponse = await this.$http('order.print.getOrderPrintData', {
|
||||
order_ids: orderList.map(s => s.id)
|
||||
const printDataResponse = await this.$http('order.print.getPrintDataByWaybillCodes', {
|
||||
waybill_codes: orderList.map(s => s.waybillCode)
|
||||
});
|
||||
const printPayload = this.extractOrderPrintPayload(printDataResponse);
|
||||
const waveGroups = this.normalizeOrderPrintGroups(printPayload);
|
||||
@ -843,7 +848,7 @@ export default {
|
||||
|
||||
/* ===== 订单信息卡 ===== */
|
||||
.order-card {
|
||||
margin: 0 24rpx;
|
||||
margin: 0 12rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 12rpx;
|
||||
flex-shrink: 0;
|
||||
@ -854,7 +859,7 @@ export default {
|
||||
.order-card__line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 24rpx;
|
||||
padding: 0 12rpx;
|
||||
height: 88rpx;
|
||||
}
|
||||
|
||||
@ -888,12 +893,12 @@ export default {
|
||||
.order-card__divider {
|
||||
height: 1rpx;
|
||||
background: #f2f3f5;
|
||||
margin: 0 24rpx;
|
||||
margin: 0 12rpx;
|
||||
}
|
||||
|
||||
/* ===== 子单号区 ===== */
|
||||
.order-card__sub-section {
|
||||
padding: 12rpx 24rpx;
|
||||
padding: 12rpx 12rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
@ -904,6 +909,7 @@ export default {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.order-card__sub-empty {
|
||||
@ -912,10 +918,12 @@ export default {
|
||||
}
|
||||
|
||||
.sub-tag {
|
||||
width: 100%;
|
||||
background: #f5f7fa;
|
||||
border: 1rpx solid #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
padding: 16rpx 20rpx;
|
||||
padding: 20rpx 36rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sub-tag:active {
|
||||
@ -923,7 +931,7 @@ export default {
|
||||
}
|
||||
|
||||
.sub-tag__text {
|
||||
font-size: 30rpx;
|
||||
font-size: 36rpx;
|
||||
color: #2979ff;
|
||||
font-weight: 500;
|
||||
}
|
||||
@ -933,7 +941,7 @@ export default {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
padding: 12rpx 24rpx 12rpx;
|
||||
padding: 12rpx 12rpx 12rpx;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user