383 lines
9.7 KiB
Vue
383 lines
9.7 KiB
Vue
<template>
|
||
<view class="groupon-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>
|
||
|
||
<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">
|
||
<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.pickerName || '--' }}</text></view>
|
||
</view>
|
||
<view class="record-right">
|
||
<text class="record-count">未复核 {{ item.pendingCount }}</text>
|
||
</view>
|
||
</view>
|
||
<view class="record-footer">
|
||
<u-button
|
||
type="primary"
|
||
size="mini"
|
||
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff', fontSize: '26rpx', height: '64rpx', lineHeight: '64rpx', padding: '0 20rpx' }"
|
||
@click="showRecordDetail(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>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
title: '团购拣货详情',
|
||
onlyMine: false,
|
||
currentUserId: '',
|
||
grabCount: 0,
|
||
pageSize: 20,
|
||
currentPage: 1,
|
||
paginationTotal: 0,
|
||
orderList: []
|
||
};
|
||
},
|
||
computed: {
|
||
displayOrderList() {
|
||
if (!this.onlyMine) {
|
||
return this.orderList;
|
||
}
|
||
return this.orderList.filter(item => item.isMine);
|
||
}
|
||
},
|
||
onLoad(options) {
|
||
this.currentUserId = String(this.$store?.getters?.user?.id || this.$store?.getters?.user?.user_id || '').trim();
|
||
const hasGrabCountParam = options && Object.prototype.hasOwnProperty.call(options, 'grabCount');
|
||
const parsedGrabCount = Number(options?.grabCount || 0);
|
||
this.grabCount = hasGrabCountParam ? Math.max(0, parsedGrabCount) : 6;
|
||
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;
|
||
},
|
||
buildMockOrderList(count) {
|
||
const listCount = Math.max(0, Number(count || 0));
|
||
return Array.from({ length: listCount }).map((_, index) => {
|
||
const waveNo = `GW${new Date().getFullYear()}${String(index + 1).padStart(4, '0')}`;
|
||
const orderNo = `TG${Date.now().toString().slice(-6)}${String(index + 1).padStart(2, '0')}`;
|
||
const isMine = index % 2 === 0;
|
||
return {
|
||
id: `${orderNo}-${index + 1}`,
|
||
waveNo,
|
||
pickerName: isMine ? '我' : `拣货员${(index % 3) + 1}`,
|
||
pendingCount: (index % 5) + 1,
|
||
isMine
|
||
};
|
||
});
|
||
},
|
||
showRecordDetail(item) {
|
||
if (!item) return;
|
||
uni.showModal({
|
||
title: '打印面单',
|
||
showCancel: false,
|
||
content: [
|
||
`波次号:${item.waveNo || '--'}`,
|
||
`拣货员:${item.pickerName || '--'}`,
|
||
`未复核数量:${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);
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.groupon-picking-detail-page {
|
||
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;
|
||
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 {
|
||
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;
|
||
}
|
||
|
||
.record-list {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 14rpx;
|
||
}
|
||
|
||
.record-item {
|
||
background: #ffffff;
|
||
border-radius: 12rpx;
|
||
padding: 18rpx;
|
||
border: 1rpx solid #ebeef5;
|
||
}
|
||
|
||
.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;
|
||
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;
|
||
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));
|
||
}
|
||
</style> |