<template>
	<customNavbarVue title="成绩"></customNavbarVue>
	<custom-scroll-list ref="customChengjiRef" :refreshFn="currentRefreshFn" @tabChange="tabChange"
		:searchBarKey="searchBarKeyName"  :defaultTab="1">
		<template #default="{list}">
			<scroll-list-card-chengji  @lookShijuan="lookShijuan" @lookPaiming="lookPaiming"   v-for="(item,index) in list"
				:key="item.ksId" :data="item"></scroll-list-card-chengji>
		</template>
	</custom-scroll-list>
</template>

<script setup>
	import {
		getKaoshichengjiList,
		getKcchengjiList
	} from "@/api/chengji.js";
	import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
	import customScrollListChengji from "@/components/custom-scroll-list/custom-scroll-list.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: '/subpkgScore/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: '/subpkgScore/pages/score/kaoshiChengjiInfo?kcId=' + data.kcId + '&name=' + data.name
		});
	}
</script>

<style lang="scss">

</style>