<%@ 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"%>
		</head>
	<body class="easyui-layout" >
 		<div data-options="region:'north'" id='north' style="height: 44px;border-bottom: none">
			<div class="form-line clearfix">
				<div class='fl'>
					<span class="text-content">开始时间：</span>
					<input  class="easyui-datetimebox"  id="LIKEsnapTime1" >
				</div>
				<div class='fl'>
					<span class="text-content">结束时间：</span>
					<input  class="easyui-datetimebox"  id="LIKEsnapTime2" >
				</div>
			 </div>
		</div>
		<div data-options="region:'center',split:false" class="easyui-layout">
			<table id='tableGrid'></table>
		 </div>   
	</body>
</html>	
<script>
var datenow = new Date();
$(function(){
	initDefault();
	
	//筛选按钮初始化
	setTimeout(function(){
		$("#filter").configBtn($("#tableGrid"),function(){})
	},500)
});

//默认
function initDefault(){
	$("#LIKEsnapTime1").datetimebox("setValue",datenow.format("yyyy-MM-dd")+" 00:00:00");
	$("#LIKEsnapTime2").datetimebox("setValue",datenow.format("yyyy-MM-dd")+" 23:59:59");
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	var LIKEsnapTime1 = $("#LIKEsnapTime1").datetimebox("getValue");//开始时间
	var LIKEsnapTime2 = $("#LIKEsnapTime2").datetimebox("getValue");//结束时间
	var tableparam = "";
	
	if(!!LIKEsnapTime1){
		tableparam += " AND snapTime > '" +LIKEsnapTime1 + "'";
	}else{
		$.dlg.alertWarning("请输入开始时间！");
		return ; 
	}
	if(!!LIKEsnapTime2){
		tableparam += " AND snapTime < '" +LIKEsnapTime2 + "'";
	}else{
		$.dlg.alertWarning("请输入结束时间！");
		return ; 
	}
	
	sParam.tableparam = tableparam;
	sParam.order = "order by createDate desc ";
	return sParam;
}
//加载列表
function initGrid(){	
	var toolbar = [{
        text:'查询',
        iconCls:'icon-search',
        handler:function(){doSearch();}
    },{
    	//定义按钮的id和图标
    	id :'filter',
        iconCls:'icon-filter'
    }];
	$('#tableGrid').datagrid({
		toolbar : toolbar,
		url : '',
		queryParams:{},
		rownumbers:true,
		//表格渲染完成前，将按钮定位到最右边
		onBeforeLoad:function(){
			$('#filter').css({
				'width':'28px',
				'height':'28px'
			}).parent('td').css({
				'position':'absolute',
				'right':'0'
			})
		},
		columns : [[
			{field:'sbbh',title:'设备编号',hidden:false,width:120,configShow:true},
			{field:'sbmc',title:'设备名称',hidden:false,width:120},
			{field:'cjbh',title:'cjbh',hidden:true,width:80},
			{field:'cjmc',title:'设备厂商',hidden:false,width:80,configShow:true},
			{field:'xzmc',title:'行政目录',hidden:false,width:80},
			{field:'xzbh',title:'xzbh',hidden:true,width:80},
			{field:'csmc',title:'类型名称',hidden:false,width:80,configShow:true},
			{field:'sbzl',title:'设备类型',hidden:true,width:70,configShow:true},
			{field:'sbzt',title:'sbzt',hidden:true,width:70},
			{field:'sbztname',title:'设备状态',hidden:false,width:70},
			{field:'sbip',title:'IP地址',hidden:false,width:100}
		]]
	});
	$.ajax({
		url:'test.json',
		type:'get',
		dataType:'json',
		success:function(data){
			$('#tableGrid').datagrid("loadData",data)
		}
	})
}
//查询
function doSearch(){
	$('#tableGrid').datagrid('load', getQueryParams());	
}
</script>