<template>
	<view class="card card2">
		<view class="chartTab">
			<view class="h3">{{ tit }}</view>
			<view class="btn_row">
				<view class="btn" @click="changeChart(1)" :class="{bg: currentChart==1}">曲线</view>
				<view class="btn" @click="changeChart(2)" :class="{bg: currentChart==2}">明细</view>
			</view>
		</view>
		<view class="tip">近30次科目{{ subject==1? '一': '四'}}模拟考试成绩</view>
		<view class="" v-if="listData.length">
			<view class="con" v-if="currentChart==1">
				<columnChart :chartData="chartData" :key="tit"></columnChart>
				<view class="tips">按住可左右滑动查看更多成绩</view>
			</view>
			<view class="con" v-if="currentChart==2">
				<view class="tables">
					<view class="fristTab li">
						<view class="item">考试成绩</view>
						<view class="item">考试用时</view>
						<view class="item">考试时间</view>
					</view>
					<view class="li" v-for="(item,index) in listData" :key="index">
						<view class="item">{{item.score}}分</view>
						<view class="item">{{item.useTime}}</view>
						<view class="item">{{item.startTime}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-else>
			<nodata>暂无考试记录</nodata>
			<view class="btnE">
				<oneBtn text="去考试" @oneBtnClick="$goPage(url)"></oneBtn>
			</view>
		</view>
		
	</view>
	
</template>

<script setup>
	import { ref } from 'vue'
	defineProps({
		tit: {
			type: String,
			default: ''
		},
		chartData: {
			type: Object,
			default: {}
		},
		listData: {
			type: Array,
			default: []
		},
		subject: {
			type: Number,
			default: 1
		},
		url: {
			type: String,
			default: '/pages/exercises/examSubjiect1/examSubjiect1'
		}
	})
	
	const currentChart = ref(1)
	function changeChart(num) {
		currentChart.value = num
	}
</script>

<style scoped lang="scss">
	.tip {
		font-size: 24rpx;
		color: #ccc;
		padding: 10rpx 0 30rpx;
	}
	.tips {
			width: 360rpx;
			height: 48rpx;
			background: #DCE7FF;
			border-radius: 24rpx;
			font-size: 24rpx;
			color: $themC;
			text-align: center;
			line-height: 48rpx;
			margin-top: 30rpx;
		}
		.chartTab {
			display: flex;
			justify-content: space-between;
		  .btn_row {
			  display: flex;
			  width: 170rpx;
			  height: 44rpx;
			  border-radius: 8rpx;
			  overflow: hidden;
			  border: 1px solid $themC;
		    .btn.bg {
				background: #3776FF;
				color: #fff;
		    }
		
		    .btn {
				color: $themC;
				text-align: center;
				font-size: 28rpx;
				flex: 1;
		    }
		  }
		}
		.tables {
			width: 100%;
		  .fristTab.li {
			  background: #F4F4F4;
			  border-radius: 8rpx 8rpx 0 0;
		    .item {
				color: $themC;
		    }
		  }
		
		  .li {
			  height: 76rpx;
			  line-height: 76rpx;
			  border-bottom: 1rpx solid #F4F4F4;
			  display: flex;
		    .item {
				text-align: center;
				flex: 1;
				font-size: 28rpx;
		    }
		  }
		}
	
	.btnE {
		width: 240rpx;
		margin: 30rpx auto 60rpx auto;
	}
</style>