<template>
	<view class="content">
		<view class="top">
			<image class="top_logo" src="../../static/logo.png" mode=""></image>
			<image class="tite" src="../../static/tite.png" mode=""></image>
			<view class="time">
				<view class="time_top">
				{{formattedTime}}
				</view>
				<view class="time_bottom">
					<view>

					</view>
					<view class="time_bottom1">
						连接状态：
						<view class="time_state" v-if="this.total">
							在线
						</view>
						<view class="time_state1" v-else>
							离线
						</view>
						
					</view>

				</view>

			</view>
		</view>
		<view class="parameter">
			<view class="parameter_xian">
				<view class="parameter_xian1">
					序号
				</view>
				<view class="parameter_xian2">
					类型
				</view>
				<view class="parameter_xian3">
					设备
				</view>
				<view class="parameter_xian4">
					内容
				</view>
				<view class="parameter_xian5">
					发生时间
				</view>
				<view class="parameter_xian6">
					恢复时间
				</view>
			</view>
			<view class="parameter_box">
				<view v-for="(item,index) in faultsList" :class="item.RESETTIME==''?'parameter_divred':'parameter_div'" :key="index">
					<view class="parameter_xian1">
						{{item.ID}}
					</view>
					<view class="parameter_xian2">
						{{item.TYPE}}
					</view>
					<zb-tooltip @click.top="closedevice" :content="item.DEVICE" placement="top" :ref="'device'+index">
					<view class="parameter_xian3">
						{{item.DEVICE}}
					</view>				
						</zb-tooltip>
					<zb-tooltip @click.top="close" :content="item.CONTENT" placement="top" :ref="'tooltip'+index">
					<view class="parameter_xian4">
						{{item.CONTENT}}
					</view>
					</zb-tooltip>
					<view class="parameter_xian5">
						{{item.FAULTTIME.substring(0, 19)}}
					</view>
					<view class="parameter_xian6">
						{{item.RESETTIME.substring(0, 19)}}
					</view>
				</view>
				 
			</view>

			<view class="parameter_bottom">
				<view class="parameter_bottom1" @click="onclick">  
					<image src="../../static/home.png" mode=""></image><text class="parameter_bottom2">返回模式选择</text>
				</view>
				<view class="parameter_bottom3">
					<view :class="faulttaps=='实时'?'parameter_bottom31':'parameter_bottom32'" @click="taps('实时')">
						实时
					</view>
					<!-- <view :class="faulttaps=='全部'?'parameter_bottom31':'parameter_bottom32'" @click="taps('全部')">
						全部
					</view> -->
					<view :class="faulttaps=='故障'?'parameter_bottom31':'parameter_bottom32'" @click="taps('故障')">
						故障
					</view>
					<view :class="faulttaps=='告警'?'parameter_bottom31':'parameter_bottom32'" @click="taps('告警')">
						告警
					</view>
					<view :class="faulttaps=='事件'?'parameter_bottom31':'parameter_bottom32'" @click="taps('事件')">
						事件
					</view>
				</view>
				<view class="parameter_bottom4">
					<view class="eliminate">
						故障清除
					</view>
					<uni-pagination :total="total" title="标题文字" :show-icon="true" @change="change" />
				</view>
			</view>

		</view>
	</view>
</template>
<!--table -->
<script>
	import {getTime} from "../../utils/index.js"
	import {getfaultsList} from "../../api/api.js"
	export default {
		data() {
			return {
				current: 1,
				total: 0,
				pageSize: 10,
				faulttaps:'实时',
				faultsList:[],
				formattedTime:getTime('yyyy年MM月dd日 hh:mm:ss'),
				formatTimeid:''
			}
		},
		onLoad() {
			
			this.formatTimeid = setInterval(() => {
			   const customFormat = 'yyyy年MM月dd日 hh:mm:ss';
			    this.formattedTime = getTime(customFormat);
			  }, 1000);
			this.onfaultsList();
		},
		beforeUnmount() {
			clearInterval(this.formatTimeid);
		},
		methods: {
			onfaultsList(){
				let data ={
					page:this.current,
					rows: this.pageSize,
					device: '',
					starttime: '',
					endtime: '',
					rt: this.faulttaps=='实时' ? 1:0,
					type: this.faulttaps=='实时'?'':this.faulttaps
				}
						getfaultsList(data).then(res => {
							console.log(res);
						 if(res.status=='ok'){
						 	 this.faultsList= res.data.list
							 this.total = res.data.pagination.total
						 }else{
							 
						 }
				});
			
							 
						},
			onclick() {
				uni.redirectTo({
					url: '/pages/index/index'
				});
			},

			change(e) {
				console.log(e);
				this.current = e.current
				this.onfaultsList()
			},
			taps(e){
				this.faulttaps=e
				console.log(e);
				this.onfaultsList()
			},
			// 文字提示
		 closedevice(){
		 	for(let i=1;i<this.total;i++){
		 		this.$refs[('device'+i)].close()
		 	}
		 },
			close(){
				for(let i=1;i<this.total;i++){
					this.$refs[('tooltip'+i)].close()
				}
			}
		}
	}
</script>

<style scoped>
	.content {
		width: 100%;
		height: 100vh;
		opacity: 1;
		background: linear-gradient(180deg, rgba(215, 230, 245, 0) 0%, rgba(196, 229, 255, 1) 100%);
		box-sizing: border-box;
	}

	.top {
		width: 100%;
		height: 100px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		background-color: #fff;
		padding: 0px 46px;
		box-sizing: border-box;
	}

	.top_logo {
		width: 426px;
		height: 68px;
	}

	.tite {
		width: 277px;
		height: 48px;
	}

	.time {
		text-align: right;
	}

	.time_top {
		font-size: 17px;
	}

	.time_bottom {
		display: flex;
		font-size: 17px;
		justify-content: space-between;
	}

	.time_bottom1 {
		display: flex;
	}

	.time_state {
		font-size: 17px;
		font-weight: 600;
		color: rgba(22, 68, 144, 1);
	}

	.parameter {
		width: 100%;
		/* padding-bottom: 20px; */
		display: flex;
		padding:0px 20px 20px 20px;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
	}

	.parameter_xian {
		width: 100%;
		height: 55px;
		background: linear-gradient(180deg, rgba(30, 131, 189, 1) 0%, rgba(69, 168, 230, 0.92) 100%);
		box-shadow: inset 0px 0px 9.79px rgba(0, 0, 0, 0.1);
		display: flex;
		align-items: center;
		/* justify-content: space-around; */
		font-size: 28px;
		font-weight: 600;
		padding: 0px 20px;
		box-sizing: border-box;
		.parameter_xian1 {
			width: 100px;
		}
		
		.parameter_xian2 {
			width: 100px;
		}
		
		.parameter_xian3 {
			width: 120px;
		}
		
		.parameter_xian4 {
			width: 400px;
			margin-right: 10px;
			  white-space: nowrap; /* 禁止换行 */
  overflow: hidden; /* 超出部分隐藏 */
  text-overflow: ellipsis; /* 显示省略号 */
		}
		
		.parameter_xian5 {
			width: 220px;
			margin-right: 10px;
		}
		
		.parameter_xian6 {
		width: 220px; 
		}
	}

	.parameter_box {
		width: 100%;
		overflow: auto;
	}

	.parameter_div {
		width: 100%;
		height: 44.05px;
		background: rgba(255, 255, 255, 1);
		box-shadow: inset 0px 0px 9.79px rgba(0, 0, 0, 0.1);
		margin-top: 10px;
		display: flex;
		align-items: center;
		/* justify-content: space-around; */
		font-weight: 500;
		padding: 0px 20px;
		box-sizing: border-box;
		.parameter_xian1 {
			font-size: 18px;
			width: 100px;
		}
		
		.parameter_xian2 {
			font-size: 18px;
			width: 100px;
		}
		
		.parameter_xian3 {
			font-size: 18px;
			width: 120px;
			white-space: nowrap; /* 禁止换行 */
			overflow: hidden; /* 超出部分隐藏 */
			text-overflow: ellipsis; /* 显示省略号 */
			margin-right: 10px;
		}
		
		.parameter_xian4 {
			font-size: 18px;
			width: 400px;
			margin-right: 10px;
			white-space: nowrap; /* 禁止换行 */
			overflow: hidden; /* 超出部分隐藏 */
			text-overflow: ellipsis; /* 显示省略号 */
		}
		
		.parameter_xian5 {
			font-size: 18px;
			width: 220px;
			margin-right: 10px;
			
		}
		
		.parameter_xian6 {
			font-size: 18px;
			width: 220px;
		}
	}

	.parameter_divred {
		width: 100%;
		height: 44.05px;
		background: rgba(245, 99, 83, 1);
		box-shadow: inset 0px 0px 9.79px rgba(0, 0, 0, 0.1);
		margin-bottom: 10px;
		display: flex;
		align-items: center;
		color: #fff;
		font-weight: 500;
		/* justify-content: space-around; */
		padding: 0px 16px;
		box-sizing: border-box;
		.parameter_xian1 {
			font-size: 18px;
			width: 100px;
		}
		
		.parameter_xian2 {
			font-size: 18px;
			width: 100px;
		}
		
		.parameter_xian3 {
			font-size: 18px;
			width: 120px;
			white-space: nowrap; /* 禁止换行 */
			overflow: hidden; /* 超出部分隐藏 */
			text-overflow: ellipsis; /* 显示省略号 */
			margin-right: 10px;
		}
		
		.parameter_xian4 {
			font-size: 18px;
			width: 400px;
			margin-right: 10px;
			white-space: nowrap; /* 禁止换行 */
			overflow: hidden; /* 超出部分隐藏 */
			text-overflow: ellipsis; /* 显示省略号 */
		}
		
		.parameter_xian5 {
			font-size: 18px;
			width: 220px;
			margin-right: 10px;
			
		}
		
		.parameter_xian6 {
			font-size: 18px;
			width: 220px;
		}
	}

	.parameter_bottom {
		display: flex;
		justify-content: space-between;
		margin-bottom: 10px;
		padding: 0px 16px;
		position: fixed;
		left: 0px;
		bottom: 10px;
		width: 100%;
		box-sizing: border-box;
	}

	.parameter_bottom1 {
		display: flex;
		align-items: center;

		image {
			width: 32px;
			height: 32px;
			display: flex;
		}
	}

	.parameter_bottom2 {
		font-size: 19.58px;
		font-weight: 400;
		color: rgba(0, 0, 0, 1);
		margin-left: 10px;
	}

	.parameter_bottom3 {
		display: flex;
	}

	.parameter_bottom31 {
		width: 48px;
		height: 48px;
		background: linear-gradient(180deg, rgba(74, 167, 224, 1) 0%, rgba(36, 134, 192, 1) 100%);
		border-radius: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 19px;
		font-weight: 700;
		margin-right: 20px;
		color: rgba(255, 255, 255, 1);
	}
	.parameter_bottom32 {
		width: 48px;
		height: 48px;
		background: linear-gradient(180deg, rgba(224, 218, 218, 1) 0%, rgba(130, 121, 121, 1) 100%);
		border-radius: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 19px;
		font-weight: 700;
		color:#222222;
		margin-right: 20px;
	}
	.parameter_bottom4 {
		display: flex;
		align-items: center;
	}

	.eliminate {
		width: 107.69px;
		height: 44.05px;
		opacity: 1;
		border-radius: 2.45px;
		background: linear-gradient(180deg, rgba(119, 163, 230, 1) 0%, rgba(25, 85, 176, 1) 10.42%, rgba(6, 53, 94, 1) 88.89%, rgba(119, 163, 230, 1) 100%);
		margin-right: 20px;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 23.5px;
		font-weight: 400;
		color: rgba(255, 255, 255, 1);
		box-sizing: border-box;
	}
	.time_state1 {
			font-size: 17px;
			font-weight: 600;
			color: rgba(217, 22, 22, 1);
		}
</style>