<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='设备异常'></cus-header>
		<div class="top" @tap="placeShow = true;">
			<div class="left">
				<image :src="imgBase+'inspection/record_location.png'"></image>
				<text>{{'电商园四期B座'}}</text>
			</div>
			<div class="right">
				<u-icon name="arrow-right" color="#FFFFFF" size="32"></u-icon>
			</div>
		</div>
		<div class="title">共有<span>{{list.length}}</span>条记录</div>
		<div class="boxs" v-if="list.length">
			<div class="box" v-for="(item,index) in list" :key="index">
				<div class="place">{{item.place}}</div>
				<div class="pre">安装位置<span>{{item.time}}</span></div>
				<div class="pre">设备编号<span>{{item.deviceno}}</span></div>
				<div class="pre">告警原因<span class="red">{{item.reason}}</span></div>
				<div class="pre">告警内容<span>{{item.content}}</span></div>
				<div class="pre">巡检时间<span>{{item.time}}</span></div>
			</div>
		</div>
		<template v-else>
			<page-empty :height="'calc(100vh - '+(mt+105)+'px)'" marginTop="105px"></page-empty>
		</template>
		<u-picker :show="placeShow" :columns="placeColumns" @cancel="placeShow=false" @change="changeHandler" @confirm="e=>paramsConfirm(e,'')" ref="uPicker"></u-picker>
	</view>
</template>

<script>
	import pageEmpty from '@/components/pageEmpty/index.vue'
	export default {
		components:{
			pageEmpty
		},
		data(){
			return {
				placeShow:false,
				placeColumns:[
					['A栋','B栋'],
                    ['A101', 'A102', 'A103', 'A201']
				],
                placeColumnData: [
                    ['A101', 'A102', 'A103', 'A201'],
                    ['B201', 'B203', 'B303', 'B404']
                ],
				list:[
					{
						place:'B座13楼1301',
						position:'电商园四期B座-13层',
						deviceno:'A32486',
						reason:'温度 ≥ 40℃',
						content:'实时温度52℃',
						time:'2024-12-28 10:34:22'
					},
					{
						place:'B座13楼1302',
						position:'电商园四期B座-13层',
						deviceno:'A32486',
						reason:'温度 ≥ 40℃',
						content:'实时温度52℃',
						time:'2024-12-28 10:34:22'
					}
				]
			}
		},
		methods:{
            changeHandler(e) {
                const {
                    columnIndex,
                    value,
                    values, // values为当前变化列的数组内容
                    index,
					// 微信小程序无法将picker实例传出来，只能通过ref操作
                    picker = this.$refs.uPicker
                } = e
                // 当第一列值发生变化时，变化第二列(后一列)对应的选项
                if (columnIndex === 0) {
                    // picker为选择器this实例，变化第二列对应的选项
                    picker.setColumnValues(1, this.placeColumnData[index])
                }
            },
			paramsConfirm(e,type){
				this.placeShow = false;
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		padding-bottom: 20rpx;
		background: #F4F8FB;
		box-sizing: border-box;
		.top{
			width: 100%;
			height: 102rpx;
			background: #198CFF;
			padding: 0 30rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left{
				display: flex;
				align-items: center;
				image{
					width: 36rpx;
					height: 36rpx;
				}
				text{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 30rpx;
					color: #FFFFFF;
					line-height: 42rpx;
					margin-left: 10rpx;
				}
			}
		}
		.filtrate{
			width: 100%;
			height: 90rpx;
			background: #FFFFFF;
			display: flex;
			.pre{
				width: calc(100% / 3);
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				text{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #4E5969;
					line-height: 40rpx;
					margin-right: 12rpx;
				}
			}
		}
		
		.title{
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #1D2129;
			line-height: 32rpx;
			margin-top: 36rpx;
			padding-left: 24rpx;
			span{
				color: #198CFF;
				margin: 0 10rpx;
			}
		}
		
		.boxs{
			width: 100%;
			padding: 0 24rpx;
			box-sizing: border-box;
			margin-top: 16rpx;
			overflow: hidden;
			.box{
				margin-top: 20rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				padding: 36rpx 24rpx;
				.place{
					font-family: PingFang-SC, PingFang-SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #1D2129;
					line-height: 36rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				.pre{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #86909C;
					line-height: 24rpx;
					margin-top: 26rpx;
					span{
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 26rpx;
						color: #1D2129;
						line-height: 26rpx;
						margin-left: 20rpx;
						&.red{
							color: #F95050;
						}
					}
				}
			}
		}
	}
</style>