<template>
	<z-paging
		ref="pagingRef"
		v-model="data_list"
		@query="queryList"
		:fixed="false"
		:auto="false"
		class="scroll_div"
		empty-view-text="暂无错题"
	>
		<view class="scroll-Y">
			<view class="content" v-for="(item, index) in data_list">
				<subject :item="item" mode="mistake" :isPreview="true" :clearResult="false"></subject>
			</view>
		</view>
		<!-- <view class="max_page detail-main">
		<scroll-view :scroll-y="true" class="scroll-Y" :show-scrollbar="false" @scrolltolower="scrolltolower">
			<view class="content" v-for="(item, index) in data_list">
				<subject :item="item" mode="mistake" :isPreview="true" :clearResult="false"></subject>
			</view>
			<list-no-data v-if="total === 0 && status == 'nomore'">暂无错题</list-no-data>
			<uv-load-more v-if="total !== 0" :status="status" loadmore-text="轻轻上拉加载" :height="30"></uv-load-more>
		</scroll-view>
	</view> -->
	</z-paging>
</template>
<script setup>
	import {onMounted, watch} from 'vue'
	import { queryTraCrsBbsInfoByCrsId } from '@/api/courseDetail.js';
	import { queryTraMistakesCollectionPaging } from '@/api/wrongQuestionRecord.js';
	import Subject from '@/components/examination/subject.vue';
	import useZpaging from '@/composables/useZpaging.js';
	const fetchFunction = (params) => queryTraMistakesCollectionPaging({ isCorrect: 'Y', ...params });
	const { pagingRef, queryList, data_list, reload, search, total, clear } = useZpaging({
		fetchFunction
	});
	const props = defineProps({
		tabIndex: {
			type: Number,
			default: function () {
				return 0;
			}
		},
		currentIndex: {
			type: Number,
			default: function () {
				return 0;
			}
		}
	});
	onMounted(() => {
		watch(
			() => props.currentIndex,
			(newVal) => {
				if (newVal === props.tabIndex && total.value === -1) {
					reload();
				}
			},
			{
				immediate: true
			}
		);
	});
</script>

<style scoped lang="scss">
	.content {
		position: relative;
		margin: 32rpx 30rpx;
		border-radius: 16rpx;
		padding: 34rpx 30rpx 34rpx 36rpx;
		background-color: #fff;
	}
	.scroll-Y {
		background-color: #f1f5fa;
	}
</style>
