WMS_PDA/pages/work/order/scatter-picking-detail.vue
2026-06-05 17:59:18 +08:00

1250 lines
34 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="scatter-picking-detail-page">
<view class="normar_container">
<page-nav :title="title">
<template #right>
<view class="nav-right-action" :class="{ 'nav-right-action--active': onlyMine }" @click="toggleOnlyMine">{{ onlyMine ? '查看全部' : '只看我的' }}</view>
</template>
</page-nav>
<view class="search-filter">
<view class="search-box">
<view class="search-box-inner">
<u-search
v-model="keyword"
placeholder="请输入快递单号/车号"
:bg-color="'#f5f5f5'"
shape="round"
:show-action="false"
@search="handleSearch"
@clear="clearSearch"
></u-search>
<view class="search-actions">
<view class="scan-btn" @click="handleCameraScan">
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
</view>
<view class="search-divider"></view>
<view class="search-btn" @click="handleSearch">
<text class="search-btn__text">搜索</text>
</view>
</view>
</view>
</view>
</view>
<scroll-view class="detail-scroll" scroll-y>
<view v-if="displayOrderList.length === 0" class="empty-state">
<u-icon name="list" size="86" color="#c0c4cc"></u-icon>
<text class="empty-text">暂无未复核订单</text>
</view>
<view v-else class="record-list">
<view v-for="item in displayOrderList" :key="item.id" class="record-item" @click="goPickGoodsDetail(item)">
<view class="record-main">
<view class="record-left">
<view class="record-line"><text class="record-label">波次号:</text><text class="record-value">{{ item.waveNo || '--' }}</text></view>
<view class="record-line"><text class="record-label">总订单数:</text><text class="record-value">{{ item.totalOrderCount }}</text></view>
</view>
<view class="record-right">
<text class="record-count">未复核 {{ item.unreviewedCount }}</text>
<text class="record-status">{{ getStatusText(item.status) }}</text>
</view>
</view>
<view class="record-footer" @click.stop>
<u-button
type="primary"
size="mini"
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff', fontSize: '26rpx', height: '64rpx', lineHeight: '64rpx', padding: '0 20rpx' }"
@click.native.stop="handlePrintAllUnreviewed(item)"
>
打印所有未复核订单
</u-button>
</view>
</view>
</view>
<view class="safe-area-bottom"></view>
</scroll-view>
<view class="pagination-wrap">
<pagination
:pageNum.sync="currentPage"
:pageSize="pageSize"
:total="paginationTotal"
:showTotal="true"
:prevText="'上一页'"
:nextText="'下一页'"
:showFirstLast="true"
:firstText="'首页'"
:lastText="'末页'"
@change="handlePageChange"
/>
</view>
</view>
<u-popup v-if="showPrintPopup" :show="showPrintPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10090" @close="showPrintPopup = false">
<view class="print-popup">
<view class="print-popup-title">打印设置</view>
<view class="print-row print-row--station">
<text class="print-label">打印台</text>
<view class="print-picker" @click="togglePrintStationDropdown">
<text class="print-picker-value">{{ printStationName || '--' }}</text>
<u-icon :name="showPrintStationDropdown ? 'arrow-up' : 'arrow-down'" size="24" color="#909399"></u-icon>
</view>
<view v-if="showPrintStationDropdown" class="print-station-dropdown">
<view
v-for="station in printStationList"
:key="station.id"
class="print-station-option"
:class="{ 'print-station-option--active': station.id === printStationId }"
@click.stop="handlePrintStationSelect(station)"
>
{{ station.name }}
</view>
</view>
</view>
<view class="print-row print-row--action">
<text class="print-label">打印</text>
<u-button
type="primary"
size="mini"
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff', fontSize: '26rpx', height: '64rpx', lineHeight: '64rpx', padding: '0 20rpx' }"
@click="handleConfirmPrint"
>
打印
</u-button>
</view>
<view class="print-row print-row--message">
<text class="print-label">打印消息</text>
<text class="print-message">{{ printMessage || '暂无打印消息' }}</text>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
title: '拣货详情(未复核)',
grabCount: 0,
keyword: '',
onlyMine: false,
currentUserId: '',
pageSize: 20,
currentPage: 1,
paginationTotal: 0,
showPrintPopup: false,
showPrintStationDropdown: false,
printStationName: '--',
printStationId: '',
printStationList: [],
printMessage: '',
pendingPrintCount: 0,
printRequestCode: '',
printWaveGroups: [],
printWavePlatformPrintData: null,
printTargetList: [],
orderList: []
};
},
computed: {
displayOrderList() {
return Array.isArray(this.orderList) ? this.orderList : [];
}
},
onLoad(options) {
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('start');
this.currentUserId = String(this.$store?.getters?.user?.id || this.$store?.getters?.user?.user_id || '');
const hasGrabCountParam = options && Object.prototype.hasOwnProperty.call(options, 'grabCount');
const parsedGrabCount = Number(options?.grabCount || 0);
this.grabCount = hasGrabCountParam
? Math.max(0, parsedGrabCount)
: 5;
this.loadBatchWaveNoList(1);
},
onShow() {
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('resume');
},
onHide() {
this.safeDispatchBroadcast('pause');
},
onUnload() {
this.safeDispatchBroadcast('stop');
},
methods: {
buildBatchListParams(page = this.currentPage) {
const where = {
wave_type: 2
};
if (this.onlyMine && this.currentUserId) {
where.picker_id = this.currentUserId;
}
return {
pagination: {
page: Math.max(1, Number(page || 1)),
pageSize: Math.max(1, Number(this.pageSize || 20))
},
only_todo: 1,
where
};
},
extractPagination(payload, response) {
return payload?.pagination || payload?.page || response?.data?.pagination || response?.pagination || null;
},
extractBatchListPayload(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' && !Array.isArray(current)) {
return current;
}
}
return {};
},
extractBatchList(payload, response) {
const candidates = [
payload?.list,
payload?.rows,
payload?.items,
payload?.data?.list,
response?.data?.list,
response?.data?.data?.list,
response?.list
];
for (let i = 0; i < candidates.length; i += 1) {
if (Array.isArray(candidates[i])) {
return candidates[i];
}
}
return [];
},
normalizeBatchWaveList(list) {
if (!Array.isArray(list)) {
return [];
}
return list
.map((item, index) => {
const source = item && typeof item === 'object' ? item : {};
const waveNo = String(source.wave_no || source.waveNo || '').trim();
const waveId = source.wave_id ?? source.waveId ?? source.id ?? '';
const rowId = source.id ?? waveId ?? waveNo ?? `batch-${this.currentPage}-${index + 1}`;
const pickerName = String(source.picker_name || source.pickerName || source.user_name || source.userName || '--').trim() || '--';
const cartNo = String(source.cart_code || source.cartCode || source.cart_no || source.cartNo || '--').trim() || '--';
const totalOrderCount = Number(source.total_order_count ?? source.totalOrderCount ?? source.order_count ?? source.orderCount ?? source.total_count ?? source.totalCount ?? source.order_num ?? source.orderNum ?? 0);
const unreviewedCount = Number(source.unreviewed_count ?? source.unreviewedCount ?? source.pending_count ?? source.pendingCount ?? 0);
const assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim();
return {
id: String(rowId || `batch-${this.currentPage}-${index + 1}`),
waveId: typeof waveId === 'number' ? waveId : String(waveId || '').trim(),
waveNo,
pickerName,
cartNo,
totalOrderCount: Number.isFinite(totalOrderCount) ? totalOrderCount : 0,
unreviewedCount: Number.isFinite(unreviewedCount) ? unreviewedCount : 0,
status: String(source.status || 'pending'),
waybillCode: String(source.waybill_no || source.waybillCode || source.waybill_code || ''),
isMine: !!this.currentUserId && !!assigneeId && assigneeId === this.currentUserId
};
})
.filter(item => !!item.waveNo);
},
resolvePaginationTotal(payload, response, pagination, list) {
const candidates = [
pagination?.total,
payload?.total,
payload?.count,
payload?.totalCount,
response?.data?.total,
response?.total,
Array.isArray(list) ? list.length : 0
];
for (let i = 0; i < candidates.length; i += 1) {
const value = Number(candidates[i]);
if (Number.isFinite(value) && value >= 0) {
return value;
}
}
return 0;
},
async loadBatchWaveNoList(page = this.currentPage) {
const targetPage = Math.max(1, Number(page || 1));
try {
const response = await this.$http('order.wave.batchList', this.buildBatchListParams(targetPage));
const payload = this.extractBatchListPayload(response);
const list = this.extractBatchList(payload, response);
const pagination = this.extractPagination(payload, response);
const batchWaveList = this.normalizeBatchWaveList(list);
this.orderList = batchWaveList;
this.paginationTotal = this.resolvePaginationTotal(payload, response, pagination, list);
this.currentPage = Number((pagination?.page ?? targetPage) || targetPage);
this.pageSize = Number((pagination?.pageSize ?? this.pageSize) || this.pageSize);
} catch (error) {
this.orderList = [];
this.paginationTotal = 0;
uni.showToast({
title: '波次列表加载失败',
icon: 'none'
});
}
},
resolveWarehouseId() {
const user = this.$store?.getters?.user || {};
const userInfo = this.$store?.getters?.userInfo || {};
const candidates = [
user?.warehouse_id,
user?.warehouseId,
user?.store_id,
user?.storeId,
userInfo?.warehouse_id,
userInfo?.warehouseId,
userInfo?.store_id,
userInfo?.storeId,
uni.getStorageSync('warehouse_id'),
uni.getStorageSync('warehouseId'),
uni.getStorageSync('store_id'),
uni.getStorageSync('storeId')
];
for (let i = 0; i < candidates.length; i += 1) {
const value = Number(candidates[i]);
if (Number.isFinite(value) && value > 0) {
return value;
}
}
return 0;
},
normalizeWaveIds(list) {
const sourceList = Array.isArray(list) ? list : [];
const normalized = sourceList
.map(item => item?.waveId ?? '')
.map(value => (typeof value === 'number' ? value : String(value || '').trim()))
.filter(value => value !== '' && value !== '--');
return Array.from(new Set(normalized));
},
buildWavePlatformPrintParams() {
const warehouseId = this.resolveWarehouseId();
const waveIds = this.normalizeWaveIds(this.printTargetList);
return {
warehouse_id: warehouseId,
wave_ids: waveIds
};
},
extractWavePlatformPrintPayload(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 {};
},
normalizeWaveGroups(payload) {
const groups = Array.isArray(payload?.waveGroups) ? payload.waveGroups : [];
return groups
.map(group => (group && typeof group === 'object' ? group : null))
.filter(group => !!group);
},
buildPrintRequestCode() {
const timePart = Date.now().toString(36);
const randomPart = Math.random().toString(36).slice(2, 10);
return `PRINT_${timePart}_${randomPart}`;
},
async requestWavePlatformPrintData() {
const params = this.buildWavePlatformPrintParams();
if (!params.warehouse_id) {
throw new Error('缺少仓库ID');
}
if (!params.wave_ids.length) {
throw new Error('缺少波次ID');
}
const response = await this.$http('order.print.getWavePlatformPrintData', params);
const payload = this.extractWavePlatformPrintPayload(response);
const waveGroups = this.normalizeWaveGroups(payload);
if (!waveGroups.length) {
throw new Error('未获取到可打印的waveGroups');
}
this.printWavePlatformPrintData = payload;
this.printWaveGroups = waveGroups;
this.printRequestCode = this.buildPrintRequestCode();
return payload;
},
buildPrintRecordWhere() {
return {};
},
buildPrintRecordParams() {
return {
page: 1,
pageSize: 20,
where: this.buildPrintRecordWhere()
};
},
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();
return {
id,
name
};
})
.filter(item => !!item.id && !!item.name);
},
async loadPrintStations() {
const response = await this.$http('print.getList', this.buildPrintRecordParams());
const list = this.extractPrintRecordList(response);
const stations = this.normalizePrintStations(list);
this.printStationList = stations;
this.printStationId = stations[0]?.id || '';
this.printStationName = stations[0]?.name || '--';
},
togglePrintStationDropdown() {
if (!this.printStationList.length) {
uni.showToast({
title: '暂无可用打印台',
icon: 'none'
});
return;
}
this.showPrintStationDropdown = !this.showPrintStationDropdown;
},
handlePrintStationSelect(station) {
this.printStationId = String(station?.id || '');
this.printStationName = String(station?.name || '--');
this.showPrintStationDropdown = false;
},
safeDispatchBroadcast(action, payload) {
try {
const task = this.$store.dispatch(`broadcast/${action}`, payload);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn(`[ScatterPickingDetail] broadcast/${action} 调用失败:`, error);
});
}
} catch (error) {
console.warn(`[ScatterPickingDetail] broadcast/${action} 调用异常:`, error);
}
},
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 '';
},
handleBroadcastResult(result) {
const scanText = this.normalizeScanResult(result);
if (!scanText) {
return;
}
this.keyword = scanText;
this.handleSearch();
},
handleSearch() {
this.keyword = this.normalizeKeyword(this.keyword);
this.requestScanOrder(this.keyword);
},
handleCameraScan() {
uni.scanCode({
onlyFromCamera: true,
scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
success: (res) => {
const scanResult = this.normalizeScanResult(res);
if (!scanResult) {
uni.showToast({
title: '未识别到有效条码',
icon: 'none'
});
return;
}
this.keyword = scanResult;
this.handleSearch();
},
fail: (error) => {
const errMsg = String(error?.errMsg || '').toLowerCase();
if (errMsg.includes('cancel')) {
return;
}
uni.showToast({
title: '扫码失败,请重试',
icon: 'none'
});
}
});
},
clearSearch() {
this.keyword = '';
},
buildScanOrderParams(keyword) {
const value = this.normalizeKeyword(keyword);
return {
keyword: value
};
},
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 {};
},
normalizeScanOrderResult(payload) {
const order = payload?.order && typeof payload.order === 'object' ? payload.order : {};
const items = Array.isArray(payload?.items) ? payload.items : [];
const firstItem = items[0] && typeof items[0] === 'object' ? items[0] : {};
const orderId = Number(
payload?.order_id
|| payload?.orderId
|| order?.order_id
|| order?.orderId
|| order?.id
|| firstItem?.order_id
|| firstItem?.orderId
|| 0
);
const recheckStatus = String(
payload?.recheck_status
|| payload?.recheckStatus
|| order?.recheck_status
|| order?.recheckStatus
|| ''
).trim().toLowerCase();
const waybillNo = String(
payload?.waybill_no
|| order?.waybill_no
|| order?.waybillCode
|| order?.waybill_code
|| ''
).trim();
const matchType = String(payload?.match_type || '').trim();
const cartMatchView = payload?.cart_match_view && typeof payload.cart_match_view === 'object'
? payload.cart_match_view
: null;
return {
matchType,
cartMatchView,
orderId,
recheckStatus,
waybillNo,
order,
items,
expresses: Array.isArray(payload?.expresses) ? payload.expresses : [],
logs: Array.isArray(payload?.logs) ? payload.logs : []
};
},
handleScanOrderSuccess(result) {
const order = result?.order || {};
const orderId = Number(result?.orderId || 0);
if (!orderId) {
uni.showToast({
title: '未查询到订单',
icon: 'none'
});
return;
}
if (String(result?.recheckStatus || '').toLowerCase() === 'fin') {
uni.showModal({
title: '提示',
content: '该订单已复核完成,禁止再次进入',
showCancel: false,
success: () => {
uni.navigateBack({
delta: 1
});
}
});
return;
}
if (result?.matchType === 'cart') {
uni.showToast({
title: '车号命中,已定位订单',
icon: 'none'
});
}
const cacheKey = `scatter_scan_order_${Date.now()}_${orderId}`;
try {
uni.setStorageSync(cacheKey, {
items: Array.isArray(result?.items) ? result.items : [],
expresses: Array.isArray(result?.expresses) ? result.expresses : [],
logs: Array.isArray(result?.logs) ? result.logs : []
});
} catch (error) {
console.warn('[ScatterPickingDetail] 缓存 scanOrder 结果失败:', error);
}
const params = [
`recordId=${encodeURIComponent(String(orderId))}`,
`orderId=${encodeURIComponent(String(orderId))}`,
`waveNo=${encodeURIComponent(String(order?.wave_no || order?.waveNo || '--'))}`,
`pickerName=${encodeURIComponent(String(order?.picker_name || order?.pickerName || '--'))}`,
`cartNo=${encodeURIComponent(String(order?.cart_code || order?.cartCode || order?.cart_no || order?.cartNo || '--'))}`,
`status=${encodeURIComponent(String(order?.status || 'pending'))}`,
`recheckStatus=${encodeURIComponent(String(result?.recheckStatus || order?.recheck_status || ''))}`,
`unreviewedCount=${encodeURIComponent(String(order?.unreviewed_count || order?.unreviewedCount || 0))}`,
`waybillNo=${encodeURIComponent(String(result?.waybillNo || '--'))}`,
`matchType=${encodeURIComponent(String(result?.matchType || ''))}`,
`cacheKey=${encodeURIComponent(cacheKey)}`
];
this.$tools.routerTo(`/pages/work/order/scatter-pick-goods-detail?${params.join('&')}`);
},
async requestScanOrder(keyword) {
const normalizedKeyword = this.normalizeKeyword(keyword);
if (!normalizedKeyword) {
uni.showToast({
title: '请输入快递单号或车号',
icon: 'none'
});
return;
}
uni.showLoading({
title: '查询订单中...'
});
try {
const response = await this.$http('order.recheckOrder.scanOrder', this.buildScanOrderParams(normalizedKeyword));
const payload = this.extractScanOrderPayload(response);
const result = this.normalizeScanOrderResult(payload);
this.handleScanOrderSuccess(result);
} catch (error) {
const message = String(error?.message || error?.msg || error?.errMsg || '').trim();
uni.showToast({
title: message || '订单查询失败',
icon: 'none'
});
} finally {
uni.hideLoading();
}
},
toggleOnlyMine() {
this.onlyMine = !this.onlyMine;
this.currentPage = 1;
this.loadBatchWaveNoList(1);
},
getStatusText(status) {
const map = {
pending: '待拣货',
picking: '拣货中',
done: '已完成'
};
return map[status] || '待拣货';
},
extractPickQueryPayload(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' && !Array.isArray(current)) {
return current;
}
}
return {};
},
extractTaskIdFromPickQueryPayload(payload) {
const taskId = Number(payload?.task_id ?? payload?.taskId ?? 0);
return Number.isFinite(taskId) && taskId > 0 ? taskId : 0;
},
normalizePickQueryStatus(payload) {
return String(payload?.status || '').trim().toLowerCase();
},
normalizePickQueryTip(payload, fallback = '') {
return String(payload?.tip || payload?.message || payload?.msg || fallback).trim();
},
isPickQueryConflict(payload, status) {
const conflictKeywords = ['conflict', '归属', '他人', '占用', '非当前用户', '非本人'];
const text = `${String(status || '')} ${this.normalizePickQueryTip(payload, '')}`.toLowerCase();
return conflictKeywords.some(keyword => text.includes(keyword));
},
routeToPickingPage(taskId) {
this.$tools.routerTo(`/pages/work/order/picking?taskId=${encodeURIComponent(String(taskId))}`);
},
goPickGoodsDetail(item) {
if (!item) {
return;
}
const waveKeyword = String(item.waveNo || '').trim();
const waybillKeyword = String(item.waybillCode || '').trim();
const keyword = waybillKeyword || waveKeyword;
if (!keyword) {
uni.showToast({
title: '缺少运单号或波次号',
icon: 'none'
});
return;
}
uni.showLoading({
title: '查询任务中...'
});
this.$http('pick.query', { keyword }, '', false)
.then(response => {
const payload = this.extractPickQueryPayload(response);
const status = this.normalizePickQueryStatus(payload);
const tip = this.normalizePickQueryTip(payload, '任务查询成功');
const taskId = this.extractTaskIdFromPickQueryPayload(payload);
if (!taskId) {
uni.showToast({
title: tip || '未获取到拣货任务',
icon: 'none'
});
return;
}
if (this.isPickQueryConflict(payload, status)) {
uni.showModal({
title: '任务归属冲突',
content: tip || '活动任务归属他人,请稍后重试',
showCancel: false
});
return;
}
if (status && status !== 'existing' && status !== 'created') {
uni.showToast({
title: tip || '任务状态异常',
icon: 'none'
});
return;
}
if (tip) {
uni.showToast({
title: tip,
icon: 'none'
});
}
this.routeToPickingPage(taskId);
})
.catch(error => {
const tip = String(error?.data?.tip || error?.data?.message || error?.message || error?.msg || '任务查询失败').trim();
if (this.isPickQueryConflict({ tip }, '')) {
uni.showModal({
title: '任务归属冲突',
content: tip || '活动任务归属他人,请稍后重试',
showCancel: false
});
return;
}
uni.showToast({
title: tip || '任务查询失败',
icon: 'none'
});
})
.finally(() => {
uni.hideLoading();
});
},
async handlePrintAllUnreviewed(item) {
const target = item && typeof item === 'object' ? item : null;
if (!target) {
uni.showToast({
title: '暂无未复核订单可打印',
icon: 'none'
});
return;
}
this.printTargetList = [target];
try {
await this.requestWavePlatformPrintData();
} catch (error) {
const message = String(error?.message || error?.msg || error?.errMsg || '打印数据获取失败');
this.printMessage = message;
uni.showToast({
title: message,
icon: 'none'
});
return;
}
try {
await this.loadPrintStations();
} catch (error) {
this.printStationList = [];
this.printStationName = '--';
uni.showToast({
title: '打印台加载失败',
icon: 'none'
});
}
this.pendingPrintCount = Number(target.unreviewedCount || 0);
this.printMessage = `待打印未复核订单 ${this.pendingPrintCount} 条`;
this.showPrintStationDropdown = false;
this.showPrintPopup = true;
},
buildPrintSendParams() {
if (!this.printRequestCode) {
this.printRequestCode = this.buildPrintRequestCode();
}
return {
type: 'express',
printStationId: this.printStationId,
requestCode: this.printRequestCode,
data: {
waveGroups: Array.isArray(this.printWaveGroups) ? this.printWaveGroups : []
}
};
},
async handleConfirmPrint() {
if (!this.printStationList.length || !this.printStationId || !this.printStationName || this.printStationName === '--') {
this.printMessage = '请选择打印台';
uni.showToast({
title: '请选择打印台',
icon: 'none'
});
return;
}
if (!Array.isArray(this.printWaveGroups) || !this.printWaveGroups.length) {
this.printMessage = '未获取到打印数据';
uni.showToast({
title: '未获取到打印数据',
icon: 'none'
});
return;
}
const params = this.buildPrintSendParams();
const effectivePrintCount = Number(this.pendingPrintCount || 0) > 0
? Number(this.pendingPrintCount || 0)
: this.printWaveGroups.length;
uni.showLoading({
title: '发送打印中...'
});
try {
const response = await this.$http('print.send', params);
const success = response?.flag !== 'failure' && response?.code !== '500' && response?.code !== 500;
if (!success) {
throw new Error(response?.message || response?.msg || '打印失败');
}
this.printMessage = `打印已发送,未复核订单 ${effectivePrintCount} 条`;
uni.showToast({
title: `已发起打印${effectivePrintCount}条`,
icon: 'none'
});
this.showPrintPopup = false;
} catch (error) {
const message = String(error?.message || error?.msg || error?.errMsg || '打印失败');
this.printMessage = message;
uni.showToast({
title: message,
icon: 'none'
});
} finally {
uni.hideLoading();
}
},
handlePageChange(page) {
const targetPage = Math.max(1, Number(page || 1));
if (targetPage === this.currentPage) {
return;
}
this.currentPage = targetPage;
this.loadBatchWaveNoList(targetPage);
}
}
};
</script>
<style lang="scss" scoped>
.scatter-picking-detail-page {
height: 100vh;
background: #f8f9fa;
}
.normar_container {
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
::v-deep .u-popup,
::v-deep .u-popup-mask {
z-index: 10090 !important;
}
::v-deep .nav-title .right {
width: auto;
min-width: 136rpx;
display: flex;
justify-content: flex-end;
}
.nav-right-action {
font-size: 32rpx;
line-height: 36rpx;
color: #ffffff;
padding: 8rpx 18rpx;
border-radius: 6rpx;
background: #2979ff;
}
.nav-right-action--active {
color: #ffffff;
background: #1f67e6;
}
.detail-scroll {
flex: 1;
min-height: 0;
height: auto;
padding: 20rpx 24rpx 0;
box-sizing: border-box;
}
.pagination-wrap {
background: #ffffff;
border-top: 1rpx solid #f0f0f0;
padding: 0 24rpx env(safe-area-inset-bottom);
flex-shrink: 0;
}
.search-filter {
background: #ffffff;
padding: 20rpx 24rpx;
border: 1rpx solid #f0f0f0;
border-top: none;
border-radius: 0;
}
.search-box {
position: relative;
}
.search-box-inner {
position: relative;
}
::v-deep .search-box-inner .u-search {
width: 100%;
}
::v-deep .search-box-inner .u-search__content {
padding-right: 200rpx;
}
::v-deep .search-box-inner .u-search__content__close {
margin-right: 12rpx;
}
.search-actions {
position: absolute;
right: 24rpx;
top: 50%;
transform: translateY(-50%);
height: 68rpx;
display: flex;
align-items: center;
}
.scan-btn {
height: 68rpx;
padding: 0 8rpx 0 4rpx;
display: flex;
align-items: center;
justify-content: center;
&:active {
opacity: 0.88;
}
}
.search-divider {
width: 1rpx;
height: 28rpx;
background: #dcdfe6;
margin: 0 16rpx 0 10rpx;
}
.search-btn {
height: 68rpx;
padding: 0 8rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
&:active {
opacity: 0.88;
}
}
.search-btn__text {
font-size: 30rpx;
color: #2979ff;
font-weight: 500;
line-height: 1;
}
.record-list {
display: flex;
flex-direction: column;
gap: 14rpx;
}
.record-item {
background: #ffffff;
border-radius: 12rpx;
padding: 18rpx;
border: 1rpx solid #ebeef5;
}
.record-item:active {
opacity: 0.75;
}
.record-main {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.record-left {
flex: 1;
min-width: 0;
}
.record-line {
display: flex;
align-items: center;
flex-wrap: nowrap;
font-size: 32rpx;
line-height: 52rpx;
}
.record-line + .record-line {
margin-top: 8rpx;
}
.record-label {
width: 170rpx;
min-width: 170rpx;
color: #909399;
white-space: nowrap;
word-break: keep-all;
overflow-wrap: normal;
flex-shrink: 0;
}
.record-value {
flex: 1;
color: #303133;
}
.record-right {
min-width: 180rpx;
display: flex;
flex-direction: column;
align-items: flex-end;
margin-left: 16rpx;
}
.record-count {
font-size: 30rpx;
line-height: 40rpx;
color: #fa8c16;
}
.record-status {
margin-top: 12rpx;
font-size: 30rpx;
line-height: 40rpx;
color: #2979ff;
}
.record-footer {
margin-top: 14rpx;
display: flex;
justify-content: flex-end;
}
.empty-state {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.empty-text {
margin-top: 18rpx;
font-size: 28rpx;
color: #909399;
}
.safe-area-bottom {
height: calc(30rpx + env(safe-area-inset-bottom));
}
.print-popup {
padding: 24rpx 24rpx calc(20rpx + env(safe-area-inset-bottom));
background: #ffffff;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
}
.print-popup-title {
font-size: 34rpx;
font-weight: 600;
color: #303133;
margin-bottom: 20rpx;
}
.print-row {
display: flex;
align-items: flex-start;
padding: 16rpx 0;
border-bottom: 1rpx solid #f2f3f5;
}
.print-row--station {
position: relative;
}
.print-row--station .print-label {
padding-top: 10rpx;
}
.print-row--action {
align-items: center;
}
.print-row--message {
border-bottom: none;
}
.print-label {
min-width: 130rpx;
width: 130rpx;
font-size: 28rpx;
line-height: 40rpx;
color: #909399;
}
.print-value {
flex: 1;
font-size: 28rpx;
line-height: 40rpx;
color: #303133;
}
.print-picker {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 16rpx;
border: 1rpx solid #dcdfe6;
border-radius: 10rpx;
background: #fafafa;
}
.print-picker-value {
flex: 1;
font-size: 28rpx;
line-height: 40rpx;
color: #303133;
padding-right: 16rpx;
word-break: break-all;
}
.print-station-dropdown {
position: absolute;
right: 0;
top: calc(100% - 4rpx);
width: calc(100% - 154rpx);
max-height: 300rpx;
overflow-y: auto;
background: #ffffff;
border: 1rpx solid #ebeef5;
border-radius: 10rpx;
z-index: 10091;
}
.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-message {
flex: 1;
font-size: 28rpx;
line-height: 40rpx;
color: #303133;
}
</style>