<template>
	<custom-scroll-list-chengji ref="customChengjiRef" :refreshFn="currentRefreshFn" @tabChange="tabChange"
		:searchBarKey="searchBarKeyName" :tabList="tabData" :defaultTab="1">
		<template #default="{list}">
			<scroll-list-card-chengji v-show="currentTab =='1'" @lookShijuan="lookShijuan" @lookPaiming="lookPaiming"   v-for="(item,index) in list"
				:key="item.ksId" :data="item"></scroll-list-card-chengji>
			<scroll-list-card-kechengji v-show="currentTab =='2'" @click="kechengChengjiClick(item)"
				v-for="(item,index) in list" :key="item.ksId" :data="item"></scroll-list-card-kechengji>
		</template>
	</custom-scroll-list-chengji>
</template>

<script setup>
	import {
		getKaoshichengjiList,
		getKcchengjiList
	} from "@/api/chengji.js";
	import customScrollListChengji from "@/components/custom-scroll-list/custom-scroll-list-chengji.vue";
	import {
		onLoad,
		onReady,

	} from "@dcloudio/uni-app"
	import {
		reactive,
		ref,
		computed
	} from "vue";
	let currentTab = ref('1')
	let searchBarKeyName = ref('ksName')
	let customChengjiRef = ref(null)
	const tabData = [{
		label: "考试成绩",
		value: 1,
	}, {
		label: "课程成绩",
		value: 2
	}]
const currentRefreshFn = computed(() => 
  currentTab.value == '1' ? getKaoshichengjiList : getKcchengjiList
)
	function tabChange(data) {
		currentTab.value = data.value
		if (currentTab.value == 1) {
			searchBarKeyName.value = 'ksName'
		} else {
			searchBarKeyName.value = 'kcName'
		}
	//	customChengjiRef.value.tabChangeSearch(data)
	}
	const lookShijuan = (data) => {
		console.log('data',data);
		uni.navigateTo({
			url: '/pages/score/kaoshiChengjiInfo?hisId=' + data.hisId + '&name=' + data.ksName+ '&userScore=' + data.userScore+ '&ksScore=' + data.ksScore
		});
	}
	const lookPaiming = (data) => {
		console.log('datalookPaiming',data);
		uni.navigateTo({
			url: '/pages/score/kaoshiChengjiInfo?kcId=' + data.kcId + '&name=' + data.name
		});
	}
</script>

<style lang="scss">

</style>