<template>
	<view>
		<view class="alarming">
			<view class="title">
				<view class="icon"></view>
				<view class="name">监测报警</view>
			</view>
			
			<view class="content">
				<view class="content_item" v-for="(item,index) in list" :key="index">
					<view class="content_title">{{item.mine_name}}</view>
					<view class="time">
						<view class="icon"></view>
						<view class="text">{{item.file_time}}</view>
					</view>
					<view class="inner">
						<view class="item">
							<view class="label">测试名称：</view>
							<view class="text">{{item.survey_name}}</view>
						</view>
						<view class="item">
							<view class="label">异常类型：</view>
							<view class="text">{{item.abnormal_type}}</view>
						</view>
						<view class="item">
							<view class="label">异常时间：</view>
							<view class="text">{{item.abnormal_time}}</view>
						</view>
						<view class="item">
							<view class="label">异常平均值：</view>
							<view class="text">{{item.abnormal_average}}</view>
						</view>
						<view class="item">
							<view class="label">异常最大值：</view>
							<view class="text">{{item.abnormal_max}}</view>
						</view>
						<view class="item">
							<view class="label">异常最小值：</view>
							<view class="text">{{item.abnormal_min}}</view>
						</view>
						<view class="item">
							<view class="label">异常原因：</view>
							<view class="text">{{item.abnormal_reason}}</view>
						</view>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	let _self = this

	export default {
		props: [
			"page",
			"code"
		],
		watch: {
			// 监听下拉加载页数
			page(newVal) {
				// console.log(newVal)
				this.page_num = newVal

				// 加载下一页
				this.get_list()
			},
			// 监听切换编码
			code(newVal) {
				// console.log(newVal)
				this.mine_code = newVal

				// 清空list
				this.list = []
				// 初始加载list
				this.get_list()
			}
		},
		data() {
			return {
				// 当前煤矿编码
				mine_code: 0,
				// 当前页
				page_num: 1,
				// 每页查询数量
				page_size: 5,
				// 列表项
				list: [],
				
				color_list:[
					"#83DCFC",
					"#E74C3C",
					"#8E44AD",
					"#2873FF",
					"#16A085",
					"#E67E22",
					"#3498DB",
					"#64C5E8",
					"#FA8B89",
					"#FBB47B",
					"#A3A2E4"
				]
			};
		},
		methods: {
			get_list() {
				// 获取列表数据
				this.$p_api.jt_safety_alarm_list({
					mine_code: this.mine_code,
					page_size: this.page_size,
					page_num: this.page_num
				}).then((res) => {
					// console.log(res.data.content.data)
					this.list = this.list.concat(res.data.content.data)
				})
			}
		}
	}
</script>

<style lang="scss">
	.alarming {
		margin-top: 8rpx;
		width: 749rpx;

		.title {
			height: 90rpx;

			display: flex;
			justify-content: center;
			align-items: center;

			border-bottom: 1px solid #eee;

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

			.name {
				margin-left: 8rpx;
			}
		}

		.content {
			box-sizing: border-box;
			padding: 20rpx 24rpx 40rpx;
			background-color: #F1F1F1;

			.content_item {
				margin-bottom: 20rpx;
				background-color: #FFFFFF;
				border-radius: 8px;
				overflow: hidden;

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

				.time {
					height: 80rpx;
					display: flex;
					align-items: center;

					box-sizing: border-box;
					padding: 0 20rpx;

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

					.text {
						margin-left: 10rpx;
					}
				}

				.inner {
					width: 700rpx;
					box-sizing: border-box;
					padding: 0 20rpx 40rpx;

					.item {
						padding: 10rpx 0;
						display: flex;

						.label {
							width: 220rpx;
						}

						.text {
							width: 480rpx;
						}
					}
				}
			}
		}
	}
</style>
