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