修改散单、团购拣货页面的打印、底部分页功能
This commit is contained in:
parent
2e41d72791
commit
5a6d95914e
@ -53,6 +53,46 @@
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<u-popup v-if="showPrintPopup" :show="showPrintPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10090" @close="handlePrintPopupClose">
|
||||||
|
<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"
|
||||||
|
@tap="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>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -67,6 +107,17 @@
|
|||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
paginationTotal: 0,
|
paginationTotal: 0,
|
||||||
|
showPrintPopup: false,
|
||||||
|
showPrintStationDropdown: false,
|
||||||
|
printStationName: '--',
|
||||||
|
printStationId: '',
|
||||||
|
printStationList: [],
|
||||||
|
printMessage: '',
|
||||||
|
pendingPrintCount: 0,
|
||||||
|
printRequestCode: '',
|
||||||
|
printWaveGroups: [],
|
||||||
|
printWavePlatformPrintData: null,
|
||||||
|
printTargetList: [],
|
||||||
orderList: []
|
orderList: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -142,11 +193,13 @@
|
|||||||
const source = item && typeof item === 'object' ? item : {};
|
const source = item && typeof item === 'object' ? item : {};
|
||||||
const waveNo = String(source.wave_no || '').trim();
|
const waveNo = String(source.wave_no || '').trim();
|
||||||
const rowId = source.wave_id ?? source.waveId ?? source.id ?? waveNo;
|
const rowId = source.wave_id ?? source.waveId ?? source.id ?? waveNo;
|
||||||
|
const waveId = source.wave_id ?? source.waveId ?? source.id ?? '';
|
||||||
const pickerName = String(source.picker_name || source.pickerName || source.user_name || source.userName || '--').trim() || '--';
|
const pickerName = String(source.picker_name || source.pickerName || source.user_name || source.userName || '--').trim() || '--';
|
||||||
const pendingCount = Number(source.pending_count ?? source.pendingCount ?? source.unreviewed_count ?? source.unreviewedCount ?? 0);
|
const pendingCount = Number(source.pending_count ?? source.pendingCount ?? source.unreviewed_count ?? source.unreviewedCount ?? 0);
|
||||||
const assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim();
|
const assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim();
|
||||||
return {
|
return {
|
||||||
id: String(rowId || ''),
|
id: String(rowId || ''),
|
||||||
|
waveId: typeof waveId === 'number' ? waveId : String(waveId || '').trim(),
|
||||||
waveNo,
|
waveNo,
|
||||||
pickerName,
|
pickerName,
|
||||||
pendingCount: Number.isFinite(pendingCount) ? pendingCount : 0,
|
pendingCount: Number.isFinite(pendingCount) ? pendingCount : 0,
|
||||||
@ -177,6 +230,147 @@
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
resolveWarehouseId() {
|
||||||
|
const user = this.$store?.getters?.user || {};
|
||||||
|
const userInfo = this.$store?.getters?.userInfo || {};
|
||||||
|
const candidates = [
|
||||||
|
user?.store_id,
|
||||||
|
user?.storeId,
|
||||||
|
userInfo?.store_id,
|
||||||
|
userInfo?.storeId,
|
||||||
|
uni.getStorageSync('store_id'),
|
||||||
|
uni.getStorageSync('storeId'),
|
||||||
|
user?.warehouse_id,
|
||||||
|
user?.warehouseId,
|
||||||
|
userInfo?.warehouse_id,
|
||||||
|
userInfo?.warehouseId,
|
||||||
|
uni.getStorageSync('warehouse_id'),
|
||||||
|
uni.getStorageSync('warehouseId')
|
||||||
|
];
|
||||||
|
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 ?? item?.id ?? '')
|
||||||
|
.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();
|
||||||
|
console.log('[GrouponPickingDetail] getWavePlatformPrintData params:', params);
|
||||||
|
try {
|
||||||
|
const response = await this.$http('order.print.getWavePlatformPrintData', params);
|
||||||
|
console.log('[GrouponPickingDetail] getWavePlatformPrintData success:', response);
|
||||||
|
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;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[GrouponPickingDetail] getWavePlatformPrintData error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
handlePrintPopupClose() {
|
||||||
|
this.showPrintPopup = false;
|
||||||
|
this.showPrintStationDropdown = false;
|
||||||
|
},
|
||||||
async loadBatchWaveNoList(page = this.currentPage) {
|
async loadBatchWaveNoList(page = this.currentPage) {
|
||||||
const targetPage = Math.max(1, Number(page || 1));
|
const targetPage = Math.max(1, Number(page || 1));
|
||||||
try {
|
try {
|
||||||
@ -209,6 +403,7 @@
|
|||||||
const isMine = index % 2 === 0;
|
const isMine = index % 2 === 0;
|
||||||
return {
|
return {
|
||||||
id: `${orderNo}-${index + 1}`,
|
id: `${orderNo}-${index + 1}`,
|
||||||
|
waveId: `${index + 1}`,
|
||||||
waveNo,
|
waveNo,
|
||||||
pickerName: isMine ? '我' : `拣货员${(index % 3) + 1}`,
|
pickerName: isMine ? '我' : `拣货员${(index % 3) + 1}`,
|
||||||
pendingCount: (index % 5) + 1,
|
pendingCount: (index % 5) + 1,
|
||||||
@ -216,17 +411,131 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showRecordDetail(item) {
|
async showRecordDetail(item) {
|
||||||
if (!item) return;
|
const target = item && typeof item === 'object' ? item : null;
|
||||||
uni.showModal({
|
console.log('[GrouponPickingDetail] print button clicked:', target);
|
||||||
title: '打印面单',
|
if (!target) {
|
||||||
showCancel: false,
|
uni.showToast({
|
||||||
content: [
|
title: '未找到可打印波次',
|
||||||
`波次号:${item.waveNo || '--'}`,
|
icon: 'none'
|
||||||
`拣货员:${item.pickerName || '--'}`,
|
});
|
||||||
`未复核数量:${item.pendingCount || 0}`
|
return;
|
||||||
].join('\n')
|
}
|
||||||
|
const targetWaveId = target.waveId ?? target.id ?? '';
|
||||||
|
if (targetWaveId === '' || targetWaveId === null || targetWaveId === undefined) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '波次缺少wave_id,无法打印',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.printTargetList = [{
|
||||||
|
...target,
|
||||||
|
waveId: targetWaveId
|
||||||
|
}];
|
||||||
|
this.printWaveGroups = [];
|
||||||
|
this.printWavePlatformPrintData = null;
|
||||||
|
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.printStationId = '';
|
||||||
|
this.printStationName = '--';
|
||||||
|
uni.showToast({
|
||||||
|
title: '打印台加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.pendingPrintCount = Number(target.pendingCount || 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() {
|
||||||
|
console.log('[GrouponPickingDetail] handleConfirmPrint clicked:', {
|
||||||
|
printStationId: this.printStationId,
|
||||||
|
printStationName: this.printStationName,
|
||||||
|
printStationListLength: Array.isArray(this.printStationList) ? this.printStationList.length : 0,
|
||||||
|
pendingPrintCount: this.pendingPrintCount,
|
||||||
|
waveGroupsLength: Array.isArray(this.printWaveGroups) ? this.printWaveGroups.length : 0
|
||||||
});
|
});
|
||||||
|
if (!this.printStationList.length || !this.printStationId || !this.printStationName || this.printStationName === '--') {
|
||||||
|
console.warn('[GrouponPickingDetail] handleConfirmPrint blocked: invalid print station');
|
||||||
|
this.printMessage = '请选择打印台';
|
||||||
|
uni.showToast({
|
||||||
|
title: '请选择打印台',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Array.isArray(this.printWaveGroups) || !this.printWaveGroups.length) {
|
||||||
|
console.warn('[GrouponPickingDetail] handleConfirmPrint blocked: waveGroups empty');
|
||||||
|
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;
|
||||||
|
console.log('[GrouponPickingDetail] print.send params:', params);
|
||||||
|
uni.showLoading({
|
||||||
|
title: '发送打印中...'
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const response = await this.$http('print.send', params);
|
||||||
|
console.log('[GrouponPickingDetail] print.send success:', response);
|
||||||
|
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) {
|
||||||
|
console.error('[GrouponPickingDetail] print.send error:', error);
|
||||||
|
const message = String(error?.message || error?.msg || error?.errMsg || '打印失败');
|
||||||
|
this.printMessage = message;
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handlePageChange(page) {
|
handlePageChange(page) {
|
||||||
const targetPage = Math.max(1, Number(page || 1));
|
const targetPage = Math.max(1, Number(page || 1));
|
||||||
@ -253,6 +562,11 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::v-deep .u-popup,
|
||||||
|
::v-deep .u-popup-mask {
|
||||||
|
z-index: 10090 !important;
|
||||||
|
}
|
||||||
|
|
||||||
::v-deep .nav-title .right {
|
::v-deep .nav-title .right {
|
||||||
width: auto;
|
width: auto;
|
||||||
min-width: 136rpx;
|
min-width: 136rpx;
|
||||||
@ -377,6 +691,118 @@
|
|||||||
color: #909399;
|
color: #909399;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
text-align: left;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-row {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 16rpx 0;
|
||||||
|
border-bottom: 1rpx solid #f5f5f5;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-row--station {
|
||||||
|
align-items: flex-start;
|
||||||
|
padding-top: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-row--station .print-label {
|
||||||
|
padding-top: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-label {
|
||||||
|
min-width: 120rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
color: #606266;
|
||||||
|
line-height: 44rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
color: #303133;
|
||||||
|
padding-right: 16rpx;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-station-dropdown {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: calc(100% - 4rpx);
|
||||||
|
width: calc(100% - 144rpx);
|
||||||
|
max-height: 360rpx;
|
||||||
|
overflow-y: auto;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1rpx solid #ebeef5;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.08);
|
||||||
|
z-index: 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-station-option {
|
||||||
|
padding: 16rpx 20rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-station-option + .print-station-option {
|
||||||
|
border-top: 1rpx solid #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-station-option--active {
|
||||||
|
color: #2979ff;
|
||||||
|
background: rgba(41, 121, 255, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-row--action .u-btn {
|
||||||
|
min-width: 160rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-row--message {
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: flex-start;
|
||||||
|
border-bottom: none;
|
||||||
|
padding-bottom: 0;
|
||||||
|
padding-top: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-message {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
color: #606266;
|
||||||
|
text-align: left;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
.safe-area-bottom {
|
.safe-area-bottom {
|
||||||
height: calc(30rpx + env(safe-area-inset-bottom));
|
height: calc(30rpx + env(safe-area-inset-bottom));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,7 +108,7 @@
|
|||||||
<u-button
|
<u-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff' }"
|
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff', fontSize: '26rpx', height: '64rpx', lineHeight: '64rpx', padding: '0 20rpx' }"
|
||||||
@click="handleConfirmPrint"
|
@click="handleConfirmPrint"
|
||||||
>
|
>
|
||||||
打印
|
打印
|
||||||
@ -134,6 +134,7 @@
|
|||||||
currentUserId: '',
|
currentUserId: '',
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
|
paginationTotal: 0,
|
||||||
showPrintPopup: false,
|
showPrintPopup: false,
|
||||||
showPrintStationDropdown: false,
|
showPrintStationDropdown: false,
|
||||||
printStationName: '--',
|
printStationName: '--',
|
||||||
@ -149,47 +150,8 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
filteredOrderList() {
|
|
||||||
let list = this.onlyMine
|
|
||||||
? this.orderList.filter(item => item.isMine)
|
|
||||||
: this.orderList;
|
|
||||||
|
|
||||||
const keyword = this.normalizeKeyword(this.keyword).toLowerCase();
|
|
||||||
if (!keyword) {
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
list = list.filter(item => {
|
|
||||||
const waybillCode = this.normalizeKeyword(item?.waybillCode).toLowerCase();
|
|
||||||
const cartNo = this.normalizeKeyword(item?.cartNo).toLowerCase();
|
|
||||||
return waybillCode.includes(keyword) || cartNo.includes(keyword);
|
|
||||||
});
|
|
||||||
|
|
||||||
return list;
|
|
||||||
},
|
|
||||||
paginationTotal() {
|
|
||||||
return this.filteredOrderList.length;
|
|
||||||
},
|
|
||||||
displayOrderList() {
|
displayOrderList() {
|
||||||
const page = Math.max(1, Number(this.currentPage || 1));
|
return Array.isArray(this.orderList) ? this.orderList : [];
|
||||||
const size = Math.max(1, Number(this.pageSize || 20));
|
|
||||||
const start = (page - 1) * size;
|
|
||||||
return this.filteredOrderList.slice(start, start + size);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
keyword() {
|
|
||||||
this.currentPage = 1;
|
|
||||||
},
|
|
||||||
onlyMine() {
|
|
||||||
this.currentPage = 1;
|
|
||||||
},
|
|
||||||
paginationTotal(newTotal) {
|
|
||||||
const total = Number(newTotal || 0);
|
|
||||||
const maxPage = Math.max(1, Math.ceil(total / this.pageSize));
|
|
||||||
if (this.currentPage > maxPage) {
|
|
||||||
this.currentPage = maxPage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
@ -204,8 +166,7 @@
|
|||||||
this.grabCount = hasGrabCountParam
|
this.grabCount = hasGrabCountParam
|
||||||
? Math.max(0, parsedGrabCount)
|
? Math.max(0, parsedGrabCount)
|
||||||
: 5;
|
: 5;
|
||||||
this.orderList = this.buildMockOrderList(this.grabCount);
|
this.loadBatchWaveNoList(1);
|
||||||
this.loadBatchWaveNoList();
|
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.safeDispatchBroadcast('setCallbacks', {
|
this.safeDispatchBroadcast('setCallbacks', {
|
||||||
@ -220,18 +181,25 @@
|
|||||||
this.safeDispatchBroadcast('stop');
|
this.safeDispatchBroadcast('stop');
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
buildBatchListParams() {
|
buildBatchListParams(page = this.currentPage) {
|
||||||
|
const where = {
|
||||||
|
source: 0,
|
||||||
|
wave_type: 2
|
||||||
|
};
|
||||||
|
if (this.onlyMine && this.currentUserId) {
|
||||||
|
where.picker_id = this.currentUserId;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
pagination: {
|
pagination: {
|
||||||
page: 1,
|
page: Math.max(1, Number(page || 1)),
|
||||||
pageSize: 20
|
pageSize: Math.max(1, Number(this.pageSize || 20))
|
||||||
},
|
},
|
||||||
where: {
|
where
|
||||||
source: 0,
|
|
||||||
wave_type: 2
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
extractPagination(payload, response) {
|
||||||
|
return payload?.pagination || payload?.page || response?.data?.pagination || response?.pagination || null;
|
||||||
|
},
|
||||||
extractBatchListPayload(response) {
|
extractBatchListPayload(response) {
|
||||||
const candidates = [
|
const candidates = [
|
||||||
response?.data?.data,
|
response?.data?.data,
|
||||||
@ -268,35 +236,67 @@
|
|||||||
if (!Array.isArray(list)) {
|
if (!Array.isArray(list)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return list.map(item => {
|
return list
|
||||||
const source = item && typeof item === 'object' ? item : {};
|
.map((item, index) => {
|
||||||
return {
|
const source = item && typeof item === 'object' ? item : {};
|
||||||
waveNo: String(source.wave_no || '').trim(),
|
const waveNo = String(source.wave_no || source.waveNo || '').trim();
|
||||||
waveId: source.wave_id ?? source.waveId ?? source.id ?? ''
|
const waveId = source.wave_id ?? source.waveId ?? source.id ?? '';
|
||||||
};
|
const rowId = source.id ?? waveId ?? waveNo ?? `batch-${this.currentPage}-${index + 1}`;
|
||||||
}).filter(item => !!item.waveNo);
|
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 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,
|
||||||
|
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);
|
||||||
},
|
},
|
||||||
applyWaveNoToMockList(batchWaveList) {
|
resolvePaginationTotal(payload, response, pagination, list) {
|
||||||
const count = batchWaveList.length ? batchWaveList.length : this.grabCount;
|
const candidates = [
|
||||||
const mockList = this.buildMockOrderList(count);
|
pagination?.total,
|
||||||
if (batchWaveList.length) {
|
payload?.total,
|
||||||
mockList.forEach((item, index) => {
|
payload?.count,
|
||||||
const current = batchWaveList[index] || {};
|
payload?.totalCount,
|
||||||
item.waveNo = current.waveNo || item.waveNo;
|
response?.data?.total,
|
||||||
item.waveId = current.waveId || '';
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.orderList = mockList;
|
return 0;
|
||||||
},
|
},
|
||||||
async loadBatchWaveNoList() {
|
async loadBatchWaveNoList(page = this.currentPage) {
|
||||||
|
const targetPage = Math.max(1, Number(page || 1));
|
||||||
try {
|
try {
|
||||||
const response = await this.$http('order.wave.batchList', this.buildBatchListParams());
|
const response = await this.$http('order.wave.batchList', this.buildBatchListParams(targetPage));
|
||||||
const payload = this.extractBatchListPayload(response);
|
const payload = this.extractBatchListPayload(response);
|
||||||
const list = this.extractBatchList(payload, response);
|
const list = this.extractBatchList(payload, response);
|
||||||
|
const pagination = this.extractPagination(payload, response);
|
||||||
const batchWaveList = this.normalizeBatchWaveList(list);
|
const batchWaveList = this.normalizeBatchWaveList(list);
|
||||||
this.applyWaveNoToMockList(batchWaveList);
|
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) {
|
} catch (error) {
|
||||||
this.orderList = this.buildMockOrderList(this.grabCount);
|
this.orderList = [];
|
||||||
|
this.paginationTotal = 0;
|
||||||
|
uni.showToast({
|
||||||
|
title: '波次列表加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
resolveWarehouseId() {
|
resolveWarehouseId() {
|
||||||
@ -676,6 +676,8 @@
|
|||||||
},
|
},
|
||||||
toggleOnlyMine() {
|
toggleOnlyMine() {
|
||||||
this.onlyMine = !this.onlyMine;
|
this.onlyMine = !this.onlyMine;
|
||||||
|
this.currentPage = 1;
|
||||||
|
this.loadBatchWaveNoList(1);
|
||||||
},
|
},
|
||||||
buildMockOrderList(count) {
|
buildMockOrderList(count) {
|
||||||
const listCount = Math.max(0, Number(count || 0));
|
const listCount = Math.max(0, Number(count || 0));
|
||||||
@ -724,7 +726,7 @@
|
|||||||
},
|
},
|
||||||
async handlePrintAllUnreviewed(item) {
|
async handlePrintAllUnreviewed(item) {
|
||||||
const target = item && typeof item === 'object' ? item : null;
|
const target = item && typeof item === 'object' ? item : null;
|
||||||
if (!target || Number(target.unreviewedCount || 0) <= 0) {
|
if (!target) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '暂无未复核订单可打印',
|
title: '暂无未复核订单可打印',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@ -782,10 +784,6 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.pendingPrintCount <= 0) {
|
|
||||||
this.printMessage = '暂无可打印订单';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!Array.isArray(this.printWaveGroups) || !this.printWaveGroups.length) {
|
if (!Array.isArray(this.printWaveGroups) || !this.printWaveGroups.length) {
|
||||||
this.printMessage = '未获取到打印数据';
|
this.printMessage = '未获取到打印数据';
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -796,6 +794,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const params = this.buildPrintSendParams();
|
const params = this.buildPrintSendParams();
|
||||||
|
const effectivePrintCount = Number(this.pendingPrintCount || 0) > 0
|
||||||
|
? Number(this.pendingPrintCount || 0)
|
||||||
|
: this.printWaveGroups.length;
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '发送打印中...'
|
title: '发送打印中...'
|
||||||
});
|
});
|
||||||
@ -805,9 +806,9 @@
|
|||||||
if (!success) {
|
if (!success) {
|
||||||
throw new Error(response?.message || response?.msg || '打印失败');
|
throw new Error(response?.message || response?.msg || '打印失败');
|
||||||
}
|
}
|
||||||
this.printMessage = `打印已发送,未复核订单 ${this.pendingPrintCount} 条`;
|
this.printMessage = `打印已发送,未复核订单 ${effectivePrintCount} 条`;
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: `已发起打印${this.pendingPrintCount}条`,
|
title: `已发起打印${effectivePrintCount}条`,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
this.showPrintPopup = false;
|
this.showPrintPopup = false;
|
||||||
@ -823,7 +824,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handlePageChange(page) {
|
handlePageChange(page) {
|
||||||
this.currentPage = Math.max(1, Number(page || 1));
|
const targetPage = Math.max(1, Number(page || 1));
|
||||||
|
if (targetPage === this.currentPage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.currentPage = targetPage;
|
||||||
|
this.loadBatchWaveNoList(targetPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1061,14 +1067,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.print-popup {
|
.print-popup {
|
||||||
padding: 24rpx;
|
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 {
|
.print-popup-title {
|
||||||
font-size: 32rpx;
|
font-size: 34rpx;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #303133;
|
color: #303133;
|
||||||
margin-bottom: 18rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.print-row {
|
.print-row {
|
||||||
@ -1082,6 +1091,10 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.print-row--station .print-label {
|
||||||
|
padding-top: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.print-row--action {
|
.print-row--action {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
@ -1091,6 +1104,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.print-label {
|
.print-label {
|
||||||
|
min-width: 130rpx;
|
||||||
width: 130rpx;
|
width: 130rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
line-height: 40rpx;
|
line-height: 40rpx;
|
||||||
@ -1106,27 +1120,35 @@
|
|||||||
|
|
||||||
.print-picker {
|
.print-picker {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
padding: 10rpx 16rpx;
|
||||||
|
border: 1rpx solid #dcdfe6;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
background: #fafafa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.print-picker-value {
|
.print-picker-value {
|
||||||
|
flex: 1;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
line-height: 40rpx;
|
line-height: 40rpx;
|
||||||
color: #303133;
|
color: #303133;
|
||||||
|
padding-right: 16rpx;
|
||||||
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.print-station-dropdown {
|
.print-station-dropdown {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 130rpx;
|
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 74rpx;
|
top: calc(100% - 4rpx);
|
||||||
|
width: calc(100% - 154rpx);
|
||||||
max-height: 300rpx;
|
max-height: 300rpx;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
border: 1rpx solid #ebeef5;
|
border: 1rpx solid #ebeef5;
|
||||||
border-radius: 8rpx;
|
border-radius: 10rpx;
|
||||||
z-index: 10091;
|
z-index: 10091;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user