<!-- 数据看板-危化品 -->
<template>
	<view class="hazardSources">
		<view class="statistics">
			<view class="statistics-t">
				<view class="statistics-t-l">危化品总数：</view>
				<view class="statistics-t-r">{{totalNumber}} </view>
			</view>
			<view class="statistics-b">
				<view class="statistics-b-li">
					<view class="statistics-b-li-t color-A">{{totalAmount}} kg</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">{{newTotal}} </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">{{todayAdded}} kg</view>
					<view class="statistics-b-li-b">今日新增量</view>
				</view>
			</view>
		</view>
		<view class="small-title">
			<view class="small-title-l">危化品存量排行TOP5</view>
			<!-- <img class="small-title-r" src="@/pages/images/icon_wdwg_gd.png"> -->
		</view>
		<view class="chart">
			<view class="chart-t">
				<qiun-data-charts :canvas2d="true" type="funnel" :opts="opts" :echartsH5="true" :chartData="chartData" />
			</view>
			<view class="chart-b" v-for="(item,index) in dataList" :key="index">
				<view :class="index==0?'chartOne':(index==1?'chartTow':(index==2?'chartThree':'chartFive'))">
					{{index+1}}
				</view>
				<view>{{item.deptSortName}}</view>
				<view>总数{{item.totalNumber}}</view>
				<view>|</view>
				<view>今日新增{{item.newTotal}}</view>
				<img src="@/pages/images/dataBoard/dataBoard-icon2.png">
			</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 {
		reportAppStatisticsChemicalStockSort
	} from '@/pages/api/index.js'
	export default {
		name: "hazardSources",
		components: {

		},
		data() {
			return {
				opts: {
					color: ['#FF0000', '#D40000', '#FF5900', '#FF9900', '#FF9900'],
					legend: {
						show: false,
					},
					padding: [15, 85, 6, 5],
					enableScroll: false,
					extra: {
						funnel: {
							activeOpacity: 0.3,
							activeWidth: 10,
							border: false,
							borderWidth: 2,
							borderColor: "#FFFFFF",
							fillOpacity: 1,
							labelAlign: "right",
							type: "pyramid"
						}
					}
				},
				chartData: {},
				totalNumber:0,
				totalAmount:0,
				newTotal:0,
				todayAdded:0,
				// 查询参数
				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: 'totalNumber',
						label: '总数',
						align: 'center',
					},
					{
						name: 'newTotal',
						label: '总量',
						align: 'center',
					},
					{
						name: 'todayAdded',
						label: '今日新增',
						align: 'center',
					},
				],
				dataList: [],
				total: 0,
			}
		},
		created() {

		},
		beforeMount() {

		},
		mounted() {
			this.reportAppStatisticsChemicalStockSort();
		},
		methods: {
			dateClick(index) {
				this.dateIndex = index;
			},
			async reportAppStatisticsChemicalStockSort() {
				let self = this;
				const {
					data
				} = await reportAppStatisticsChemicalStockSort();
				if (data.code == 200) {
					this.$set(self, 'totalNumber', data.data.totalNumber);
					this.$set(self, 'totalAmount', data.data.totalAmount);
					this.$set(self, 'newTotal', data.data.newTotal);
					this.$set(self, 'todayAdded', data.data.todayAdded);
					//列表
					this.dataList=data.data.chemicalStockSubs;
					//图表
					if(data.data.chemicalStockSubs[0]){
						let list=[];
						data.data.chemicalStockSubs.forEach(function(item,index){
							if(index<5){
								list.push({
								"name": item.deptSortName,
								"value": item.totalNumber,
								"labelText": "总量"+item.totalNumber+'kg',
								"textColor": "#fff",
							})
							}
						})
						let res = {
							series: [{
								data:list
							}]
						};
						this.chartData = JSON.parse(JSON.stringify(res));
					}
					
				}
			},	
			
		},
	}
</script>

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

		.small-title {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.small-title-l {
				font-weight: 400;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 45rpx;
				text-align: left;
				margin: 28rpx 0;
			}

			.small-title-r {
				width: 15rpx;
				height: 18rpx;
			}

		}

		.chart {
			width: 690rpx;
			// height: 850rpx;
			background: #3E414F;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			padding: 24rpx 20rpx 1rpx;
			box-sizing: border-box;

			.chart-t {
				width: 650rpx;
				height: 452rpx;
				margin-bottom:20rpx;
			}

			.chart-b {
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				height: 40rpx;
				margin-bottom: 36rpx;

				>view {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				>view:nth-of-type(1) {
					width: 32rpx;
					height: 32rpx;
					font-weight: 400;
					font-size: 28rpx;
					line-height: 32rpx;
					text-align: center;
					margin-right: 18rpx;
				}

				>view:nth-of-type(2) {
					width: 246rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
					line-height: 39rpx;
				}

				>view:nth-of-type(3) {
					width: 132rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
					line-height: 39rpx;
				}

				>view:nth-of-type(4) {
					width: 2rpx;
					height: 20rpx;
					background: #D8D8D8;
					margin-right: 22rpx;
				}

				>view:nth-of-type(5) {
					width: 154rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
					line-height: 39rpx;
				}

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

			.chartOne {
				background: rgba(255, 0, 0, 0.2);
				color: #FF0000;
			}

			.chartTow {
				background: #FFE3CC;
				color: #FF9900;
			}

			.chartThree {
				background: #FFEECC;
				color: #FFAA00;
			}

			.chartFive {
				background: #CCE6FE;
				color: #0183FA;
			}
		}

		.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>
