<!-- 数据看板-首页 -->
<template>
	<view class="labPage">
		<view class="chart">
			<view class="chart-t">
				<view class="chart-t-li" @click="dateClick(index)" :class="dateIndex==index?'color-A':'color-B'"
					v-for="(item,index) in dateList">
					<view class="chart-t-li-t">{{item.num}}</view>
					<view class="chart-t-li-b">{{item.letterNUm}}</view>
				</view>
			</view>
			<view class="chart-b">
				<qiun-data-charts type="line" :opts="opts" :echartsH5="true" :chartData="chartData" />
			</view>
		</view>
		<view class="statistics">
			<view class="statistics-t">
				<view class="statistics-t-l">实验室总数：</view>
				<view class="statistics-t-r">364 间</view>
			</view>
			<view class="statistics-b">
				<view class="statistics-b-li">
					<view class="statistics-b-li-t color-A">175 间</view>
					<view class="statistics-b-li-b">使用</view>
				</view>
				<view class="line"></view>
				<view class="statistics-b-li">
					<view class="statistics-b-li-t color-B">130 间</view>
					<view class="statistics-b-li-b">空闲</view>
				</view>
				<view class="line"></view>
				<view class="statistics-b-li">
					<view class="statistics-b-li-t color-C">19 间</view>
					<view class="statistics-b-li-b">异常</view>
				</view>
			</view>
		</view>
		<view class="table">
			<uni-card>
				<view style="height: 200px">
					<zb-table :columns="column" :stripe="false" :border="false" :data="dataList"></zb-table>
				</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import {
		config
	} from '@/api/request/config.js'
	import {

	} from '@/pages_basics/api/index.js'
	export default {
		name: "labPage",
		components: {

		},
		data() {
			return {
				dateList: [{
						num: '1',
						letterNUm: 'Mon',
					},
					{
						num: '2',
						letterNUm: 'Tue',
					},
					{
						num: '3',
						letterNUm: 'Wed',
					},
					{
						num: '4',
						letterNUm: 'Thur',
					},
					{
						num: '5',
						letterNUm: 'Fri',
					},
					{
						num: '6',
						letterNUm: 'Sat',
					},
					{
						num: '7',
						letterNUm: 'Sun',
					},
				],
				dateIndex: 0,


				// 查询参数
				queryParams: {
					page: 1,
					pageSize: 10,
				},
				opts: {
					color: ["#0183FA", "#16BF32", "#FF8C00", "#FF0000", ],
					padding: [15, 0, 0, 0],
					enableScroll: false,
					dataLabel: false,
					dataPointShape: false,
					legend: {
						show: false,
						fontColor: '#fff',
					},
					extra: {
						tooltip: {
							legendShape: 'circle',
						},
					},
					xAxis: {
						disableGrid: true,
						fontColor: '#fff',
					},
					yAxis: {
						gridType: "dash",
						dashLength: 2,
						data: [{
							axisLine: false,
							fontColor: '#fff',
						}]
					},
				},
				chartData: {},
				column: [{
						name: 'data1',
						label: '学院单位',
						fixed: true,
						width: 80,
						align: 'center',
					},
					{
						name: 'data2',
						label: '实验人数',
						fixed: true,
						width: 80,
						align: 'center',
					},
					{
						name: 'data3',
						label: '值班人数',
						align: 'center',
					},
					{
						name: 'data4',
						label: '检查次数',
						align: 'center',
					},
					{
						name: 'data5',
						label: '超期设备',
						align: 'center',
					},
				],
				dataList: [{
						data1: '植物保护',
						data2: '499',
						data3: '47',
						data4: '220',
						data5: '137',
					},
					{
						data1: '资源环境',
						data2: '199',
						data3: '7',
						data4: '120',
						data5: '37',
					},
					{
						data1: '生命科学',
						data2: '299',
						data3: '71',
						data4: '10',
						data5: '37',
					},
					{
						data1: '资源环境',
						data2: '199',
						data3: '7',
						data4: '120',
						data5: '37',
					},
					{
						data1: '生命科学',
						data2: '299',
						data3: '71',
						data4: '10',
						data5: '37',
					},
				],
				total: 0,
			}
		},
		created() {
			this.dateIndex = new Date().getDay() - 1;
			console.log(this.dateIndex)
		},
		beforeMount() {

		},
		mounted() {
			this.getServerData();
		},
		methods: {

			dateClick(index) {
				//this.dateIndex = index;
			},
			getServerData() {
				//模拟从服务器获取数据时的延时
				setTimeout(() => {
					//模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
					let res = {
						categories: ["0:00", "6:00", "12:00", "18:00", "24:00"],
						series: [{
								name: "实验人数",
								data: [35, 8, 25, 37, 4, 20]
							},
							{
								name: "值日人数",
								data: [70, 40, 65, 100, 44, 68]
							},
							{
								name: "检查次数",
								data: [100, 80, 95, 150, 112, 132]
							},
							{
								name: "超期设备数",
								data: [30, 10, 25, 10, 82, 122]
							}
						]
					};
					this.chartData = JSON.parse(JSON.stringify(res));
				}, 500);
			},
		},
	}
</script>
<style lang="stylus" scoped>
	.labPage {
		height: 100%;
		width: 100%;
		background: #363744;
		padding: 20rpx 30rpx 36rpx;
		box-sizing: border-box;

		.chart {
			width: 690rpx;
			height: 640rpx;
			background: #3E414F;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			padding: 34rpx 30rpx 26rpx;
			box-sizing: border-box;

			.chart-t {
				display: flex;
				justify-content: space-between;

				.chart-t-li {
					width: 76rpx;
					height: 100rpx;

					.chart-t-li-t {
						font-weight: 400;
						font-size: 30rpx;

						line-height: 42rpx;
						text-align: center;
						margin-top: 8rpx;
					}

					.chart-t-li-b {
						font-weight: 400;
						font-size: 28rpx;

						line-height: 39rpx;
						text-align: center;
						margin-top: 4rpx;
					}
				}

				.color-A {
					background: #0183FA;
					border-radius: 10rpx 10rpx 10rpx 10rpx;

					.chart-t-li-t {
						color: #FFFFFF;
					}

					.chart-t-li-b {
						color: #FFFFFF;
					}
				}

				.color-B {
					background: none;

					.chart-t-li-t {
						color: #FFFFFF;
					}

					.chart-t-li-b {
						color: #FFFFFF;
					}
				}
			}

			.chart-b {
				width: 632rpx;
				height: 444rpx;
				margin-top: 34rpx;
			}
		}

		.statistics {
			width: 690rpx;
			height: 241rpx;
			background: #3E414F;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin-top: 20rpx;

			.statistics-t {
				height: 100rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1rpx solid #52545F;
				padding: 0 42rpx 0 38rpx;
				box-sizing: border-box;

				.statistics-t-l {
					font-weight: 400;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 45rpx;
				}

				.statistics-t-r {
					font-weight: 400;
					font-size: 36rpx;
					color: #FFFFFF;
					line-height: 50rpx;
				}
			}

			.statistics-b {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.statistics-b-li {
					flex: 1;
					text-align: center;

					.statistics-b-li-t {
						font-weight: 400;
						font-size: 36rpx;
						line-height: 50rpx;
						margin-top: 28rpx;
					}

					.statistics-b-li-b {
						font-weight: 400;
						font-size: 28rpx;
						color: #FFFFFF;
						line-height: 39rpx;
						margin-top: 9rpx;
					}
				}

				.line {
					width: 2rpx;
					height: 30rpx;
					background: #D8D8D8;
				}

				.color-A {
					color: #FF8C00;
				}

				.color-B {
					color: #26C736;
				}

				.color-C {
					color: #FF0000;
				}
			}
		}

		.table {
			width: 690rpx;
			margin-top: 20rpx;
			border-radius: 20rpx 20rpx 0 0;
			overflow: hidden;
		}
	}
</style>
