<%@ page language="java" import="java.util.*" pageEncoding="gbk" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
    <%@include file="../../../../../../frame/assets/header-all.jsp" %>
    <link rel="stylesheet" type="text/css" href="../../../../resource/css/map.frame.css">
</head>
<body class="easyui-layout" onselectstart="return false">
<div data-options="region:'north'" id='north' style="height: 78px;border: none">
    <div class="left-box fl">
        <div>
            <span class="text-content">设备类别：</span>
            <select id="lb" class="easyui-combobox">
                <option value="">全部</option>
                <option value="1" selected>监控</option>
                <option value="2">服务器</option>
                <option value="3">信号灯</option>
                <option value="4">诱导屏</option>
                <option value="10">地磁</option>
                <option value="11">微波</option>
                <option value="12">雷达</option>
                <option value="5">建筑</option>
                <option value="6">标志</option>
                <option value="7">标线</option>
                <option value="8">护栏</option>
                <option value="9">路段</option>
            </select>
        </div>
        <div>
            <span class="text-content">设备名称：</span>
            <input class="easyui-textbox" id="LIKEsbmc" prompt='请输入编号或名称'>
        </div>
    </div>

    <div class="right-box fl">
        <button id="search" class="button-search" onclick="doSearch()">查询</button>
    </div>
</div>

<div data-options="region:'center',split:false" class="easyui-layout" style="border: none">
    <table id="monitor-tab-grid"></table>
</div>
<div data-options="region:'south',height:70,borer:false,collapsible:true" class="easyui-layout" id='southPanel'>
    <div style="height:100%;margin:0 auto;" id="GridListDiv">
        <table id="statisgrid" cellspacing="0"  width="100%"  cellpadding="0"  border="1"  align="center"  style="text-align:center;margin:0 auto;" >
            <thead>
            <tr>
                <td>总数</td>
                <td>正常数</td>
                <td>异常数</td>
                <td>正在维修数</td>
                <td>已经维修数</td>
            </tr>
            </thead>
            <tbody id='searchGridList'>
            </tbody>
        </table>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $.fn.pagination.defaults.beforePageText = '';
        $.fn.pagination.defaults.afterPageText = '';
        $.fn.pagination.defaults.showPageList = false;
        $.fn.pagination.defaults.showRefresh = false;

        initGrid();
    })

    //查询
    function doSearch() {
        $('#monitor-tab-grid').datagrid('loadData',{total:0,rows:[]})
        $('#monitor-tab-grid').datagrid('load', getQueryParams());
        getdata();
    }

    //查询条件
    function getQueryParams() {
        var sParam = {};
        sParam.layerSeq = 1;
        sParam.LIKEmc = $('#LIKEsbmc').textbox('getText');
        sParam.sblb = $('#lb').combobox('getValue');
//    console.log(sParam);
        return sParam;
    }

    //加载列表
    function initGrid() {
        //统计所有设备的数据
        datagrid = $('#monitor-tab-grid').datagrid({
            url: 'szMapStatisAction!getMapDeviceStatusData.do',
            queryParams: getQueryParams(),
            rownumbers: true,
            columns: [[
                {field: 'name', title: '设备名称', width: 120},
                {field: 'status', title: '状态', width: 40},
                {field: 'jd', title: '经度', width: 90},
                {field: 'wd', title: '纬度', width: 90}
            ]]
        });
        getdata();
    }

    //加入所选
    function getdata() {
        $.ajax({
            type: 'post',
            dateType: 'json',
            url: 'szMapStatisAction!getDeviceStatusStatis.do',
            data: getQueryParams(),
            success: function (res) {
                renderTable(res);
            }
        });
    }

    function renderTable(res) {
        $("#searchGridList").html();
        var table = '';
        if (res) {
            var rows = res;
            table += '<tr>\
				<td>' + transformateEmpty(rows.total) + '</td>\
				<td>' + transformateEmpty(rows.normal) + '</td>\
				<td>' + transformateEmpty(rows.abnormal) + '</td>\
				<td>' + transformateEmpty(rows.repairing) + '</td>\
				<td>' + transformateEmpty(rows.repaired) + '</td>\
				<tr>'
        } else {
            table += '<tr> <td colspan="8">暂无数据</td> <tr>';

        }
        $("#searchGridList").html(table);
    }

    function transformateEmpty(str) {
        if (!str || str == null || str == "null") {
            return "-";
        }
        return str;
    }
</script>
</body>
</html>	
