修改散单拣货详情页面的打印功能
This commit is contained in:
parent
cbb173ba16
commit
9821d1c577
@ -250,7 +250,21 @@ export default {
|
||||
}
|
||||
},
|
||||
order: {
|
||||
print: {
|
||||
getWavePlatformPrintData: {
|
||||
path: "order.print.getWavePlatformPrintData",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
}
|
||||
},
|
||||
wave: {
|
||||
batchList: {
|
||||
path: "order.wave.batchList",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
waveStrategyList: {
|
||||
path: "order.wave.waveStrategyList",
|
||||
auth: true,
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
type="primary"
|
||||
size="mini"
|
||||
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff', fontSize: '26rpx', height: '64rpx', lineHeight: '64rpx', padding: '0 20rpx' }"
|
||||
@click.native.stop="handlePrintAllUnreviewed"
|
||||
@click.native.stop="handlePrintAllUnreviewed(item)"
|
||||
>
|
||||
打印所有未复核订单
|
||||
</u-button>
|
||||
@ -65,12 +65,26 @@
|
||||
<view class="safe-area-bottom"></view>
|
||||
</scroll-view>
|
||||
|
||||
<u-popup :show="showPrintPopup" mode="bottom" :closeable="true" border-radius="20" @close="showPrintPopup = false">
|
||||
<u-popup :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">
|
||||
<view class="print-row print-row--station">
|
||||
<text class="print-label">打印台</text>
|
||||
<text class="print-value">{{ printStationName }}</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"
|
||||
class="print-station-option"
|
||||
:class="{ 'print-station-option--active': station === printStationName }"
|
||||
@click.stop="handlePrintStationSelect(station)"
|
||||
>
|
||||
{{ station }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="print-row print-row--action">
|
||||
<text class="print-label">打印</text>
|
||||
@ -103,10 +117,12 @@
|
||||
onlyMine: false,
|
||||
currentUserId: '',
|
||||
showPrintPopup: false,
|
||||
showPrintStationDropdown: false,
|
||||
printStationName: '--',
|
||||
printStationList: [],
|
||||
printMessage: '',
|
||||
pendingPrintCount: 0,
|
||||
printTargetList: [],
|
||||
orderList: []
|
||||
};
|
||||
},
|
||||
@ -143,6 +159,7 @@
|
||||
? Math.max(0, parsedGrabCount)
|
||||
: 5;
|
||||
this.orderList = this.buildMockOrderList(this.grabCount);
|
||||
this.loadBatchWaveNoList();
|
||||
},
|
||||
onShow() {
|
||||
this.safeDispatchBroadcast('setCallbacks', {
|
||||
@ -157,6 +174,136 @@
|
||||
this.safeDispatchBroadcast('stop');
|
||||
},
|
||||
methods: {
|
||||
buildBatchListParams() {
|
||||
return {
|
||||
pagination: {
|
||||
page: 1,
|
||||
pageSize: 20
|
||||
},
|
||||
where: {
|
||||
source: 0,
|
||||
wave_type: 2
|
||||
}
|
||||
};
|
||||
},
|
||||
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 => {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
return {
|
||||
waveNo: String(source.wave_no || '').trim(),
|
||||
waveId: source.wave_id ?? source.waveId ?? source.id ?? ''
|
||||
};
|
||||
}).filter(item => !!item.waveNo);
|
||||
},
|
||||
applyWaveNoToMockList(batchWaveList) {
|
||||
const count = batchWaveList.length ? batchWaveList.length : this.grabCount;
|
||||
const mockList = this.buildMockOrderList(count);
|
||||
if (batchWaveList.length) {
|
||||
mockList.forEach((item, index) => {
|
||||
const current = batchWaveList[index] || {};
|
||||
item.waveNo = current.waveNo || item.waveNo;
|
||||
item.waveId = current.waveId || '';
|
||||
});
|
||||
}
|
||||
this.orderList = mockList;
|
||||
},
|
||||
async loadBatchWaveNoList() {
|
||||
try {
|
||||
const response = await this.$http('order.wave.batchList', this.buildBatchListParams());
|
||||
const payload = this.extractBatchListPayload(response);
|
||||
const list = this.extractBatchList(payload, response);
|
||||
const batchWaveList = this.normalizeBatchWaveList(list);
|
||||
this.applyWaveNoToMockList(batchWaveList);
|
||||
} catch (error) {
|
||||
this.orderList = this.buildMockOrderList(this.grabCount);
|
||||
}
|
||||
},
|
||||
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
|
||||
};
|
||||
},
|
||||
async requestWavePlatformPrintData() {
|
||||
const params = this.buildWavePlatformPrintParams();
|
||||
if (!params.warehouse_id) {
|
||||
throw new Error('缺少仓库ID');
|
||||
}
|
||||
if (!params.wave_ids.length) {
|
||||
throw new Error('缺少波次ID');
|
||||
}
|
||||
return this.$http('order.print.getWavePlatformPrintData', params);
|
||||
},
|
||||
buildPrintRecordWhere() {
|
||||
return {};
|
||||
},
|
||||
@ -181,7 +328,21 @@
|
||||
const list = this.extractPrintRecordList(response);
|
||||
const names = this.normalizePrintStationNames(list);
|
||||
this.printStationList = names;
|
||||
this.printStationName = names.length ? names.join('、') : '--';
|
||||
this.printStationName = names[0] || '--';
|
||||
},
|
||||
togglePrintStationDropdown() {
|
||||
if (!this.printStationList.length) {
|
||||
uni.showToast({
|
||||
title: '暂无可用打印台',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.showPrintStationDropdown = !this.showPrintStationDropdown;
|
||||
},
|
||||
handlePrintStationSelect(station) {
|
||||
this.printStationName = String(station || '--');
|
||||
this.showPrintStationDropdown = false;
|
||||
},
|
||||
safeDispatchBroadcast(action, payload) {
|
||||
try {
|
||||
@ -470,15 +631,29 @@
|
||||
];
|
||||
this.$tools.routerTo(`/pages/work/order/scatter-pick-goods-detail?${params.join('&')}`);
|
||||
},
|
||||
async handlePrintAllUnreviewed() {
|
||||
const targetList = this.displayOrderList.filter(item => Number(item.unreviewedCount || 0) > 0);
|
||||
if (!targetList.length) {
|
||||
async handlePrintAllUnreviewed(item) {
|
||||
const target = item && typeof item === 'object' ? item : null;
|
||||
if (!target || Number(target.unreviewedCount || 0) <= 0) {
|
||||
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) {
|
||||
@ -489,11 +664,20 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
this.pendingPrintCount = targetList.length;
|
||||
this.printMessage = `待打印未复核订单 ${targetList.length} 条`;
|
||||
this.pendingPrintCount = Number(target.unreviewedCount || 0);
|
||||
this.printMessage = `待打印未复核订单 ${this.pendingPrintCount} 条`;
|
||||
this.showPrintStationDropdown = false;
|
||||
this.showPrintPopup = true;
|
||||
},
|
||||
handleConfirmPrint() {
|
||||
async handleConfirmPrint() {
|
||||
if (!this.printStationList.length || !this.printStationName || this.printStationName === '--') {
|
||||
this.printMessage = '请选择打印台';
|
||||
uni.showToast({
|
||||
title: '请选择打印台',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.pendingPrintCount <= 0) {
|
||||
this.printMessage = '暂无可打印订单';
|
||||
return;
|
||||
@ -514,6 +698,11 @@
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
::v-deep .u-popup,
|
||||
::v-deep .u-popup-mask {
|
||||
z-index: 10090 !important;
|
||||
}
|
||||
|
||||
::v-deep .nav-title .right {
|
||||
width: auto;
|
||||
min-width: 136rpx;
|
||||
@ -736,6 +925,10 @@
|
||||
border-bottom: 1rpx solid #f2f3f5;
|
||||
}
|
||||
|
||||
.print-row--station {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.print-row--action {
|
||||
align-items: center;
|
||||
}
|
||||
@ -758,6 +951,47 @@
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.print-picker {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.print-picker-value {
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.print-station-dropdown {
|
||||
position: absolute;
|
||||
left: 130rpx;
|
||||
right: 0;
|
||||
top: 74rpx;
|
||||
max-height: 300rpx;
|
||||
overflow-y: auto;
|
||||
background: #ffffff;
|
||||
border: 1rpx solid #ebeef5;
|
||||
border-radius: 8rpx;
|
||||
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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user