新整面单补打页面
This commit is contained in:
parent
439255445e
commit
5a509540c3
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
|
||||
|
||||
@ -198,6 +198,13 @@
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/packing/labelReprint",
|
||||
"style" :
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
@ -318,6 +318,7 @@
|
||||
const isGrouponWaveStrategy = menuName === '团购波次策略' || (menuName.includes('团购') && menuName.includes('波次'));
|
||||
const isScatterReviewShipping = menuName === '散单复核发货' || menuName === '订单复核' || (menuName.includes('散单') && menuName.includes('复核') && menuName.includes('发货'));
|
||||
const isGrouponPickingDetail = menuName === '团购拣货详情' || (menuName.includes('团购') && menuName.includes('拣货') && menuName.includes('详情'));
|
||||
const isLabelReprint = menuName === '面单补打' || (menuName.includes('面单') && menuName.includes('补打'));
|
||||
const rawPath = item?.component || item?.path || '';
|
||||
const normalizedPath = rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : '';
|
||||
const isRandomStorage = menuName === '随机入库' || (menuName.includes('随机') && menuName.includes('入库'));
|
||||
@ -344,7 +345,9 @@
|
||||
? '/pages/work/order/gBWaveStrategy'
|
||||
: (isScatterReviewShipping
|
||||
? '/pages/work/order/order-review'
|
||||
: (isGrouponPickingDetail ? '/pages/work/order/groupon-picking-detail' : normalizedPath)))));
|
||||
: (isGrouponPickingDetail
|
||||
? '/pages/work/order/groupon-picking-detail'
|
||||
: (isLabelReprint ? '/pages/packing/labelReprint' : normalizedPath))))));
|
||||
|
||||
if (!targetPath) {
|
||||
uni.showToast({
|
||||
|
||||
@ -1187,6 +1187,7 @@
|
||||
const isScatterPickingDetail = menuName === '散单拣货详情' || (menuName.includes('散单') && menuName.includes('拣货') && menuName.includes('详情'));
|
||||
const isScatterReviewShipping = menuName === '散单复核发货' || menuName === '订单复核' || (menuName.includes('散单') && menuName.includes('复核') && menuName.includes('发货'));
|
||||
const isGrouponPickingDetail = menuName === '团购拣货详情' || (menuName.includes('团购') && menuName.includes('拣货') && menuName.includes('详情'));
|
||||
const isLabelReprint = menuName === '面单补打' || (menuName.includes('面单') && menuName.includes('补打'));
|
||||
const rawPath = item?.component || item?.path || '';
|
||||
const normalizedPath = rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : '';
|
||||
const isRandomStorage = menuName === '随机入库' || (menuName.includes('随机') && menuName.includes('入库'));
|
||||
@ -1214,8 +1215,10 @@
|
||||
: (isScatterReviewShipping
|
||||
? '/pages/work/order/order-review'
|
||||
: (isScatterPickingDetail
|
||||
? '/pages/work/order/scatter-picking-detail'
|
||||
: (isGrouponPickingDetail ? '/pages/work/order/groupon-picking-detail' : normalizedPath))))));
|
||||
? '/pages/work/order/scatter-picking-detail'
|
||||
: (isGrouponPickingDetail
|
||||
? '/pages/work/order/groupon-picking-detail'
|
||||
: (isLabelReprint ? '/pages/packing/labelReprint' : normalizedPath)))))));
|
||||
|
||||
if (!targetPath) {
|
||||
uni.showToast({
|
||||
|
||||
899
pages/packing/labelReprint.vue
Normal file
899
pages/packing/labelReprint.vue
Normal file
@ -0,0 +1,899 @@
|
||||
<template>
|
||||
<view class="reprint-page">
|
||||
<!-- 顶部栏 -->
|
||||
<view class="top-bar">
|
||||
<view class="status-bar"></view>
|
||||
<view class="header">
|
||||
<view class="header-left" @click="handleBack">
|
||||
<u-icon name="arrow-left" size="36rpx" color="#303133"></u-icon>
|
||||
<text class="header-back-text">返回</text>
|
||||
</view>
|
||||
<text class="header-title">面单补打</text>
|
||||
<view class="header-right" @click="handlePrinterSettings">
|
||||
<text class="header-printer-text" :class="{ 'header-printer-text--bound': !!printerName }">
|
||||
{{ printerName || '未绑定' }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 无权限态 -->
|
||||
<view v-if="!hasPermission" class="no-permission">
|
||||
<u-icon name="lock" size="64" color="#c0c4cc"></u-icon>
|
||||
<text class="no-permission-text">无权限</text>
|
||||
</view>
|
||||
|
||||
<!-- 有权限:中部操作区 + 底部消息区 -->
|
||||
<template v-else>
|
||||
<view class="content-box">
|
||||
<!-- 手动输入开关按钮 + 输入框(默认隐藏) -->
|
||||
<view class="broadcast-input-area">
|
||||
<view class="manual-toggle-btn"
|
||||
:class="{ 'manual-toggle-btn--active': manualInputOpen }"
|
||||
@click="toggleManualInput"
|
||||
>
|
||||
<text class="manual-toggle-btn__text">{{ manualInputOpen ? '关闭手动输入' : '手动输入' }}</text>
|
||||
</view>
|
||||
<view v-if="manualInputOpen" class="scan-section">
|
||||
<view class="scan-row">
|
||||
<input
|
||||
class="scan-input"
|
||||
v-model="scanKeyword"
|
||||
:focus="inputFocus"
|
||||
:placeholder="printerId ? '扫描/输入快递单号' : '扫描/输入打印台编码'"
|
||||
placeholder-style="color:#c0c4cc;font-size:32rpx"
|
||||
@confirm="handleScanConfirm"
|
||||
/>
|
||||
<view v-if="!isBroadcastMode" class="scan-camera-btn" @click="handleCameraScan">
|
||||
<u-icon name="scan" size="34rpx" color="#2979ff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 模式切换条 -->
|
||||
<view class="mode-switch-bar">
|
||||
<view
|
||||
class="mode-switch-item"
|
||||
:class="{ 'mode-switch-item--active': reprintMode === 'single' }"
|
||||
@click="reprintMode = 'single'"
|
||||
>
|
||||
<text class="mode-switch-item__text">单张模式</text>
|
||||
</view>
|
||||
<view
|
||||
class="mode-switch-item"
|
||||
:class="{ 'mode-switch-item--active': reprintMode === 'wave' }"
|
||||
@click="reprintMode = 'wave'"
|
||||
>
|
||||
<text class="mode-switch-item__text">整波模式</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部消息区 -->
|
||||
<view class="bottom-message-area">
|
||||
<scroll-view class="message-scroll" scroll-y :scroll-into-view="lastMsgId">
|
||||
<view
|
||||
v-for="(msg, index) in printMsgList"
|
||||
:key="index"
|
||||
:id="index === printMsgList.length - 1 ? 'lastMsg' : undefined"
|
||||
class="message-item"
|
||||
>
|
||||
<text class="message-item__text">{{ msg }}</text>
|
||||
</view>
|
||||
<view v-if="printMsgList.length === 0" class="message-empty">
|
||||
<text class="message-empty__text">等待打印操作...</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 打印台设置弹窗 -->
|
||||
<u-popup :show="showPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10090" @close="showPopup = false">
|
||||
<view class="print-popup">
|
||||
<scroll-view scroll-y class="print-popup-scroll">
|
||||
<view class="print-popup-title">打印台绑定</view>
|
||||
<view class="print-row print-row--station">
|
||||
<text class="print-label">打印台</text>
|
||||
<view class="print-station-input-wrap">
|
||||
<u-input
|
||||
v-model="printStationInputKeyword"
|
||||
placeholder="请输入或扫描打印台编号"
|
||||
:clearable="true"
|
||||
:customStyle="{ fontSize: '28rpx', height: '80rpx', lineHeight: '80rpx', padding: '0 20rpx', background: '#fafafa', borderRadius: '10rpx' }"
|
||||
@input="handlePrintStationInput"
|
||||
@focus="handlePrintStationInputFocus"
|
||||
@blur="handlePrintStationInputBlur"
|
||||
@confirm="handlePrintStationInputConfirm"
|
||||
></u-input>
|
||||
<view v-if="showPrintStationDropdown && printStationFilteredList.length > 0" class="print-station-dropdown">
|
||||
<scroll-view scroll-y class="print-station-dropdown-scroll">
|
||||
<view
|
||||
v-for="station in printStationFilteredList"
|
||||
:key="station.id"
|
||||
class="print-station-option print-station-option--row"
|
||||
:class="{ 'print-station-option--active': station.id === printerId }"
|
||||
@mousedown.stop="handlePrintStationSelect(station)"
|
||||
>
|
||||
<text class="station-option-name">{{ station.name }}</text>
|
||||
<text v-if="station.customBarcode" class="station-option-code">{{ station.customBarcode }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view v-if="showPrintStationDropdown && printStationInputKeyword && printStationFilteredList.length === 0" class="print-station-dropdown">
|
||||
<view class="print-station-option print-station-option--empty">未匹配到打印台</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import voice from '@/core/utils/voice';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
hasPermission: true,
|
||||
isBroadcastMode: false,
|
||||
manualInputOpen: false,
|
||||
inputFocus: false,
|
||||
scanKeyword: '',
|
||||
reprintMode: 'single',
|
||||
printerName: '',
|
||||
printerId: '',
|
||||
printStationList: [],
|
||||
printStationInputKeyword: '',
|
||||
showPrintStationDropdown: false,
|
||||
showPopup: false,
|
||||
printMsgList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
lastMsgId() {
|
||||
return this.printMsgList.length > 0 ? 'lastMsg' : undefined;
|
||||
},
|
||||
printStationFilteredList() {
|
||||
const list = Array.isArray(this.printStationList) ? this.printStationList : [];
|
||||
const keyword = this.normalizeKeyword(this.printStationInputKeyword);
|
||||
if (!keyword) {
|
||||
return list;
|
||||
}
|
||||
return list.filter(station => {
|
||||
const name = String(station.name || '').toLowerCase();
|
||||
const id = String(station.id || '').toLowerCase();
|
||||
const barcode = String(station.customBarcode || '').toLowerCase();
|
||||
const kw = keyword.toLowerCase();
|
||||
return name.includes(kw) || id.includes(kw) || barcode.includes(kw);
|
||||
});
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.isBroadcastMode = options?.broadcast === 'true' || options?.broadcast === true;
|
||||
this.checkPermission();
|
||||
this.loadPrinterBinding();
|
||||
this.loadPrintStations(1, false);
|
||||
this.safeDispatchBroadcast('setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
});
|
||||
this.safeDispatchBroadcast('start');
|
||||
},
|
||||
onShow() {
|
||||
this.safeDispatchBroadcast('setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
});
|
||||
this.safeDispatchBroadcast('resume');
|
||||
},
|
||||
onHide() {
|
||||
this.safeDispatchBroadcast('pause');
|
||||
},
|
||||
onUnload() {
|
||||
this.safeDispatchBroadcast('stop');
|
||||
},
|
||||
methods: {
|
||||
checkPermission() {
|
||||
// TODO: 检查面单补打权限
|
||||
this.hasPermission = true;
|
||||
},
|
||||
handleBack() {
|
||||
uni.navigateBack({ delta: 1 });
|
||||
},
|
||||
speakVoice(text) {
|
||||
voice.speak(text, { minInterval: 800 });
|
||||
},
|
||||
normalizeKeyword(value) {
|
||||
return String(value || '').replace(/\s+/g, '');
|
||||
},
|
||||
normalizeScanResult(scanResult) {
|
||||
if (!scanResult) {
|
||||
return '';
|
||||
}
|
||||
if (typeof scanResult === 'string') {
|
||||
return this.normalizeKeyword(scanResult);
|
||||
}
|
||||
if (typeof scanResult.result === 'string') {
|
||||
return this.normalizeKeyword(scanResult.result);
|
||||
}
|
||||
if (Array.isArray(scanResult.result)) {
|
||||
const firstResult = scanResult.result.find(item => item);
|
||||
if (typeof firstResult === 'string') {
|
||||
return this.normalizeKeyword(firstResult);
|
||||
}
|
||||
if (firstResult && typeof firstResult.data === 'string') {
|
||||
return this.normalizeKeyword(firstResult.data);
|
||||
}
|
||||
}
|
||||
if (typeof scanResult.data === 'string') {
|
||||
return this.normalizeKeyword(scanResult.data);
|
||||
}
|
||||
return '';
|
||||
},
|
||||
safeDispatchBroadcast(action, payload) {
|
||||
try {
|
||||
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||||
if (task && typeof task.catch === 'function') {
|
||||
task.catch(error => {
|
||||
console.warn(`[labelReprint] broadcast/${action} 调用失败:`, error);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`[labelReprint] broadcast/${action} 调用异常:`, error);
|
||||
}
|
||||
},
|
||||
/* ===== 打印台绑定 ===== */
|
||||
buildPrintRecordParams(page = 1) {
|
||||
return {
|
||||
page: Math.max(1, Number(page || 1)),
|
||||
pageSize: 20,
|
||||
where: {}
|
||||
};
|
||||
},
|
||||
extractPrintRecordList(response) {
|
||||
const list = response?.data?.list || response?.data?.data?.list;
|
||||
return Array.isArray(list) ? list : [];
|
||||
},
|
||||
normalizePrintStations(list) {
|
||||
return list
|
||||
.map(item => {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
const id = String(source.id ?? source.print_station_id ?? source.printStationId ?? '').trim();
|
||||
const name = String(source.name || source.station_name || source.print_station_name || '').trim();
|
||||
const customBarcode = String(source.custom_barcode || '').trim();
|
||||
return { id, name, customBarcode };
|
||||
})
|
||||
.filter(item => !!item.id && !!item.name);
|
||||
},
|
||||
async loadPrintStations(page = 1, autoAssign = false) {
|
||||
try {
|
||||
const response = await this.$http('print.getList', this.buildPrintRecordParams(page));
|
||||
const list = this.extractPrintRecordList(response);
|
||||
const stations = this.normalizePrintStations(list);
|
||||
this.printStationList = stations;
|
||||
if (autoAssign && stations.length && !this.printerId) {
|
||||
this.printerId = stations[0]?.id || '';
|
||||
this.printerName = stations[0]?.name || '';
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('[labelReprint] 加载打印台列表失败:', error);
|
||||
}
|
||||
},
|
||||
savePrinterBinding() {
|
||||
try {
|
||||
uni.setStorageSync('labelReprint_printer', {
|
||||
printerId: this.printerId,
|
||||
printerName: this.printerName
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('[labelReprint] 保存打印台绑定失败:', e);
|
||||
}
|
||||
},
|
||||
loadPrinterBinding() {
|
||||
try {
|
||||
const stored = uni.getStorageSync('labelReprint_printer');
|
||||
if (stored) {
|
||||
this.printerId = String(stored.printerId || '');
|
||||
this.printerName = String(stored.printerName || '');
|
||||
}
|
||||
} catch (e) {
|
||||
// 忽略
|
||||
}
|
||||
},
|
||||
matchPrintStation(text) {
|
||||
if (!text || !Array.isArray(this.printStationList) || !this.printStationList.length) {
|
||||
uni.showToast({ title: '暂无可用打印台', icon: 'none' });
|
||||
this.speakVoice('暂无打印台');
|
||||
return;
|
||||
}
|
||||
const kw = text.toLowerCase();
|
||||
// 优先精确匹配 customBarcode
|
||||
const matched = this.printStationList.find(station =>
|
||||
String(station.customBarcode || '').toLowerCase() === kw
|
||||
|| String(station.name).toLowerCase() === kw
|
||||
|| String(station.id).toLowerCase() === kw
|
||||
);
|
||||
if (matched) {
|
||||
this.printerId = String(matched.id);
|
||||
this.printerName = String(matched.name || '');
|
||||
this.savePrinterBinding();
|
||||
uni.showToast({ title: `已绑定打印台:${matched.name}`, icon: 'success' });
|
||||
this.speakVoice('已绑定打印台');
|
||||
this.addPrintMsg(`打印台绑定成功:${matched.name}(${matched.customBarcode || matched.id})`);
|
||||
} else {
|
||||
uni.showToast({ title: '未匹配到打印台', icon: 'none' });
|
||||
this.speakVoice('未绑定打印台');
|
||||
}
|
||||
},
|
||||
handlePrinterSettings() {
|
||||
this.printStationInputKeyword = '';
|
||||
this.showPopup = true;
|
||||
if (!this.printStationList.length) {
|
||||
this.loadPrintStations(1, false);
|
||||
}
|
||||
},
|
||||
handlePrintStationInput(value) {
|
||||
const keyword = this.normalizeKeyword(value);
|
||||
this.showPrintStationDropdown = false;
|
||||
if (!keyword) return;
|
||||
const exactMatch = this.printStationFilteredList.find(station => {
|
||||
const kw = keyword.toLowerCase();
|
||||
return String(station.name).toLowerCase() === kw
|
||||
|| String(station.id).toLowerCase() === kw
|
||||
|| String(station.customBarcode || '').toLowerCase() === kw;
|
||||
});
|
||||
if (exactMatch) {
|
||||
this.handlePrintStationSelect(exactMatch);
|
||||
}
|
||||
},
|
||||
handlePrintStationSelect(station) {
|
||||
this.printerId = String(station?.id || '');
|
||||
this.printerName = String(station?.name || '');
|
||||
this.savePrinterBinding();
|
||||
this.showPrintStationDropdown = false;
|
||||
this.showPopup = false;
|
||||
uni.showToast({ title: `已绑定打印台:${station.name}`, icon: 'success' });
|
||||
this.speakVoice('已绑定打印台');
|
||||
this.addPrintMsg(`打印台绑定成功:${station.name}`);
|
||||
},
|
||||
handlePrintStationInputConfirm() {
|
||||
const keyword = this.normalizeKeyword(this.printStationInputKeyword);
|
||||
if (!keyword) return;
|
||||
if (this.printStationFilteredList.length > 0) {
|
||||
this.handlePrintStationSelect(this.printStationFilteredList[0]);
|
||||
}
|
||||
},
|
||||
handlePrintStationInputFocus() {
|
||||
this.showPrintStationDropdown = false;
|
||||
},
|
||||
handlePrintStationInputBlur() {
|
||||
setTimeout(() => {
|
||||
this.showPrintStationDropdown = false;
|
||||
}, 200);
|
||||
},
|
||||
/* ===== 广播扫描结果处理 ===== */
|
||||
handleBroadcastResult(result) {
|
||||
const scanText = this.normalizeScanResult(result);
|
||||
console.log('[labelReprint] handleBroadcastResult 扫描结果:', scanText);
|
||||
if (!scanText) return;
|
||||
|
||||
// 打印设置弹窗打开时,扫描填入打印台输入框
|
||||
if (this.showPopup) {
|
||||
this.printStationInputKeyword = scanText;
|
||||
this.handlePrintStationInput(scanText);
|
||||
return;
|
||||
}
|
||||
|
||||
// 未绑定打印台 → 走匹配打印台
|
||||
if (!this.printerId) {
|
||||
this.matchPrintStation(scanText);
|
||||
return;
|
||||
}
|
||||
|
||||
// 已绑定打印台 → 走补打请求
|
||||
this.doReprint(scanText);
|
||||
},
|
||||
/* ===== 扫码/输入 ===== */
|
||||
handleScanConfirm() {
|
||||
const keyword = String(this.scanKeyword || '').trim();
|
||||
if (!keyword) return;
|
||||
this.scanKeyword = '';
|
||||
if (!this.printerId) {
|
||||
this.matchPrintStation(keyword);
|
||||
} else {
|
||||
this.doReprint(keyword);
|
||||
}
|
||||
},
|
||||
handleCameraScan() {
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
|
||||
success: (res) => {
|
||||
const code = String(res?.result || '').trim();
|
||||
if (!code) return;
|
||||
if (!this.printerId) {
|
||||
this.matchPrintStation(code);
|
||||
} else {
|
||||
this.doReprint(code);
|
||||
}
|
||||
},
|
||||
fail: () => {}
|
||||
});
|
||||
},
|
||||
toggleManualInput() {
|
||||
this.manualInputOpen = !this.manualInputOpen;
|
||||
if (this.manualInputOpen) {
|
||||
this.$nextTick(() => {
|
||||
this.inputFocus = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
/* ===== 补打 ===== */
|
||||
async doReprint(keyword) {
|
||||
if (!this.printerId) {
|
||||
uni.showToast({ title: '未绑定打印台,请先扫描打印台编码', icon: 'none' });
|
||||
this.speakVoice('未绑定打印台');
|
||||
return;
|
||||
}
|
||||
const normalizedKeyword = this.normalizeKeyword(keyword);
|
||||
if (!normalizedKeyword) return;
|
||||
|
||||
this.addPrintMsg(`补打请求: ${normalizedKeyword}`);
|
||||
this.addPrintMsg(`模式: ${this.reprintMode === 'single' ? '单张' : '整波'}`);
|
||||
this.addPrintMsg(`打印台: ${this.printerName}`);
|
||||
|
||||
uni.showLoading({ title: '查询订单中...' });
|
||||
try {
|
||||
// 1. 查询订单
|
||||
const scanResponse = await this.$http('order.recheckOrder.scanOrder', this.buildScanOrderParams(normalizedKeyword));
|
||||
if (scanResponse?.flag === 'failure') {
|
||||
const errMsg = String(scanResponse?.message || scanResponse?.msg || '订单查询失败');
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: errMsg, icon: 'none' });
|
||||
this.addPrintMsg(`查询失败: ${errMsg}`);
|
||||
this.speakVoice('无记录');
|
||||
return;
|
||||
}
|
||||
const payload = this.extractScanOrderPayload(scanResponse);
|
||||
const orderIds = this.extractOrderIdsFromResult(payload);
|
||||
if (!orderIds.length) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '未查询到可补打的订单', icon: 'none' });
|
||||
this.addPrintMsg('未查询到可补打的订单');
|
||||
this.speakVoice('无记录');
|
||||
return;
|
||||
}
|
||||
this.addPrintMsg(`查询到 ${orderIds.length} 条订单`);
|
||||
|
||||
// 2. 获取打印数据
|
||||
const printDataResponse = await this.$http('order.print.getOrderPrintData', { order_ids: orderIds });
|
||||
const printPayload = this.extractOrderPrintPayload(printDataResponse);
|
||||
const waveGroups = this.normalizeOrderPrintGroups(printPayload);
|
||||
if (!waveGroups.length) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '未获取到可打印数据', icon: 'none' });
|
||||
this.addPrintMsg('未获取到可打印数据');
|
||||
return;
|
||||
}
|
||||
this.addPrintMsg(`获取打印数据成功,${waveGroups.length} 个波次组`);
|
||||
|
||||
// 3. 发送打印
|
||||
const requestCode = this.buildPrintRequestCode();
|
||||
const sendResponse = await this.$http('print.send', {
|
||||
type: 'express',
|
||||
printStationId: this.printerId,
|
||||
requestCode,
|
||||
data: { waveGroups }
|
||||
});
|
||||
const success = sendResponse?.flag !== 'failure' && sendResponse?.code !== '500' && sendResponse?.code !== 500;
|
||||
if (!success) {
|
||||
throw new Error(sendResponse?.message || sendResponse?.msg || '打印发送失败');
|
||||
}
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: `已发起补打 ${orderIds.length} 条`, icon: 'success' });
|
||||
this.addPrintMsg(`补打成功,已发送 ${orderIds.length} 条`);
|
||||
this.speakVoice('补打成功');
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
const message = String(error?.message || error?.msg || error?.errMsg || '补打失败');
|
||||
uni.showToast({ title: message, icon: 'none' });
|
||||
this.addPrintMsg(`补打失败: ${message}`);
|
||||
}
|
||||
},
|
||||
/* ===== 补打辅助方法 ===== */
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// detail 模式
|
||||
const orderId = Number(payload?.order_id ?? payload?.orderId ?? payload?.order?.id ?? 0);
|
||||
if (orderId > 0) ids.push(orderId);
|
||||
}
|
||||
|
||||
return ids;
|
||||
},
|
||||
extractOrderPrintPayload(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 {};
|
||||
},
|
||||
normalizeOrderPrintGroups(payload) {
|
||||
const groups = Array.isArray(payload?.waveGroups) ? payload.waveGroups : [];
|
||||
if (groups.length) return groups;
|
||||
if (payload && typeof payload === 'object') return [payload];
|
||||
return [];
|
||||
},
|
||||
buildPrintRequestCode() {
|
||||
const timePart = Date.now().toString(36);
|
||||
const randomPart = Math.random().toString(36).slice(2, 10);
|
||||
return `PRINT_${timePart}_${randomPart}`;
|
||||
},
|
||||
addPrintMsg(msg) {
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
this.printMsgList.push(`[${timestamp}] ${msg}`);
|
||||
if (this.printMsgList.length > 200) {
|
||||
this.printMsgList = this.printMsgList.slice(-100);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.reprint-page {
|
||||
height: 100vh;
|
||||
background: #f8f9fa;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ===== 顶部栏 ===== */
|
||||
.top-bar {
|
||||
background: #ffffff;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
height: var(--status-bar-height, 44rpx);
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 24rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
min-width: 100rpx;
|
||||
}
|
||||
|
||||
.header-back-text {
|
||||
font-size: 30rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
text-align: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
min-width: 100rpx;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.header-printer-text {
|
||||
font-size: 28rpx;
|
||||
color: #909399;
|
||||
padding: 4rpx 12rpx;
|
||||
border: 1rpx solid #dcdfe6;
|
||||
border-radius: 6rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.header-printer-text--bound {
|
||||
color: #07c160;
|
||||
border-color: #07c160;
|
||||
}
|
||||
|
||||
/* ===== 无权限 ===== */
|
||||
.no-permission {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.no-permission-text {
|
||||
font-size: 36rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* ===== 手动输入开关按钮(内联) ===== */
|
||||
.manual-toggle-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 160rpx;
|
||||
height: 64rpx;
|
||||
margin: 0 auto 20rpx;
|
||||
background: #2979ff;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.manual-toggle-btn--active {
|
||||
background: #fa8c16;
|
||||
}
|
||||
|
||||
.manual-toggle-btn__text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ===== 中部操作区 ===== */
|
||||
.content-box {
|
||||
padding: 20rpx 24rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 扫码输入区 */
|
||||
.scan-section {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.scan-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.scan-input {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
background: #f5f5f5;
|
||||
border: 2rpx solid #dcdfe6;
|
||||
border-radius: 12rpx;
|
||||
padding: 0 20rpx;
|
||||
font-size: 32rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.scan-camera-btn {
|
||||
flex-shrink: 0;
|
||||
width: 72rpx;
|
||||
height: 72rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f0f7ff;
|
||||
border: 2rpx solid #2979ff;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.scan-camera-btn:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* 模式切换条 */
|
||||
.mode-switch-bar {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
border: 2rpx solid #e74c3c;
|
||||
}
|
||||
|
||||
.mode-switch-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 20rpx 0;
|
||||
background: #ffffff;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.mode-switch-item--active {
|
||||
background: #e74c3c;
|
||||
}
|
||||
|
||||
.mode-switch-item__text {
|
||||
font-size: 32rpx;
|
||||
color: #303133;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.mode-switch-item--active .mode-switch-item__text {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* ===== 底部消息区 ===== */
|
||||
.bottom-message-area {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin: 0 24rpx 24rpx;
|
||||
background: #1a1a1a;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.message-scroll {
|
||||
height: 100%;
|
||||
padding: 16rpx 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
padding: 4rpx 0;
|
||||
}
|
||||
|
||||
.message-item__text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
font-family: 'Courier New', monospace;
|
||||
line-height: 1.6;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.message-empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.message-empty__text {
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
/* ===== 打印台设置弹窗 ===== */
|
||||
.print-popup {
|
||||
height: 70vh;
|
||||
background: #ffffff;
|
||||
border-top-left-radius: 20rpx;
|
||||
border-top-right-radius: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.print-popup-scroll {
|
||||
flex: 1;
|
||||
padding: 48rpx 32rpx calc(40rpx + env(safe-area-inset-bottom));
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.print-popup-title {
|
||||
font-size: 42rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 36rpx;
|
||||
}
|
||||
|
||||
.print-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 28rpx 0;
|
||||
border-bottom: 1rpx solid #f2f3f5;
|
||||
}
|
||||
|
||||
.print-row--station {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.print-row--station .print-label {
|
||||
padding-top: 10rpx;
|
||||
}
|
||||
|
||||
.print-label {
|
||||
min-width: 130rpx;
|
||||
width: 130rpx;
|
||||
font-size: 36rpx;
|
||||
line-height: 40rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.print-station-input-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.print-station-dropdown {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 100%;
|
||||
max-height: 600rpx;
|
||||
background: #ffffff;
|
||||
border: 1rpx solid #ebeef5;
|
||||
border-radius: 10rpx;
|
||||
z-index: 10091;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.print-station-dropdown-scroll {
|
||||
flex: 1;
|
||||
max-height: 600rpx;
|
||||
}
|
||||
|
||||
.print-station-option {
|
||||
padding: 16rpx 20rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.print-station-option + .print-station-option {
|
||||
border-top: 1rpx solid #f2f3f5;
|
||||
}
|
||||
|
||||
.print-station-option--active {
|
||||
color: #2979ff;
|
||||
}
|
||||
|
||||
.print-station-option--row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.station-option-name {
|
||||
font-size: 36rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.station-option-code {
|
||||
font-size: 32rpx;
|
||||
color: #909399;
|
||||
margin-left: 12rpx;
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user