<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html >
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>告警</title>
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" href="${ctx}/css/plugin/bootstrap/bootstrap.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/bootstrap/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/datatables/buttons.dataTables.min.css">
<link rel="stylesheet" href="${ctx}/css/basic.css">
<style type="text/css">
	#query{
		float:right;
		margin:2px 17px -6px 0px;
		background-color:#006565;
	}
	.table > tbody > tr > td {
		padding : 3px;
	}
</style>
</head>
<body style="overflow:hidden;">
	<div role="alert" style="background-color: #d9edf7;">
		    <shiro:hasPermission name="/pqs9200/business/glindex/#">

		        <button type="button" class="btn themeBGColor" id="query" style="margin-right: 5%"
		                onclick="jump()">
		            <i class="glyphicon glyphicon-bullhorn"></i>事件处理并查看
		        </button>

		    </shiro:hasPermission>
            <table id="example"
		           class="table table-striped table-bordered dataTable no-footer"
		           cellspacing="0" width="100%" role="grid"
		           aria-describedby="example_info">
		        <thead>
		        <tr role="row">
		            <th class="text-center">变电站名称</th>
		            <th class="text-center">监测点名称</th>
		            <th class="text-center">发生时间</th>
		            <th class="text-center">特征幅值(%)</th>
		            <th class="text-center">持续时间(s)</th>
		        </thead>
		    </table>
	</div>
	<script src="${ctx}/js/plugin/jquery.min.js"></script>
	<script src="${ctx}/js/plugin/layerui/layui.js"></script>
	<script src="${ctx}/js/plugin/layerui/layui.all.js"></script>
	<script src="${ctx}/js/plugin/bootstrap/jquery.dataTables.min.js"></script>
	<script src="${ctx}/js/plugin/bootstrap/dataTables.bootstrap.min.js"></script>
	<script src="${ctx}/js/plugin/bootstrap/bootstrap-datetimepicker.min.js"></script>
	<script src="${ctx}/js/plugin/bootstrap/bootstrap-datetimepicker.zh-CN.js"></script>
	<script src="${ctx}/js/plugin/bootstrap-table/bootstrap-table.js"></script>
	<script src="${ctx}/js/plugin/bootstrap-table/locales/bootstrap-table-zh-CN.js"></script>
	<script src="${ctx}/js/plugin/bootstrap-table/bootstrap-table.js"></script>
	<script src="${ctx}/js/plugin/datatables/dataTables.buttons.min.js"></script>
	<script src="${ctx}/js/plugin/datatables/buttons.html5.min.js"></script>
	<script src="${ctx}/jspJS/utils/judgeAjaxStatus.js"></script>
	<script src="${ctx}/jspJS/utils/loading.js"></script>
	<script type="text/javascript">
	var eventlist = parent.eventlist;
	$(document).ready(function () {


		initTable(eventlist);
	});

	var table=null;
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引

	/**
	 * @param data
	 * @returns
	 * 初始化表格
	 */
	 function initTable(data) {
		   var  oTable = $('#example').DataTable({
		        destroy: true,
	            columns: [
	                {
	                    width: "22%", data: "bdname", render: function (data, type, full, meta) {
	                        var value = data;
	                        if (data.length > 8) {
	                            value = data.substring(0, 7) + "...";
	                            value = "<span title=\""+data+"\">" + value + "</span>";
	                        }
	                        return value;
	                    }
	                },
	                {
	                    width: "22%", data: "pointname", render: function (data, type, full, meta) {
	                        var value = data;
	                        if (data.length > 10) {
	                            value = data.substring(0, 9) + "...";
	                            value = "<span title=\""+data+"\">" + value + "</span>";
	                        }
	                        return value;
	                    }
	                },
	                {width: "23%", data: "timeid"},
	                {width: "16%", data: "eventvalue"},
	                {width: "16%", data: "persisttime", render: function (data, type, full, meta) {
                        var value = (parseFloat(data)).toFixed(3);

                        return value.toString();
                    }}
	            ],
		        "aaSorting": [[2, "desc"]],
		        data: data,
		        dom: 'rt',
	            lengthChange: false,
		        scrollY: '215px',
		        lengthMenu: [12],
		        language: {
		            url: '/pqs9200/json/chine.json'
		        }
		    });
		}

	function jump(){
		let arr = eventlist.map(item=>item.eventIndex)
		if(arr.length!=0){
			$.ajax({
				type: "POST",
				url: "/pqs9200/event/dealEventWarn",
				dataType: 'json',
				contentType:'application/json;charset=UTF-8',
				data:JSON.stringify(arr),
				success: function (data) {
					if(data.code === 200){
						parent.closeWarn()
						layer.msg(data.message, {icon: 1,time:1000},function () {
							{
								window.top.addTab('vdlist','区域暂降列表');
								parent.eventlist=[];
								parent.layer.close(index);
							}
						})

					}else {
						layer.msg(data.message, {icon: 2})
					}
				}
			})
		}

	}


	function dealEvent(){



	}
	</script>
</body>
</html>
