<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title>查询指定终端在线率</title>
    <link rel="stylesheet" href="${ctx}/css/plugin/bootstrap/bootstrap.min.css" >
    <link rel="stylesheet" href="${ctx}/css/plugin/datatables/datatables.bootstrap.css">
    <link rel="stylesheet" href="${ctx}/css/basic.css">
    <style>
        .table>tbody>tr>td,
        .table>tbody>tr>th,
        .table>tfoot>tr>td,
        .table>tfoot>tr>th,
        .table>thead>tr>td,
        .table>thead>tr>th{
            padding:3px
        }
    </style>
</head>
<body>
<div class="container-fluid">
    <table id="content" class="width100 table table-striped table-bordered" cellspacing="0">
        <thead>
        <tr>
            <th>供电公司</th>
            <th>变电站</th>
            <th>终端</th>
            <th>终端IP</th>
            <th>在线率(%)</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>

</div>

<script src="${ctx}/js/plugin/jquery/jquery.min.js"></script>
<script src="${ctx}/js/plugin/datatables/datatables.jquery.js"></script>
<script src="${ctx}/js/plugin/datatables/datatables.bootstrap.js"></script>
<script src="${ctx}/js/plugin/layui/layer.js"></script>
<script src="${ctx}/jspJS/utils/judgeAjaxStatus.js"></script>
<script src="${ctx}/jspJS/utils/loading.js"></script>
<script>
    var startTime,endTime,gist,type;
        $(function () {
             startTime=parent.$("#startTime").val();
             endTime=parent.$("#endTime").val();
             gist=parent.$("#gist").val();
             gist=gist.replace(/(^\s*)|(\s*$)/g, '');
             type=parent.$("#type").val();
            switch (type){
                case'city':
                    executeQuery(type+"OnlineRate");
                    break;
                case'voltage':
                    executeQuery(type+"OnlineRate");
                    break;
                case'company':
                    executeQuery(type+"OnlineRate");
                    break;
            }
        })

    //执行查询
    function  executeQuery(name) {
            var i;
            $.ajax({
                url:"/pqs9000/overview/"+name,
                type:'post',
                data:{
                    startTime:startTime,
                    endTime:endTime,
                    gist:gist
                },
                dataType:'json',
                beforeSend: function () {
                    i = ityzl_SHOW_LOAD_LAYER();
                },
                success:function (data) {
                    //画表格
                    if(data.body===null){
                        initTable(null)
                    }else{
                        initTable(data.body)
                    }
                    //***********关闭loading
                    ityzl_CLOSE_LOAD_LAYER(i);
                }
            })
    }
    // 执行表格数据添加
    function  initTable(data){
        $('#content').DataTable({
            data:data,
            order:[],
            columnDefs:[
                {target:0,orderable:false}
            ],
            info:false,
            paging:false,
            searching:false,
            lengthChange:false,
            columns:[
                {data:'gdName'},
                {data:'subName'},
                {data:'name'},
                {data:'ip'},
                {data:'onlineRate'}
            ],
            language : {
                url:'/pqs9000/json/chine.json'
            }
        });
    }

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