修改散单拣货详情、团购拣货页面的打印、底部分页功能

This commit is contained in:
zm2000 2026-05-31 18:22:39 +08:00
parent 9821d1c577
commit 2e41d72791
2 changed files with 361 additions and 54 deletions

View File

@ -37,6 +37,21 @@
</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>
</view>
</template>
@ -49,6 +64,9 @@
onlyMine: false,
currentUserId: '',
grabCount: 0,
pageSize: 20,
currentPage: 1,
paginationTotal: 0,
orderList: []
};
},
@ -65,9 +83,121 @@
const hasGrabCountParam = options && Object.prototype.hasOwnProperty.call(options, 'grabCount');
const parsedGrabCount = Number(options?.grabCount || 0);
this.grabCount = hasGrabCountParam ? Math.max(0, parsedGrabCount) : 6;
this.orderList = this.buildMockOrderList(this.grabCount);
this.loadBatchWaveNoList();
},
methods: {
buildBatchListParams(page = this.currentPage) {
return {
pagination: {
page: Number(page || 1),
pageSize: Number(this.pageSize || 20)
},
where: {
source: 0,
wave_type: 1
}
};
},
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 => {
const source = item && typeof item === 'object' ? item : {};
const waveNo = String(source.wave_no || '').trim();
const rowId = source.wave_id ?? source.waveId ?? source.id ?? waveNo;
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 assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim();
return {
id: String(rowId || ''),
waveNo,
pickerName,
pendingCount: Number.isFinite(pendingCount) ? pendingCount : 0,
isMine: !!this.currentUserId && !!assigneeId && assigneeId === this.currentUserId
};
})
.filter(item => !!item.waveNo)
.map((item, index) => ({
...item,
id: item.id || `batch-${this.currentPage}-${index + 1}`
}));
},
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'
});
}
},
toggleOnlyMine() {
this.onlyMine = !this.onlyMine;
},
@ -97,6 +227,14 @@
`未复核数量:${item.pendingCount || 0}`
].join('\n')
});
},
handlePageChange(page) {
const targetPage = Math.max(1, Number(page || 1));
if (targetPage === this.currentPage) {
return;
}
this.currentPage = targetPage;
this.loadBatchWaveNoList(targetPage);
}
}
};
@ -104,10 +242,17 @@
<style lang="scss" scoped>
.groupon-picking-detail-page {
min-height: 100vh;
height: 100vh;
background: #f8f9fa;
}
.normar_container {
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
::v-deep .nav-title .right {
width: auto;
min-width: 136rpx;
@ -129,11 +274,20 @@
}
.detail-scroll {
height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
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;
}
.record-list {
display: flex;
flex-direction: column;

View File

@ -65,45 +65,61 @@
<view class="safe-area-bottom"></view>
</scroll-view>
<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 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"
class="print-station-option"
:class="{ 'print-station-option--active': station === printStationName }"
@click.stop="handlePrintStationSelect(station)"
>
{{ station }}
</view>
</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 class="print-row print-row--action">
<text class="print-label">打印</text>
<u-button
type="primary"
size="mini"
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff' }"
@click="handleConfirmPrint"
<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)"
>
打印
</u-button>
</view>
<view class="print-row print-row--message">
<text class="print-label">打印消息</text>
<text class="print-message">{{ printMessage || '暂无打印消息' }}</text>
{{ station.name }}
</view>
</view>
</view>
</u-popup>
</view>
<view class="print-row print-row--action">
<text class="print-label">打印</text>
<u-button
type="primary"
size="mini"
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff' }"
@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>
@ -116,18 +132,24 @@
keyword: '',
onlyMine: false,
currentUserId: '',
pageSize: 20,
currentPage: 1,
showPrintPopup: false,
showPrintStationDropdown: false,
printStationName: '--',
printStationId: '',
printStationList: [],
printMessage: '',
pendingPrintCount: 0,
printRequestCode: '',
printWaveGroups: [],
printWavePlatformPrintData: null,
printTargetList: [],
orderList: []
};
},
computed: {
displayOrderList() {
filteredOrderList() {
let list = this.onlyMine
? this.orderList.filter(item => item.isMine)
: this.orderList;
@ -144,6 +166,30 @@
});
return list;
},
paginationTotal() {
return this.filteredOrderList.length;
},
displayOrderList() {
const page = Math.max(1, Number(this.currentPage || 1));
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) {
@ -294,6 +340,32 @@
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) {
@ -302,7 +374,16 @@
if (!params.wave_ids.length) {
throw new Error('缺少波次ID');
}
return this.$http('order.print.getWavePlatformPrintData', params);
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 {};
@ -318,17 +399,26 @@
const list = response?.data?.list || response?.data?.data?.list;
return Array.isArray(list) ? list : [];
},
normalizePrintStationNames(list) {
normalizePrintStations(list) {
return list
.map(item => String(item?.name || '').trim())
.filter(name => !!name);
.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 names = this.normalizePrintStationNames(list);
this.printStationList = names;
this.printStationName = names[0] || '--';
const stations = this.normalizePrintStations(list);
this.printStationList = stations;
this.printStationId = stations[0]?.id || '';
this.printStationName = stations[0]?.name || '--';
},
togglePrintStationDropdown() {
if (!this.printStationList.length) {
@ -341,7 +431,8 @@
this.showPrintStationDropdown = !this.showPrintStationDropdown;
},
handlePrintStationSelect(station) {
this.printStationName = String(station || '--');
this.printStationId = String(station?.id || '');
this.printStationName = String(station?.name || '--');
this.showPrintStationDropdown = false;
},
safeDispatchBroadcast(action, payload) {
@ -669,8 +760,21 @@
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.printStationName || this.printStationName === '--') {
if (!this.printStationList.length || !this.printStationId || !this.printStationName || this.printStationName === '--') {
this.printMessage = '请选择打印台';
uni.showToast({
title: '请选择打印台',
@ -682,11 +786,44 @@
this.printMessage = '暂无可打印订单';
return;
}
this.printMessage = `打印已发送,未复核订单 ${this.pendingPrintCount} 条`;
uni.showToast({
title: `已发起打印${this.pendingPrintCount}条`,
icon: 'none'
if (!Array.isArray(this.printWaveGroups) || !this.printWaveGroups.length) {
this.printMessage = '未获取到打印数据';
uni.showToast({
title: '未获取到打印数据',
icon: 'none'
});
return;
}
const params = this.buildPrintSendParams();
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 = `打印已发送,未复核订单 ${this.pendingPrintCount} 条`;
uni.showToast({
title: `已发起打印${this.pendingPrintCount}条`,
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) {
this.currentPage = Math.max(1, Number(page || 1));
}
}
};
@ -694,10 +831,17 @@
<style lang="scss" scoped>
.scatter-picking-detail-page {
min-height: 100vh;
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;
@ -725,11 +869,20 @@
}
.detail-scroll {
height: calc(100vh - 120rpx - 112rpx - env(safe-area-inset-bottom));
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;