<template>
	<view>
		<!-- @click="openPop(item) -->
		<view class="order-item" v-for="item,index in groupList">
			<view class="ddflex order-item-header">
				<view class="order-time">类型：{{item.alarmFlag}}</view>
				<block>
					<view v-if="item.type==1" class="order-state">待消除</view>
					<view v-else class="order-state" style="color: #0FCB27;border: 2rpx solid #0FCB27;">已消除</view>
				</block>
			</view>
			<view class="order-item-body">
				<view class="order-item-content ddflex">
					<view class="order-item-content-label">机柜编号：</view>
					<view class="order-item-content-data fflex tover">{{item.devId}}</view>
				</view>
				<view class="order-item-content ddflex">
					<view class="order-item-content-label">电池编号：</view>
					<view class="order-item-content-data fflex tover">{{item.batteryId}}</view>
				</view>
				<view class="order-item-content ddflex">
					<view class="order-item-content-label">描述：</view>
					<view class="order-item-content-data fflex tover">{{item.alarmDesc}}</view>
				</view>
				<view class="order-item-content ddflex">
					<view class="order-item-content-label">告警时间：</view>
					<view class="order-item-content-data fflex tover">{{item.alarmTime}}</view>
				</view>
			</view>
		</view>
		
		<bottom-pop v-if="showPop" :showPop='showPop' :btnColor="'#11BB8B'" :showBtn='false' title="解除提醒"
			@closePop="closePop()" @popSubmit="popSubmit()">
			<view>
				<view>
					<image class="nodata-icon" src="../../static/pages/images/alarmUpload.png"></image>
					<view class="nodata-note">上传检修记录，恢复正常</view>
				</view>
				<view class="pop-btns ddflex">
					<view class="btn" @click="closePop">取消</view>
					<view class="btn2" @click="jumpUrl('warning/reconditionAlarmUpload/reconditionAlarmUpload')">上传检修记录</view>
				</view>
			</view>
		</bottom-pop>
		
	</view>
</template>

<script>
	const app = getApp();
	const req = require("../../utils/request.js");
	import bottomPop from "../../components/bottom-pop/index";
	export default {
		components: {
			bottomPop
		},
		props: {},
		data() {
			return {
				showPop: false,
				tempData: null,
				
				id:null,
				
				groupList: [],
				page: 1,
				limit: 10,
				searchValue:'',
				isQuerying:false,//正在查询数据
			}
		},
		onLoad(options) {
			if(options.id){
				this.id = options.id
			}
			this.getMachineList()
		},
		onShow() {
			
		},
		onReachBottom() {
			this.getMachineList(true)
		},
		methods: {
			jumpUrl(url) {
				if (!req.isLogin()) return false;
				app.globalData.navigateTo(url);
			},
			// 弹窗弹出
			openPop(item) {
				this.tempData = JSON.parse(JSON.stringify(item))
				this.showPop = true
			},
			// 弹窗关闭
			closePop() {
				this.showPop = false
				this.tempData = null
			},
			// 弹窗确认
			popSubmit() {
				this.closePop()
			},
			
			// 获取机柜列表
			getMachineList(isPage){
				if(this.isQuerying) return
				else this.isQuerying = true
				if (!isPage) {
					this.page = 1
				}
				let queryParams = {
					page: this.page,
					limit: this.limit,
				}
				let api = '/admin/v2/cab/page'
				if(this.id){
					api = '/admin/v2/cab/alarm/page'
					queryParams.devId = this.id
				}
				req.getRequest(
					api,
					queryParams,
					data => {
						if (data != null && data.list.length > 0) {
							if (!isPage) {
								this.groupList = data.list
							} else {
								this.groupList = this.groupList.concat(data.list)
							}
							this.page++
						} else {
							if (!isPage)
								this.groupList = data.list
							else {}
						}
						uni.hideLoading()
						this.isQuerying = false
					}
				)
			},
		},
		mounted() {
		},
		onPageScroll: function(e) {
		}
	}
</script>

<style>
	@import "./machineAlarm.css";
</style>