var windowId,proName = window.location.pathname.split("/")[1],sysUrl = "http://"+window.location.host+"/"+proName,toEdit;

$(function(){
	initDefault();	
});
//默认
function initDefault(){
	// 默认时间
	$("#startTime").datetimebox("setValue",$.getTodayStart(0,"00:00:00"));
	$("#endTime").datetimebox("setValue",$.getTodayEnd("23:59:59"));
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	sParam.LIKEldmc = $("#LIKEldmc").textbox("getValue");
	var   startTime = $('#startTime').datetimebox("getValue");
	var   endTime = $('#endTime').datetimebox("getValue");
	sParam.tableparam="";
	if(!(startTime==null||startTime==""||startTime==undefined)){
		sParam.tableparam += " AND create_time >= '" +startTime + "'";
	}
	if(!(endTime==null||endTime==""||endTime==undefined)){
		sParam.tableparam += " AND create_time <= '" +endTime + "'";
	}
	sParam.order = "order by ldmc desc"
	return sParam;
}
//加载列表
function initGrid(){	
	var toolbar = [{
    	text	:	'查询',
        iconCls	:	'icon-search',
        handler	:	doSearch
    }];
	$('#tableGrid').datagrid({
		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : 'zxldAction!listZxldHistoryStateByPage.do',
		columns : [[
			{field:'ldmc',title:'雷达名称',hidden:false,width:120},
			{field:'ldbh',title:'雷达编号',hidden:false,width:120},
			{field: 'gxdwbh', title: '管辖单位编号', hidden: false, width: 120},
			{field: 'gxdwmc', title: '管辖单位名称', hidden: false, width: 120},
			{field: 'jd', title: '经度', hidden: false, width: 120},
			{field: 'wd', title: '纬度', hidden: false, width: 120},
			{field: 'fx', title: '方向', hidden: false, width: 120},
			{field: 'qs', title: '期数', hidden: false, width: 120},
			{field: 'bz', title: '备注', hidden: false, width: 120},
			{field:'create_time',title:'检测时间',hidden:false,width:125},
			{field:'state',title:'状态',hidden:false,width:60,
				formatter:function showClick(value,record,num){
					if(value==1){
						return "<div style='height:13px;width:13px;background-color:green;border-radius:50%;-moz-border-radius: 50%;-webkit-border-radius: 50%;margin:0 auto;'></div>";
//					}else if(value==0){
					}else {
						return "<div style='height:13px;width:13px;background-color:#fe0000;border-radius:50%;-moz-border-radius: 50%;-webkit-border-radius: 50%;margin:0 auto;'></div>";
					}
				}
			}
		]]
	});
}

//查询
function doSearch(){	
	$('#tableGrid').datagrid('load',getQueryParams());
}
