<template>
	<view class="page-view">
		<top-return color="#FFF" text="作业统计"></top-return>
		<!-- 背景 -->
		<view class="bg-box1"></view>
		<!-- 页面标题内容 -->
		<view class="top-box">
			<view class="flex-baseline">
				<view class="info-title" style="margin-left: 0;">{{dayTime.split('月')[0]}}</view>
				<view class="info-subtitle">月</view>
				<view class="info-title">{{dayTime.split('月')[1]}}
				</view>
				<view class="info-subtitle">日</view>
				<view class="info-title" style="margin-left: 20rpx;">{{weekTime}}</view>
			</view>
			<view class="flex-baseline">
				<view class="data-subtitle" style="margin-left: 0;">孩子今日共</view>
				<view class="data-title">{{workData.length}}</view>
				<view class="data-subtitle">份作业</view>
			</view>
		</view>
		<!-- 统计列表 -->
		<view class="card-view">
			<view class="card-item" style="width: 100%;">
				<view class="card-title">
					<view class="front-tag"></view>
					<view class="title">近期作业完成率</view>
				</view>
				<view class="chart-box">
					<qiun-data-charts type="column" ontouch="true" :chartData="workChartData[0]"
						tooltipFormat='HomeworkPercent' :canvas2d="true" canvasId="work_chart1" />
				</view>
			</view>

			<view class="card-item" style="width: 100%;">
				<view class="card-title">
					<view class="front-tag"></view>
					<view class="title">近期作业得分率</view>
				</view>
				<view class="chart-box">
					<qiun-data-charts type="area" ontouch="true" :chartData="workChartData[1]"
						tooltipFormat='HomeworkPercent' :canvas2d="true" canvasId="work_chart2" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState('m_children', ['workData']),
			...mapState('m_chart', ['workChartData']),
		},
		data() {
			return {
				dayTime: '',
				weekTime: ''
			};
		},
		onLoad() {
			this.getToday()
		},
		methods: {
			getToday() {
				this.dayTime = (new Date()).format('M-d').replace('-', '月')
				this.weekTime = "星期" + "日一二三四五六".charAt(new Date().getDay());
			}
		}
	}
</script>

<style lang="scss">
	@import '@/subpkg/datalist/top_info.scss';
	.chart-box {
		width: 100%;
		height: 500rpx;
	}
</style>
