<!-- 数据看板-预警处置 -->
<template>
	<view class="warningDispose">
		<!-- <view class="chart">
			<img class="chart-bg" :src="imagesUrl('dataBoard/dataBoard-icon4.png')">
			<view class="chart-n">
				<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">
					<view class="chart-b-li" v-for="(item,index) in deptList" :key="index">
						<view>{{item.deptSortName}}：{{item.todayTotal}}</view>
						<img v-if="item.todayTotal==0" :src="imagesUrl('dataBoard/img_xyzc_bg@1x.png')">
						<img v-if="item.todayTotal!=0" :src="imagesUrl('dataBoard/img_xyyc_bg@1x.png')">
					</view>
				</view>
			</view>
		</view> -->
		<view class="statistics">
			<view class="statistics-b">
				<view class="statistics-b-li">
					<view class="statistics-b-li-t">{{yesterdayTotal}}</view>
					<view class="statistics-b-li-b">昨日预警处置数</view>
				</view>
				<view class="line"></view>
				<view class="statistics-b-li">
					<view class="statistics-b-li-t">{{todayTotal}}</view>
					<view class="statistics-b-li-b">今日预警处置数</view>
				</view>
				<view class="line"></view>
				<view class="statistics-b-li">
					<view class="statistics-b-li-t-tow">
						<text
							:class="rateType == 0?'color-C':(rateType == 1?'color-B':(rateType == 2?'color-A':''))">{{rate}}</text>
						<img :src="imagesUrl('dataBoard/dataBoard-icon2.png')" style="margin-left:10rpx;" v-if="rateType == 2">
						<img :src="imagesUrl('dataBoard/dataBoard-icon3.png')" style="margin-left:10rpx;transform: rotate(180deg);"
							v-if="rateType == 1">
					</view>
					<view class="statistics-b-li-b">环比增长</view>
				</view>
			</view>
		</view>
		<view class="table">
			<uni-card>
				<view style="height: 400px">
					<zb-table :cell-style="handleStyle" :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 {
		reportAppStatisticsWarningHandle
	} from '@/pages/api/index.js'
	export default {
		name: "warningDispose",
		components: {

		},
		data() {
			return {
				dateList: [],
				dateIndex: 6,
				deptList: [],
				// 查询参数
				queryParams: {
					page: 1,
					pageSize: 10,
				},
				column: [{
						type: 'index',
						label: '排行',
						fixed: true,
						width: 60,
						align: 'center',
					},
					{
						name: 'deptSortName',
						label: '学院单位',
						fixed: true,
						width: 80,
						align: 'center',
					},
					{
						name: 'handleTotal',
						label: '总数',
						align: 'center',
					},
					{
						name: 'yesterdayTotal',
						label: '昨日',
						align: 'center',
					},
					{
						name: 'todayTotal',
						label: '今日',
						align: 'center',
					},
					{
						name: 'rate',
						label: '环比',
						align: 'center',
					},
				],
				dataList: [],
				total: 0,

				todayTotal: 0,
				yesterdayTotal: 0,
				rate: 0,
				rateType: 0,
			}
		},
		created() {

		},
		beforeMount() {

		},
		mounted() {
			this.getCurrentDate();
		},
		methods: {
			handleStyle(val) {
				if (val.column.name == 'rate') {
					// console.log('val======>', val.row);
					if (val.row.rate.indexOf('-') != -1) {
						return {
							'color': '#2EA805',
						}
					} else if (val.row.rate.indexOf('+') != -1){
						return {
							'color': '#FF0000',
						}
					}else {
						return {
							'color': '#FFFFFF',
						}
					}
				}
			},
			dateClick(index) {
				this.dateIndex = index;
				this.reportAppStatisticsWarningHandle();
			},
			getCurrentDate() {
				// 获取当前日期和星期
				let date = new Date();
				let weekdays = ["Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"];
				let weekdaysTow = ["7", "1", "2", "3", "4", "5", "6"];
				// 获取星期几的索引
				let dayOfWeekIndex = date.getDay();

				// 获取当天的日期和星期
				let dayOfMonth = date.getDate();
				let month = date.getMonth() + 1; // 月份从0开始，需要加1
				let year = date.getFullYear();

				// 输出当前日期和星期
				// console.log("Today is " + month + "/" + dayOfMonth + "/" + year + ", " + weekdays[dayOfWeekIndex] + ".");

				// 获取接下来一周的每天日期和星期
				let nextDays = [];
				for (let i = 0; i < 7; i++) {
					let nextDate = new Date(date.getTime() - (i * 24 * 60 * 60 * 1000)); // 加上一天的时间差
					nextDays.push({
						date: nextDate.getDate(),
						month: nextDate.getMonth() + 1,
						year: nextDate.getFullYear(),
						dayOfWeek: weekdays[nextDate.getDay()],
						dayOfWeekTow: weekdaysTow[nextDate.getDay()],
					});

				}

				// 输出接下来一周的每天日期和星期
				for (let i = 0; i < 7; i++) {
					this.dateList.push({
						num: nextDays[i].dayOfWeekTow,
						letterNUm: nextDays[i].dayOfWeek,
						format: nextDays[i].year + "-" + nextDays[i].month + "-" + nextDays[i].date
					})
				}
				this.dateList = this.dateList.reverse();
				this.reportAppStatisticsWarningHandle();
			},
			//预警处置
			async reportAppStatisticsWarningHandle(planId) {
				let self = this;
				const {
					data
				} = await reportAppStatisticsWarningHandle({
					'date': this.dateList[this.dateIndex].format
				});
				if (data.code == 200) {
					this.deptList = data.data.warningList;
					this.dataList = data.data.warningScatterList;
					this.$set(self, 'todayTotal', data.data.warning.todayTotal);
					this.$set(self, 'yesterdayTotal', data.data.warning.yesterdayTotal);
					if (data.data.warning.rate.indexOf('-') != -1) {
						this.$set(self, 'rateType', 1);
					} else if (data.data.warning.rate.indexOf('+') != -1) {
						this.$set(self, 'rateType', 2);
					} else {
						this.$set(self, 'rateType', 0);
					}
					this.$set(self, 'rate', data.data.warning.rate);
				}
			},
		},
	}
</script>

<style lang="stylus" scoped>
	.warningDispose {
		height: 100%;
		width: 100%;
		background: #363744;
		padding: 20rpx 0rpx 36rpx;
		box-sizing: border-box;

		.chart {
			width: 750rpx;
			height: 500rpx;

			position: relative;

			.chart-bg {
				width: 750rpx;
				height: 500rpx;
				position: absolute;
				z-index: 100;
			}

			.chart-n {
				padding: 34rpx 0rpx 26rpx;
				box-sizing: border-box;
				position: absolute;
				z-index: 200;

				.chart-t {

					display: flex;
					justify-content: space-between;
					margin: 0 50rpx;
					width: 650rpx;

					.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: 690rpx;
					height: 350rpx;
					position: absolute;

					.chart-b-li {
						position: absolute;
						z-index: 300;
						width: 200rpx;
						height: 46rpx;

						>img {
							width: 200rpx;
							height: 46rpx;
							position: absolute;
							z-index: 400;
						}

						>view {
							padding-left: 16rpx;
							box-sizing: border-box;
							width: 200rpx;
							height: 46rpx;
							position: absolute;
							z-index: 500;
							font-weight: 400;
							font-size: 24rpx;
							color: #FFFFFF;
							line-height: 46rpx;
							text-align: left;
						}

					}

					.chart-b-li:nth-child(1) {
						top: 20rpx;
						left: 30rpx;
					}

					.chart-b-li:nth-child(2) {
						top: 20rpx;
						left: 260rpx;
					}

					.chart-b-li:nth-child(3) {
						top: 20rpx;
						left: 490rpx;
					}

					.chart-b-li:nth-child(4) {
						top: 80rpx;
						left: 30rpx;
					}

					.chart-b-li:nth-child(5) {
						top: 80rpx;
						left: 260rpx;
					}

					.chart-b-li:nth-child(6) {
						top: 80rpx;
						left: 490rpx;
					}

					.chart-b-li:nth-child(7) {
						top: 140rpx;
						left: 30rpx;
					}

					.chart-b-li:nth-child(8) {
						top: 140rpx;
						left: 260rpx;
					}

					.chart-b-li:nth-child(9) {
						top: 140rpx;
						left: 490rpx;
					}

					.chart-b-li:nth-child(10) {
						top: 200rpx;
						left: 30rpx;
					}

					.chart-b-li:nth-child(11) {
						top: 200rpx;
						left: 260rpx;
					}

					.chart-b-li:nth-child(12) {
						top: 200rpx;
						left: 490rpx;
					}

					.chart-b-li:nth-child(13) {
						top: 260rpx;
						left: 30rpx;
					}

					.chart-b-li:nth-child(14) {
						top: 260rpx;
						left: 260rpx;
					}

					.chart-b-li:nth-child(15) {
						top: 260rpx;
						left: 490rpx;
					}

					.chart-b-li:nth-child(16) {
						top: 320rpx;
						left: 30rpx;
					}

					.chart-b-li:nth-child(17) {
						top: 320rpx;
						left: 260rpx;
					}

					.chart-b-li:nth-child(18) {
						top: 320rpx;
						left: 490rpx;
					}

					.chart-b-li:nth-child(19) {
						top: 380rpx;
						left: 30rpx;
					}

					.chart-b-li:nth-child(20) {
						top: 380rpx;
						left: 260rpx;
					}

					.chart-b-li:nth-child(21) {
						top: 380rpx;
						left: 490rpx;
					}
				}
			}


		}

		.statistics {
			width: 750rpx;
			height: 120rpx;
			background: #3E414F;

			.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;
						color: #FFFFFF;
						line-height: 50rpx;
						margin-top: 10rpx;

					}

					.statistics-b-li-t-tow {
						margin-top: 10rpx;
						display: flex;
						justify-content: center;
						align-items: center;

						>text {
							font-weight: 400;
							font-size: 28rpx;
							line-height: 50rpx;
						}

						>img {
							width: 22rpx;
							height: 28rpx;
						}
					}

					.color-A {
						color: #FF0000;
					}

					.color-B {
						color: #2EA805;
					}
					.color-C {
						color: #FFFFFF;
					}


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

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

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