auditRecord2.vue 8 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"
						v-for="(item, index) in list"
						:key="index"
					>
						<!-- 卡片头部:日期 + 状态 -->
						<view class="card-header">
							<view class="date">
								<image :src="config.baseUrl_api + '/fs/static/calendar@2x.png'" v-if="item.commitTime" mode="widthFix" style="width:30rpx;height:30rpx;"/>
								<text class="date-text" v-if="item.commitTime">{{ item.commitTime }}</text>
							</view>
							<view class="status-tags">
								<view class="status-tag" :class="getStatusClass(item.status)">
									{{ item.statusStr || '待提交' }}
								</view>
							</view>
						</view>

						<!-- 基本信息 -->
						<view class="info-row">
							<text class="label">缴费编号:</text>
							<text class="value">{{ item.examCode || '--' }}</text>
						</view>
						<view class="info-row">
							<text class="label">缴费名称:</text>
							<text class="value">{{ item.name || '--' }}</text>
						</view>
						<view class="info-row">
							<text class="label">上报单位:</text>
							<text class="value">{{ item.memberName || '--' }}</text>
						</view>

						<!-- 费用信息区 -->
						<view class="info-section">
							<view class="info-item">
								<text class="item-label">考试人数</text>
								<text class="item-value">{{ item.totalNum || 0 }}</text>
							</view>
							<view class="info-line"></view>
							<view class="info-item">
								<text class="item-label">总金额</text>
								<text class="item-value">¥{{ (Number(item.price) || 0).toFixed(2) }}</text>
							</view>
							<view class="info-line"></view>
							<view class="info-item">
								<text class="item-label">支付方式</text>
								<text class="item-value">民生付</text>
							</view>
						</view>

						<!-- 审核信息 -->
						<view class="price-section">
							<view class="price-row">
								<text class="price-label">提交日期</text>
								<text class="price-value">{{ item.commitTime || '--' }}</text>
							</view>
							<view class="price-row">
								<text class="price-label">审核日期</text>
								<text class="price-value">{{ item.handleDate || '--' }}</text>
							</view>
						</view>
					</view>
				</view>

				<!-- 空状态 -->
				<view v-else class="empty">
					<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: #f5f7fa;
	display: flex;
	flex-direction: column;
}

// Tab
.tab-bar {
	display: flex;
	background: #fff;
	border-bottom: 1rpx solid #eee;
	flex-shrink: 0;

	.tab-item {
		flex: 1;
		text-align: center;
		padding: 24rpx 0;
		font-size: 28rpx;
		color: #666;
		position: relative;

		&.active {
			color: #e4393c;
			font-weight: 500;

			&::after {
				content: '';
				position: absolute;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);
				width: 60rpx;
				height: 4rpx;
				background: linear-gradient(90deg, #FF755A, #F51722);
				border-radius: 2rpx;
			}
		}
	}
}

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

.order-list {
	padding: 20rpx;
}

.order-card {
	background: #fff;
	margin-bottom: 20rpx;
	padding: 24rpx;
	border-radius: 12rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	border-top: 6rpx solid transparent;
	background-clip: padding-box, border-box;
	background-origin: padding-box, border-box;
	background-image: linear-gradient(#fff, #fff), linear-gradient(90deg, #FF755A, #F51722);
}

.card-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-bottom: 20rpx;
	margin-bottom: 20rpx;
	border-bottom: 1rpx dashed #eee;

	.date {
		display: flex;
		align-items: center;
		gap: 8rpx;

		.date-text {
			font-size: 26rpx;
			color: #666;
		}
	}

	.status-tags {
		display: flex;
		gap: 10rpx;
	}

	.status-tag {
		font-size: 22rpx;
		padding: 6rpx 16rpx;
		border-radius: 20rpx;

		&.success {
			background: #e6f7ef;
			color: #52c41a;
		}

		&.danger {
			background: #fff1f0;
			color: #ff4d4f;
		}

		&.pending {
			background: #f5f5f5;
			color: #999;
		}

		&.warning {
			background: #fff7e6;
			color: #faad14;
		}
	}
}

.info-row {
	display: flex;
	align-items: center;
	margin-bottom: 16rpx;
	font-size: 26rpx;

	.label {
		color: #999;
		flex-shrink: 0;
		min-width: 140rpx;
	}

	.value {
		color: #333;
		word-break: break-all;
	}
}

.info-section {
	display: flex;
	align-items: center;
	background: #f3f6fc;
	padding: 16rpx 20rpx;
	margin: 16rpx 0;
	border-radius: 8rpx;

	.info-item {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;

		.item-label {
			font-size: 24rpx;
			color: #999;
		}

		.item-value {
			font-size: 28rpx;
			color: #333;
			font-weight: 500;
			margin-top: 8rpx;
		}
	}

	.info-line {
		width: 1rpx;
		height: 60rpx;
		background: #ddd;
	}
}

.price-section {
	border-top: 1rpx dashed #eee;
	padding-top: 16rpx;
	margin-top: 8rpx;

	.price-row {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 8rpx 0;

		.price-label {
			font-size: 26rpx;
			color: #333;
		}

		.price-value {
			font-size: 26rpx;
			color: #666;
		}
	}
}

.empty {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 120rpx 0;

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

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