<!-- 作业分析报告页面 -->
<template>
	<view class="page-view">
		<top-return color="#FFF"></top-return>
		<!-- 背景 -->
		<view class="bg1"></view>

		<view class="flex-row">
			<view class="flex-column" style="margin: 120rpx 0 0 50rpx;">
				<view class="report-title">作业</view>
				<view class="report-title">分析报告</view>
				<view class="report-subtitle">{{workData[index].work.name}}</view>
			</view>
			<view class="detail-image" :style="{backgroundImage:`url(${image})`}"></view>
		</view>

		<view class="card-view">
			<view class="card-item">
				<view class="title-box">
					<view class="title-tag"></view>
					<view class="title">作业题详情</view>
				</view>
				<view class="table-container">
					<uni-table :loading="tableLoading">
						<!-- 表头行 -->
						<uni-tr>
							<uni-th width="46" align="center">题号</uni-th>
							<uni-th width="12" align="center">题型</uni-th>
							<!-- <uni-th>名次</uni-th> -->
							<uni-th width="25" align="center">作答</uni-th>
							<uni-th width="25" align="center">答案</uni-th>
							<uni-th width="25" align="center">更多</uni-th>
						</uni-tr>
						<uni-tr v-for="(item,index) in reportData.tableData" :key="index" v-if="index < showTableNum">
							<uni-td width="46" align="center">
								<view class="data">{{item.name}}</view>
							</uni-td>
							<uni-td width="12" align="center">
								<view class="subtitle">{{item.type}}</view>
							</uni-td>
							<uni-td width="25" align="center">
								<view v-if="item.answer != '详情'" class="data"
									:style="{color: item.answer === item.rightAnswer?'#23b46c':'#ff5959'}">
									{{item.answer}}
								</view>
								<view class="table-box" v-if="item.answer === '详情'">
									<view class="data" style="color: #4169E1">{{item.answer}}
									</view>
									<view class="t-icon t-icon-you"></view>
								</view>
							</uni-td>
							<uni-td width="25" align="center">
								<view v-if="item.rightAnswer != '详情'" class="data">
									{{item.rightAnswer}}
								</view>
								<view class="table-box" v-if="item.rightAnswer === '详情'">
									<view class="data" style="color: #4169E1">{{item.rightAnswer}}
									</view>
									<view class="t-icon t-icon-you"></view>
								</view>
							</uni-td>
							<uni-td width="25" align="center">
								<view class="table-box">
									<view class="data" style="color: #4169E1;">解析</view>
									<view class="t-icon t-icon-you"></view>
								</view>
							</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view class="table-btn" v-if="reportData.tableData.length > showTableNum">
					<view class="btn-text" @click="showTableList">展开全部作业题</view>
					<u-icon name="arrow-down" color="#616367" @click="showTableList"></u-icon>
				</view>
			</view>

			<view class="card-item">
				<view class="title-box">
					<view class="title-tag"></view>
					<view class="title">知识点分析</view>
					<view class="subsection">
						<u-subsection :list="pointList" :current="pointCurrent" @change="changePoint"
							activeColor="#FFF">
						</u-subsection>
					</view>
				</view>
				<view class="chart-box" style="height: 700rpx;width: 100%;">
					<qiun-data-charts type="bar" ontouch="true" :chartData="reportData.pointChartData"
						:opts="{legend:{position: 'top',float:'left'},xAxis:{format:'xAxisBar'}}" />
				</view>
				<view class="point-analyse">
					<view class="flex-row">
						<view class="analyse-box1">
							<view class="analyse-title">知识点</view>
						</view>
						<view class="analyse-box2">
							<view class="analyse-subtitle">掌握程度</view>
						</view>
					</view>
					<view class="flex-row" v-for="(item,index) in reportData.pointData" :key="index">
						<view class="analyse-box1" style="background-color: #f3f4f9;">
							<view class="point-box">
								<view class="point-title" style="margin-left: 30rpx;">{{item.pointName}}</view>
							</view>
						</view>
						<view class="analyse-box2" style="background-color: #f3f4f9;">
							<view class="circle" :style="{backgroundColor: item.level === '优秀掌握'?'#23b46c': item.level === '部分掌握'? '#f9c752':'#FF6D31'}"></view>
							<view class="point-title">{{item.level}}</view>
							<u-icon name="arrow-right" color="#616367" size="15"></u-icon>
						</view>
					</view>
				</view>
				
				<view class="cutting-line"></view>
				
				<view class="title-box">
					<view class="title-tag"></view>
					<view class="title">诊断分析</view>
				</view>
				
				<view class="analysis-box">
							<view class="subtitle">本次作业孩子在:</view>
							<view class="title" style="color: #ff5959;">[化学能与热能]、[反应速率与化学平衡]</view>
							<view class="subtitle">等知识点上的掌握低于班级平均水平，请重点加强练习。</view>
					</view>
					<view class="subtitle" style="margin:30rpx;font-size: 26rpx;">#结果由系统维度分析得出，仅供参考#</view>
					<view class="btn">
						<view class="btn-text">获取练习方案</view>
					</view>
				</view>
				<view class="card-item">
					<view class="title-box">
						<view class="title-tag"></view>
						<view class="title">作业分趋势</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState('m_children', ['workData'])
		},
		data() {
			return {
				index: '',
				reportData: {
					tableData: [{
						name: '单选题01',
						type: '单选',
						answer: 'A',
						rightAnswer: 'A',
					}, {
						name: '单选题02',
						type: '单选',
						answer: 'B',
						rightAnswer: 'A',
					}, {
						name: '单选题03',
						type: '单选',
						answer: 'C',
						rightAnswer: 'C',
					}, {
						name: '单选题04',
						type: '单选',
						answer: 'A',
						rightAnswer: 'D',
					}, {
						name: '填空题01',
						type: '填空',
						answer: '123',
						rightAnswer: '321',
					}, {
						name: '填空题02',
						type: '填空',
						answer: '正确',
						rightAnswer: '错误',
					}, {
						name: '解答题01',
						type: '解答',
						answer: '详情',
						rightAnswer: '详情',
					}, {
						name: '解答题02',
						type: '解答',
						answer: '详情',
						rightAnswer: '详情',
					}],
					pointChartData: {
						"categories": ["文案居中", "知识点信息", "知识点信息", "知识点信息", "知识点信息", "知识点信息"],
						"series": [{
								"name": "个人得分率",
								"data": [80, 100, 55, 10, 100, 70]
							},
							{
								"name": "班级得分率",
								"data": [70, 90, 65, 50, 80, 50]
							}
						]
					},
					pointData: [{
							pointName: '化学能与热能',
							level: '未掌握'
						},
						{
							pointName: '化学反应速率与化学平衡',
							level: '未掌握'
						},
						{
							pointName: '溶液中得离子平衡',
							level: '部分掌握'
						},
						{
							pointName: '化学能与电能',
							level: '部分掌握'
						},
						{
							pointName: '化学反应原理综合',
							level: '部分掌握'
						},
						{
							pointName: '原子结构与性质',
							level: '优秀掌握'
						},
						{
							pointName: '晶体结构与性质',
							level: '优秀掌握'
						}
					]
				},
				showTableNum: 5,
				tableLoading: false,
				pointList: ['优势', '短板'],
				pointCurrent: 0,
				image: 'https://ouch-cdn2.icons8.com/L7XZ0sgjVoRcfTOPCIQaYDAjSFWSuLHiH__hrCVy_CQ/rs:fit:439:456/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9wbmcvNTM2/L2M3ZmQyOTdiLTgz/ODEtNGQzYy1hNzk1/LWY1MmY3ZWUyMjIw/YS5wbmc.png'
			};
		},
		onLoad(param) {
			this.index = param.index
		},
		methods: {
			showTableList() {
				this.showTableNum = this.reportData.tableData.length
			},
			changePoint(e) {
				this.pointCurrent = e
			}
		},
	}
</script>

<style lang="scss">
	@import 'data_pages.scss';
	@import 'top_info.scss';

	.bg1 {
		position: fixed;
		width: 100%;
		height: 1200rpx;
		background-size: 100%;
		background-repeat: no-repeat;
		background-image: linear-gradient(to top, #f3f4f9, #f9c752);
	}

	.detail-image {
		position: absolute;
		top: 140rpx;
		left: 430rpx;
		width: 330rpx;
		height: 360rpx;
		background-size: 100%; //背景图片自适应
		background-repeat: no-repeat;
		z-index: 50;
	}

	.card-item {
		width: 100%;

		.title-box {
			display: flex;
			align-items: center;
			padding: 20rpx 0;

			.title-tag {
				margin-left: -10rpx;
				margin-right: 20rpx;
				height: 100%;
				width: 20rpx;
				border-radius: 100rpx;
				background-color: #f9c752;
				z-index: 99;
			}

			.title {
				font-size: 35rpx;
				line-height: 50rpx;
			}

			.subsection {
				width: 300rpx;
				height: 100%;
				margin: 0 30rpx 0 auto;

				.u-subsection--button__bar {
					background-color: #f9c752 !important;
				}
			}
		}

		.table-container {
			margin-bottom: 20rpx;

			.uni-table-td {
				padding: 26rpx 10rpx !important;
			}

			.table-box {
				display: flex;
				align-items: center;
				justify-content: center;
				margin-right: -22rpx;
			}

			.data {
				line-height: 28rpx;
				font-size: 28rpx;
				font-weight: bold;
				color: $title;
			}

			.subtitle {
				line-height: 24rpx;
				font-size: 24rpx;
				font-weight: bold;
				color: $subtitle;
			}

			.t-icon {
				width: 30rpx;
				height: 30rpx;
			}
		}

		.table-btn {
			width: 100%;
			height: 50rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-bottom: 40rpx;

			.btn-text {
				font-size: 26rpx;
				font-weight: bold;
				color: #616367;
				margin-right: 10rpx;
			}
		}

		.point-analyse {
			margin: 0 20rpx 40rpx 20rpx;
			border-radius: $border-radius;
			display: flex;
			flex-direction: column;
			border-radius: $border-radius;
			overflow: hidden;

			.analyse-box1 {
				display: flex;
				align-items: center;
				justify-content: center;
				background-color: #f9c752;
				height: 80rpx;
				width: 70%;
				.point-box{
					display: flex;
					align-items: center;
					width: 100%;
					height: 100%;
				}

				.analyse-title {
					line-height: 32rpx;
					font-size: 32rpx;
					font-weight: bold;
					color: #FFF;
				}

				.point-title {
					line-height: 30rpx;
					font-size: 30rpx;
					font-weight: bold;
					color: #616367;
				}
			}

			.analyse-box2 {
				display: flex;
				align-items: center;
				justify-content: center;
				background-color: #f9edc6;
				height: 80rpx;
				width: 30%;
				.circle{
					height: 24rpx;
					width: 24rpx;
					border-radius: 50%;
					margin-right: 10rpx;
				}

				.analyse-subtitle {
					line-height: 32rpx;
					font-size: 32rpx;
					font-weight: bold;
					color: $title;
				}

				.point-title {
					line-height: 28rpx;
					font-size: 28rpx;
					font-weight: bold;
					color: #616367;
				}
			}
		}
		.cutting-line {
			margin: 0 50rpx 20rpx 50rpx;
			height: 1px;
			background-color: #e6e7eb;
		}
		
		.analysis-box {
			display: flex;
			flex-direction: column;
			margin: 10rpx 30rpx;
		
			.title {
				margin: 10rpx;
				line-height: 35rpx;
				font-size: 35rpx;
				color: $color-pink;
			}
		
			.subtitle {
				line-height: 30rpx;
				font-size: 30rpx;
				font-weight: 400;
				color: $title;
			}
		}
		
		.btn {
			display: flex;
			align-items: center;
			justify-content: center;
			height: 80rpx;
			margin: 0 30rpx 30rpx 30rpx;
			background-color: #f9c752;
			border-radius: $border-radius;
			box-shadow: $box-shadow;
		
			.btn-text {
				line-height: 38rpx;
				font-size: 38rpx;
				color: #FFF;
				font-family: YSfont;
			}
		}
	}
</style>
