<template>
	<view>
		<view class="top">
			<image src="./icon/top.jpg" mode=""></image>
		</view>
		<view class="content">

			<view class="charts-box" v-if="chartData.series[0].data[0].value">
				<qiun-data-charts type="ring" :opts="ring_1" :chartData="chartData" background="none" />
			</view>

			<view class="list">
				<view class="item" v-for="(item,index) in list" :key="index">
					<view class="title" :style="{borderLeftColor: item.color}">{{item.cocalminename}}</view>
					<view class="inner">
						<view class="box" v-for="(item_2,index_2) in item.data">
							<view class="name">{{item_2.title}}</view>
							<view class="num">{{item_2.num}}个</view>
						</view>
					</view>
					<view class="right_arrow" @click="go_personnel_orientation(item.mine_code)">
						<view class="text">查看详情</view>
						<view class="icon"></view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				chartData: {
					categories: [],
					"series": [{
						"data": [{
								"name": "全矿下井人数",
								"value": 0
							},
							{
								"name": "矿级领导",
								"value": 0
							},
							{
								"name": "公司领导",
								"value": 0
							}
						]
					}]
				},
				ring_1: {
					"dataLabel": false,
					"legend": {
						"position": "bottom",
					},
					"title": {
						"name": "下矿总人数",
						"color": "#555",
					},
					"subtitle": {
						"name": "3515人",
						"color": "#333",
					},
					"extra": {
						"ring": {
							"centerColor": "#F1F1F1",
							"border": false,
						},

					}
				},


				list: []

			};
		},
		onLoad() {
			this.get_data()
		},
		methods: {
			get_data() {
				this.$p_api.personnel_mineall_total({
					mine: "all"
				}).then((res) => {
					console.log(res.data.data)

					this.ring_1.subtitle.name = res.data.data.total + res.data.data.mine_leader_total + res.data
						.data.company_leader_total

					this.chartData.series[0].data[0].value = res.data.data.total
					this.chartData.series[0].data[1].value = res.data.data.mine_leader_total
					this.chartData.series[0].data[2].value = res.data.data.company_leader_total


					this.list = res.data.data.list
				})
			},
			//人员定位
			go_personnel_orientation(mine_code) {
				uni.navigateTo({
					url: "../../production/personnel_orientation/personnel_orientation?mine=" + mine_code
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F1F1F1;
	}

	.top {
		image {
			width: 750rpx;
			height: 360rpx;
		}
	}

	/* 请根据需求修改图表容器尺寸，如果父容器没有高度图表则会显示异常 */
	.charts-box {
		width: 100%;
		height: 300px;
	}

	.content {
		width: 750rpx;

		box-sizing: border-box;
		padding: 25rpx;
	}

	.list {
		.item {
			width: 700rpx;
			background-color: #FFFFFF;
			border-radius: 8px;
			overflow: hidden;

			margin-bottom: 25rpx;

			.title {
				line-height: 80rpx;
				padding-left: 20rpx;
				border-left: 8rpx solid #83DCFC;
				border-bottom: 1px solid #eee;
			}

			.inner {
				display: flex;
				justify-content: space-around;

				.box {
					padding: 30rpx 0;
					color: #999;
					text-align: center;

					.name {
						line-height: 60rpx;
					}

					.num {
						color: #49C27D;
					}
				}

				.box:nth-child(2) {
					.num {
						color: #B85A56;
					}
				}

				.box:nth-child(3) {
					.num {
						color: #34383D;
					}
				}
			}

			.right_arrow {
				width: 160rpx;
				height: 60rpx;
				margin-left: 520rpx;

				display: flex;
				align-items: center;

				.text {
					font-size: 28rpx;
					color: #999999;
					margin-right: 8rpx;
				}

				.icon {
					width: 30rpx;
					height: 30rpx;
					background-image: url(./icon/right.png);
					background-size: cover;
					background-repeat: no-repeat;
				}

			}
		}
	}
</style>
