<template>
	<view>
		<view class="alarm" v-for="item in deviceAlarmRecords" :key="item.code">
			<text class="title">{{item.alarmName}}</text>

			<view class="content">
				<text>报警时间：{{item.createTime | timeFilter}}</text>
				<text>变量ID：{{item.variableId}}</text>
				<text>报警状态：{{item.status}}</text>
				<text>持续时长：{{item.createTime | timeFilter}}-{{item.endTime | timeFilter}}</text>

			</view>
		</view>

		<view class="anniu">
			<image class="anniu" src="../../static/设备菜单/前往列表@2x.png" @tap="back"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deviceAlarmRecords: [],
			}
		},
		filters: {
			timeFilter(data) {
				if(data!=='') {
					let time = uni.$moment(data).format("YYYY-MM-DD HH:mm:ss")
					return time
				}
			}
		},
		onLoad() {
			uni.request({
				url: 'http://127.0.0.1:9999/deviceAlarmRecord/list',
				method: 'GET',
				data: {},
				success: res => {

					this.deviceAlarmRecords = res.data.data.deviceAlarmRecords;
					console.log(res.data.data.deviceAlarmRecords);
				},

			})
		},
		methods: {
			back() {
				uni.navigateTo({
					url: '/pages/device/deviceInfo/deviceInfo'
				})
			}
		}
	}
</script>

<style>
	.anniu {
		width: 116rpx;
		height: 116rpx;
		float: right;
		margin-top: 10rpx;
		margin-right: 4rpx;
	}

	.alarm {
		width: 702rpx;
		height: 329rpx;
		background-color: white;
		margin-top: 30rpx;
		margin-left: 24rpx;
		border-radius: 10rpx;
		padding-top: 30rpx;
	}

	.content {
		display: flex;
		flex-direction: column;
		margin-top: 30rpx;
		margin-left: 30rpx;
		line-height: 55rpx;
		font-size: 28rpx;
		color: #444546;
	}

	.title {
		font-size: 36rpx;
		margin-left: 30rpx;
		color: #282828;
		font-weight: 600;
	}
</style>
