修改拆单页面

This commit is contained in:
zm2000 2026-07-28 18:28:43 +08:00
parent 569f32e2dc
commit 5795083c3f

View File

@ -79,11 +79,11 @@
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view class="order-card__actions"> <view class="order-card__actions">
<view class="action-btn action-btn--split" @click="handleSplitOrder"> <view v-show="!!currentWaybill" class="action-btn action-btn--split" @click="handleSplitOrder">
<text class="action-btn__text">拆单</text> <text class="action-btn__text">拆单</text>
</view> </view>
<view <view
v-if="subOrderList.length > 0" v-show="subOrderList.length > 0"
class="action-btn action-btn--print" class="action-btn action-btn--print"
@click="handlePrintAll" @click="handlePrintAll"
> >
@ -92,11 +92,9 @@
</view> </view>
</view> </view>
<!-- 加载态 --> <!-- 弹性填充,吸收卡片高度变化,防止页面抖动 -->
<view v-if="loading" class="loading-state"> <view class="flex-filler"></view>
<u-loading-icon mode="circle" size="48"></u-loading-icon>
<text class="loading-state__text">{{ loadingText }}</text>
</view>
</template> </template>
<!-- 拆单数量弹窗 --> <!-- 拆单数量弹窗 -->
@ -109,7 +107,7 @@
type="number" type="number"
placeholder="请输入拆单数量" placeholder="请输入拆单数量"
:clearable="false" :clearable="false"
:customStyle="{ fontSize: '36rpx', height: '100rpx', lineHeight: '100rpx', textAlign: 'center', background: '#f5f5f5', borderRadius: '12rpx', padding: '0 20rpx' }" :customStyle="{ height: '100rpx', lineHeight: '100rpx', textAlign: 'center', background: '#f5f5f5', borderRadius: '12rpx', padding: '0 20rpx' }"
></u-input> ></u-input>
</view> </view>
<view class="split-popup__actions"> <view class="split-popup__actions">
@ -177,8 +175,6 @@ export default {
manualInputOpen: false, manualInputOpen: false,
inputFocus: false, inputFocus: false,
scanKeyword: '', scanKeyword: '',
loading: false,
loadingText: '',
currentWaybill: '', currentWaybill: '',
orderId: null, orderId: null,
orderInfo: null, orderInfo: null,
@ -280,7 +276,27 @@ export default {
return; return;
} }
this.scanKeyword = ''; if (!this.printerId) {
// 未绑定打印台 → 扫描值尝试匹配打印台,匹配失败不弹窗
const keyword = this.normalizeKeyword(scanText);
const list = Array.isArray(this.printStationList) ? this.printStationList : [];
const matched = list.find(station =>
String(station.customBarcode || '').toLowerCase() === keyword.toLowerCase()
|| String(station.name).toLowerCase() === keyword.toLowerCase()
|| String(station.id).toLowerCase() === keyword.toLowerCase()
);
if (matched) {
this.printerId = String(matched.id);
this.printerName = String(matched.name || '');
uni.showToast({ title: `已绑定打印台:${matched.name}`, icon: 'success' });
this.speakVoice('已绑定打印台');
} else {
this.speakVoice('未绑定打印台');
}
return;
}
// 已绑定打印台 → 走快递号查询
this.currentWaybill = scanText; this.currentWaybill = scanText;
this.queryOrder(scanText); this.queryOrder(scanText);
}, },
@ -288,7 +304,6 @@ export default {
handleScanConfirm() { handleScanConfirm() {
const keyword = String(this.scanKeyword || '').trim(); const keyword = String(this.scanKeyword || '').trim();
if (!keyword) return; if (!keyword) return;
this.scanKeyword = '';
this.currentWaybill = keyword; this.currentWaybill = keyword;
this.queryOrder(keyword); this.queryOrder(keyword);
}, },
@ -318,9 +333,7 @@ export default {
const normalizedKeyword = this.normalizeKeyword(keyword); const normalizedKeyword = this.normalizeKeyword(keyword);
if (!normalizedKeyword) return; if (!normalizedKeyword) return;
this.loading = true; uni.showLoading({ title: '查询订单中...' });
this.loadingText = '查询订单中...';
this.subOrderList = [];
try { try {
// 1. 查询待处理订单列表,按快递单号匹配 // 1. 查询待处理订单列表,按快递单号匹配
@ -346,6 +359,7 @@ export default {
const errMsg = String(listResponse?.message || listResponse?.msg || '订单查询失败'); const errMsg = String(listResponse?.message || listResponse?.msg || '订单查询失败');
uni.showToast({ title: errMsg, icon: 'none' }); uni.showToast({ title: errMsg, icon: 'none' });
this.speakVoice('无记录'); this.speakVoice('无记录');
this.subOrderList = [];
return; return;
} }
@ -355,6 +369,7 @@ export default {
if (!orderList.length) { if (!orderList.length) {
uni.showToast({ title: '未查询到订单', icon: 'none' }); uni.showToast({ title: '未查询到订单', icon: 'none' });
this.speakVoice('无记录'); this.speakVoice('无记录');
this.subOrderList = [];
return; return;
} }
@ -366,6 +381,7 @@ export default {
if (!orderId) { if (!orderId) {
uni.showToast({ title: '未查询到订单', icon: 'none' }); uni.showToast({ title: '未查询到订单', icon: 'none' });
this.speakVoice('无记录'); this.speakVoice('无记录');
this.subOrderList = [];
return; return;
} }
this.orderId = orderId; this.orderId = orderId;
@ -380,6 +396,7 @@ export default {
if (detailResponse?.flag === 'failure') { if (detailResponse?.flag === 'failure') {
const errMsg = String(detailResponse?.message || detailResponse?.msg || '订单详情查询失败'); const errMsg = String(detailResponse?.message || detailResponse?.msg || '订单详情查询失败');
uni.showToast({ title: errMsg, icon: 'none' }); uni.showToast({ title: errMsg, icon: 'none' });
this.subOrderList = [];
return; return;
} }
@ -387,12 +404,13 @@ export default {
this.orderInfo = this.normalizeOrderInfo(data); this.orderInfo = this.normalizeOrderInfo(data);
this.subOrderList = this.normalizeSubOrders(data); this.subOrderList = this.normalizeSubOrders(data);
this.speakVoice('查询成功');
} catch (error) { } catch (error) {
console.error('[splitOrder] 查询订单失败:', error); console.error('[splitOrder] 查询订单失败:', error);
uni.showToast({ title: '查询订单失败', icon: 'none' }); uni.showToast({ title: '查询订单失败', icon: 'none' });
this.subOrderList = [];
} finally { } finally {
this.loading = false; uni.hideLoading();
this.scanKeyword = '';
} }
}, },
normalizeOrderInfo(data) { normalizeOrderInfo(data) {
@ -432,8 +450,7 @@ export default {
return; return;
} }
this.showSplitPopup = false; this.showSplitPopup = false;
this.loading = true; uni.showLoading({ title: '分配子单号中...' });
this.loadingText = '分配子单号中...';
try { try {
const response = await this.$http('order.pendingOrder.allocateSubOrderNumber', { const response = await this.$http('order.pendingOrder.allocateSubOrderNumber', {
@ -455,14 +472,15 @@ export default {
this.speakVoice('拆单成功'); this.speakVoice('拆单成功');
// 重新查询订单详情刷新子单列表 // 重新查询订单详情刷新子单列表
if (this.orderInfo?.id) { if (this.orderId) {
try { try {
const detailResponse = await this.$http('order.pendingOrder.detail', { const detailResponse = await this.$http('order.pendingOrder.detail', {
id: this.orderInfo.id, id: this.orderId,
ids: [this.orderInfo.id], ids: [this.orderId],
tableType: 'order' tableType: 'order'
}); });
const data = detailResponse?.data || detailResponse?.result || {}; const data = detailResponse?.data || detailResponse?.result || {};
this.orderInfo = this.normalizeOrderInfo(data);
this.subOrderList = this.normalizeSubOrders(data); this.subOrderList = this.normalizeSubOrders(data);
} catch (e) { } catch (e) {
console.warn('[splitOrder] 刷新子单列表失败:', e); console.warn('[splitOrder] 刷新子单列表失败:', e);
@ -472,7 +490,7 @@ export default {
console.error('[splitOrder] 拆单失败:', error); console.error('[splitOrder] 拆单失败:', error);
uni.showToast({ title: '拆单失败', icon: 'none' }); uni.showToast({ title: '拆单失败', icon: 'none' });
} finally { } finally {
this.loading = false; uni.hideLoading();
} }
}, },
/* ===== 单个子单打印 ===== */ /* ===== 单个子单打印 ===== */
@ -501,8 +519,7 @@ export default {
async doPrint(orderList) { async doPrint(orderList) {
if (!orderList || !orderList.length) return; if (!orderList || !orderList.length) return;
this.loading = true; uni.showLoading({ title: '获取打印数据...' });
this.loadingText = '获取打印数据...';
try { try {
const printDataResponse = await this.$http('order.print.getOrderPrintData', { const printDataResponse = await this.$http('order.print.getOrderPrintData', {
@ -516,7 +533,7 @@ export default {
return; return;
} }
this.loadingText = '发送打印...'; uni.showLoading({ title: '发送打印...' });
const requestCode = this.buildPrintRequestCode(); const requestCode = this.buildPrintRequestCode();
const sendResponse = await this.$http('print.send', { const sendResponse = await this.$http('print.send', {
type: 'express', type: 'express',
@ -536,7 +553,7 @@ export default {
const message = String(error?.message || error?.msg || error?.errMsg || '打印失败'); const message = String(error?.message || error?.msg || error?.errMsg || '打印失败');
uni.showToast({ title: message, icon: 'none' }); uni.showToast({ title: message, icon: 'none' });
} finally { } finally {
this.loading = false; uni.hideLoading();
} }
}, },
extractOrderPrintPayload(response) { extractOrderPrintPayload(response) {
@ -750,7 +767,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 175rpx; width: 210rpx;
height: 52rpx; height: 52rpx;
background: #2979ff; background: #2979ff;
border-radius: 8rpx; border-radius: 8rpx;
@ -831,6 +848,7 @@ export default {
border-radius: 12rpx; border-radius: 12rpx;
flex-shrink: 0; flex-shrink: 0;
overflow: hidden; overflow: hidden;
min-height: 300rpx;
} }
.order-card__line { .order-card__line {
@ -879,6 +897,7 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 12rpx; gap: 12rpx;
min-height: 100rpx;
} }
.order-card__sub-list { .order-card__sub-list {
@ -945,6 +964,12 @@ export default {
font-weight: 600; font-weight: 600;
} }
/* ===== 弹性填充 ===== */
.flex-filler {
flex: 1;
min-height: 0;
}
/* ===== 空态 ===== */ /* ===== 空态 ===== */
.empty-state { .empty-state {
flex: 1; flex: 1;
@ -960,27 +985,6 @@ export default {
color: #909399; color: #909399;
} }
/* ===== 加载态 ===== */
.loading-state {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.8);
gap: 16rpx;
z-index: 999;
}
.loading-state__text {
font-size: 28rpx;
color: #909399;
}
/* ===== 拆单数量弹窗 ===== */ /* ===== 拆单数量弹窗 ===== */
.split-popup { .split-popup {
width: 560rpx; width: 560rpx;
@ -1004,6 +1008,11 @@ export default {
margin-bottom: 32rpx; margin-bottom: 32rpx;
} }
.split-popup__input-wrap ::v-deep .u-input__content__field-wrapper__field {
font-size: 48rpx !important;
text-align: center !important;
}
.split-popup__actions { .split-popup__actions {
width: 100%; width: 100%;
display: flex; display: flex;