diff --git a/pages/packing/splitOrder.vue b/pages/packing/splitOrder.vue index fbc7781..195366f 100644 --- a/pages/packing/splitOrder.vue +++ b/pages/packing/splitOrder.vue @@ -79,11 +79,11 @@ - + 拆单 @@ -92,11 +92,9 @@ - - - - {{ loadingText }} - + + + @@ -109,7 +107,7 @@ type="number" placeholder="请输入拆单数量" :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' }" > @@ -177,8 +175,6 @@ export default { manualInputOpen: false, inputFocus: false, scanKeyword: '', - loading: false, - loadingText: '', currentWaybill: '', orderId: null, orderInfo: null, @@ -280,7 +276,27 @@ export default { 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.queryOrder(scanText); }, @@ -288,7 +304,6 @@ export default { handleScanConfirm() { const keyword = String(this.scanKeyword || '').trim(); if (!keyword) return; - this.scanKeyword = ''; this.currentWaybill = keyword; this.queryOrder(keyword); }, @@ -318,9 +333,7 @@ export default { const normalizedKeyword = this.normalizeKeyword(keyword); if (!normalizedKeyword) return; - this.loading = true; - this.loadingText = '查询订单中...'; - this.subOrderList = []; + uni.showLoading({ title: '查询订单中...' }); try { // 1. 查询待处理订单列表,按快递单号匹配 @@ -346,6 +359,7 @@ export default { const errMsg = String(listResponse?.message || listResponse?.msg || '订单查询失败'); uni.showToast({ title: errMsg, icon: 'none' }); this.speakVoice('无记录'); + this.subOrderList = []; return; } @@ -355,6 +369,7 @@ export default { if (!orderList.length) { uni.showToast({ title: '未查询到订单', icon: 'none' }); this.speakVoice('无记录'); + this.subOrderList = []; return; } @@ -366,6 +381,7 @@ export default { if (!orderId) { uni.showToast({ title: '未查询到订单', icon: 'none' }); this.speakVoice('无记录'); + this.subOrderList = []; return; } this.orderId = orderId; @@ -380,6 +396,7 @@ export default { if (detailResponse?.flag === 'failure') { const errMsg = String(detailResponse?.message || detailResponse?.msg || '订单详情查询失败'); uni.showToast({ title: errMsg, icon: 'none' }); + this.subOrderList = []; return; } @@ -387,12 +404,13 @@ export default { this.orderInfo = this.normalizeOrderInfo(data); this.subOrderList = this.normalizeSubOrders(data); - this.speakVoice('查询成功'); } catch (error) { console.error('[splitOrder] 查询订单失败:', error); uni.showToast({ title: '查询订单失败', icon: 'none' }); + this.subOrderList = []; } finally { - this.loading = false; + uni.hideLoading(); + this.scanKeyword = ''; } }, normalizeOrderInfo(data) { @@ -432,8 +450,7 @@ export default { return; } this.showSplitPopup = false; - this.loading = true; - this.loadingText = '分配子单号中...'; + uni.showLoading({ title: '分配子单号中...' }); try { const response = await this.$http('order.pendingOrder.allocateSubOrderNumber', { @@ -455,14 +472,15 @@ export default { this.speakVoice('拆单成功'); // 重新查询订单详情刷新子单列表 - if (this.orderInfo?.id) { + if (this.orderId) { try { const detailResponse = await this.$http('order.pendingOrder.detail', { - id: this.orderInfo.id, - ids: [this.orderInfo.id], + 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); @@ -472,7 +490,7 @@ export default { console.error('[splitOrder] 拆单失败:', error); uni.showToast({ title: '拆单失败', icon: 'none' }); } finally { - this.loading = false; + uni.hideLoading(); } }, /* ===== 单个子单打印 ===== */ @@ -501,8 +519,7 @@ export default { async doPrint(orderList) { if (!orderList || !orderList.length) return; - this.loading = true; - this.loadingText = '获取打印数据...'; + uni.showLoading({ title: '获取打印数据...' }); try { const printDataResponse = await this.$http('order.print.getOrderPrintData', { @@ -516,7 +533,7 @@ export default { return; } - this.loadingText = '发送打印...'; + uni.showLoading({ title: '发送打印...' }); const requestCode = this.buildPrintRequestCode(); const sendResponse = await this.$http('print.send', { type: 'express', @@ -536,7 +553,7 @@ export default { const message = String(error?.message || error?.msg || error?.errMsg || '打印失败'); uni.showToast({ title: message, icon: 'none' }); } finally { - this.loading = false; + uni.hideLoading(); } }, extractOrderPrintPayload(response) { @@ -750,7 +767,7 @@ export default { display: flex; align-items: center; justify-content: center; - width: 175rpx; + width: 210rpx; height: 52rpx; background: #2979ff; border-radius: 8rpx; @@ -831,6 +848,7 @@ export default { border-radius: 12rpx; flex-shrink: 0; overflow: hidden; + min-height: 300rpx; } .order-card__line { @@ -879,6 +897,7 @@ export default { display: flex; flex-direction: column; gap: 12rpx; + min-height: 100rpx; } .order-card__sub-list { @@ -945,6 +964,12 @@ export default { font-weight: 600; } +/* ===== 弹性填充 ===== */ +.flex-filler { + flex: 1; + min-height: 0; +} + /* ===== 空态 ===== */ .empty-state { flex: 1; @@ -960,27 +985,6 @@ export default { 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 { width: 560rpx; @@ -1004,6 +1008,11 @@ export default { 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 { width: 100%; display: flex;