auditRecord2.vue 7.56 KB
<template>
	<view class="order-page">
		<!-- 顶部Tab -->
		<view class="tab-bar">
			<view
				v-for="(tab, index) in statusTabs"
				:key="index"
				class="tab-item"
				:class="{ active: currentTab === index }"
				@click="switchTab(index)"
			>
				{{ tab.name }}
			</view>
		</view>

		<!-- 列表 -->
		<scroll-view
			scroll-y
			class="order-list-scroll"
			:show-scrollbar="false"
			@scrolltolower="loadMore"
			lower-threshold="200"
		>
			<view class="order-list">
				<view v-if="list.length > 0">
					<view
						class="order-card-new"
						v-for="(item, index) in list"
						:key="index"
					>
						<view class="card-header">
							<view class="date">
								<view class="data-header">
									<text class="member-label">{{ item.examCode || '--' }}</text>
									<!-- <text class="value ml10">{{ item.examCode || '--' }}</text> -->
								</view>
								<text class="status-tag" :class="getStatusClass(item.status)">
									{{ item.statusStr || '待提交' }}
								</text>
							</view>
						</view>

						<view class="member-time">
							<view class="label">
								<text class="star"></text>
								{{ item.name || '--' }}
							</view>
							<view class="price">
								<view>{{ (Number(item.price) || 0).toFixed(2) }}</view>
								<view class="person">{{ item.totalNum || 0 }}</view>
							</view>
						</view>

						<view class="detail-section">
							<view class="detail-row">
								<text class="detail-label">上报单位</text>
								<text class="detail-value">{{ item.memberName || '--' }}</text>
							</view>
							<view class="detail-row">
								<text class="detail-label">提交日期</text>
								<text class="detail-value">{{ item.commitTime || '--' }}</text>
							</view>
							<view class="detail-row">
								<text class="detail-label">审核日期</text>
								<text class="detail-value">{{ item.handleDate || '--' }}</text>
							</view>
						</view>
					</view>
				</view>

				<!-- 空状态 -->
				<view v-else class="empty">
					 <image class="empty-img" mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
					<text class="empty-text">暂无审核记录</text>
				</view>

				<!-- 加载/无更多提示 -->
				<view class="loading-tip" v-if="loading">加载中...</view>
				<view class="no-more" v-if="!loading && !hasMore && list.length > 0">没有更多了</view>
			</view>
		</scroll-view>
	</view>
</template>

<script setup>
	import { ref, onMounted } from 'vue';
	import * as api from '@/common/api.js';
	import config from '@/config.js'

	// 状态Tab配置
	const statusTabs = [
		{ name: '全部', type: '' },
		{ name: '审批中', type: '1' },
		{ name: '审批通过', type: '2' },
		{ name: '审批拒绝', type: '3' }
	];

	const currentTab = ref(0);
	const list = ref([]);
	const loading = ref(false);
	const hasMore = ref(true);
	const pageNum = ref(1);
	const pageSize = ref(10);

	onMounted(() => {
		initData();
	});

	// 切换Tab
	const switchTab = (index) => {
		currentTab.value = index;
		pageNum.value = 1;
		list.value = [];
		hasMore.value = true;
		initData();
	};

	// 上拉加载更多
	const loadMore = () => {
		console.log("触发上拉加载");
		if (loading.value || !hasMore.value) return;
		pageNum.value++;
		initData();
	};

	// 获取列表数据
	const initData = async () => {
		loading.value = true;
		try {
			const params = {
				pageNum: pageNum.value,
				pageSize: pageSize.value,
				status: statusTabs[currentTab.value].type,
				auditSelectType: '1'
			};
			const res = await api.getLevelList(params);
			console.log("接口返回:", res);

			if (!res || !res.rows || res.rows.length === 0) {
				hasMore.value = false;
				loading.value = false;
				return;
			}

			// 第一页覆盖,后面页数追加
			if (pageNum.value === 1) {
				list.value = res.rows;
			} else {
				list.value.push(...res.rows);
			}

			// 关键修复:只要返回条数 < pageSize 就说明没有更多了
			hasMore.value = res.rows.length === pageSize.value;
		} catch (e) {
			console.error('加载失败:', e);
			uni.showToast({ title: '加载失败', icon: 'none' });
			hasMore.value = false;
		} finally {
			loading.value = false;
		}
	};

	// 状态样式
	const getStatusClass = (status) => {
		const map = { '1': 'pending', '2': 'success', '3': 'danger', '4': 'warning' };
		return map[status] || '';
	};
</script>

<style lang="scss" scoped>
.order-page {
	height: 100vh;
	background: #ededf0;
	display: flex;
	flex-direction: column;
}

// Tab
.tab-bar {
	display: flex;
	flex-shrink: 0;
	padding: 22rpx 32rpx 4rpx;
	background: #ededf0;

	.tab-item {
		flex: 1;
		text-align: center;
		padding: 0 0 14rpx;
		font-size: 30rpx;
		color: #666;
		position: relative;
		font-weight: bold;

		&.active {
			color: #c30d23;
			font-weight: bold;

			&::after {
				content: '';
				position: absolute;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);
				width: 72rpx;
				height: 4rpx;
				background: #c30d23;
				border-radius: 2rpx;
			}
		}
	}
}

// 滚动列表容器 —— 这里是关键修复
.order-list-scroll {
	flex: 1;
	height: 0;
	min-height: 0;
	overflow: hidden;
	background: #ededf0;
}

.order-list {
	min-height: 100%;
	box-sizing: border-box;
	padding: 0 24rpx calc(120rpx + env(safe-area-inset-bottom));
}

.order-card-new {
	background: #fff;
	margin-bottom: 22rpx;
	padding: 22rpx 18rpx 18rpx;
	border-radius: 18rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	display: flex;
	flex-direction: column;

	.card-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 10rpx;

		.date {
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;
			gap: 8rpx;
			font-size: 26rpx;
		}

		.data-header {
			display: flex;
			align-items: center;
			min-width: 0;
		}

		.member-label {
			color: #c30d23;
			font-size: 28rpx;
			font-weight: bold;
			flex-shrink: 0;
		}

		.value {
			color: #000;
			font-size: 27rpx;
			font-weight: bold;
			max-width: 360rpx;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}

		.ml10 {
			margin-left: 10rpx;
		}

		.status-tag {
			font-size: 24rpx;
			color: #999;
			flex-shrink: 0;

			&.success {
				color: #52c41a;
			}

			&.danger {
				color: #ff4d4f;
			}

			&.pending {
				color: #faad14;
			}

			&.warning {
				color: #999;
			}
		}
	}

	.member-time {
		width: 100%;
		display: flex;
		justify-content: space-between;
		padding-bottom: 8rpx;

		.label {
			max-width: 480rpx;
			color: #555;
			font-size: 26rpx;
			font-weight: 700;
			line-height: 1.4;
			word-break: break-all;
		}

		.star {
			color: #777;
			font-size: 26rpx;
		}

		.price {
			min-width: 150rpx;
			color: #333;
			font-size: 26rpx;
			font-weight: 500;
			text-align: right;
			margin-left: 20rpx;

			.person {
				font-size: 24rpx;
				color: #999;
				text-align: right;
				margin-top: 4rpx;
			}
		}
	}

	.detail-section {
		background: #f3f6fc;
		border-radius: 18rpx;
		padding: 10rpx 18rpx;
		margin-top: 10rpx;
	}

	.detail-row {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		padding: 8rpx 0;
		gap: 24rpx;
	}

	.detail-label {
		font-size: 26rpx;
		color: #666;
		flex-shrink: 0;
	}

	.detail-value {
		font-size: 26rpx;
		color: #333;
		text-align: right;
		word-break: break-all;
	}
}

.empty {
	padding: 160rpx 0 80rpx;
	display: flex;
	flex-direction: column;
	align-items: center;

	.empty-img {
		width: 240rpx;
		height: 180rpx;
	}

	.empty-text {
		margin-top: 20rpx;
		color: #999;
		font-size: 28rpx;
	}
}


.loading-tip,
.no-more {
	text-align: center;
	padding: 20rpx 0;
	color: #999;
	font-size: 26rpx;
}
</style>