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

$(function(){
	initGrid();
});

//加载列表
function initGrid(){	
	toolbar = [
	      {
		        text:'统计列表',
		        iconCls:'icon-search',
		        handler:function(){
		        	showList();
		        }
	      },
	      {
	    	  text:"统计图",
	    	  iconCls:"icon-search",
	    	  handler:function(){
	    		  showGraph();
	    	  }
	      },
		  {
				text:"导出",
				iconCls:"icon-search",
				handler:function(){
					showExport();
				}
			},
		  {
				text:"计算公式",
				iconCls:"icon-search",
				handler:function(){
					showCompute();
				}
			}
	];
	showList();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	sParam.order = "order by alarmtime desc ";
	return sParam;
}
//列表展示
function showList(){
	$("#searchGridListDiv").show();
	$("#searchGridPicDiv").hide();
	$("#searchGridStaticsDiv").hide();
	displayType = "list";
	$('#searchGridList').datagrid({
		toolbar : toolbar,
		queryParams:getQueryParams(),
		url : 'ywalarmeventinfoAction!listYwalarmeventinfoByPage.do',//'demoAction!listDemoByPage.do',
		columns : [[
		        	{field:'alarmruleid',title:'序号',hidden:true,width:120},
					{field:'alarmrulename',title:'行政规划',hidden:false,width:120},
					{field:'alarmdevicetypename',title:'监控点总数',hidden:false,width:120},
					{field:'alarmdevicename',title:'无经纬度数',hidden:false,width:120, 
						formatter:function showClick(value,record,num){ 
							return "<a  href='javascript:void(0);' class='ahref' onclick='showJw("+num+")'>"+value+"</a>";
						}},
					{field:'alarmdeviceid',title:'经纬度缺失',hidden:false,width:120,
							formatter:function showClick(value,record,num){ 
								return "<a  href='javascript:void(0);' class='ahref' onclick='showJw("+num+")'>"+value+"</a>";
							}
					},
					{field:'channelnum',title:'经纬度无效数',hidden:false,width:120},
					{field:'alarmtypename',title:'经纬度完整数',hidden:false,width:120},
					{field:'alarmgradename',title:'经纬度采集率',hidden:false,width:120},
					{field:'alarmsubtypecode',title:'告警子类型编码',hidden:true,width:120},
					{field:'alarmsubtypename',title:'告警子类型编码名称',hidden:true,width:120},
					{field:'alarmreason',title:'告警原因',hidden:false,width:120}
	/*	    {field: 'A',checkbox:'true',width:30},
		    {field:'xuhao',title:'序号',hidden:false,width:120},
			{field:'xzgh',title:'行政规划',hidden:false,width:120},
			{field:'jkdzs',title:'监控点总数',hidden:false,width:120},
			{field:'wjwd',title:'无经纬度',hidden:false,width:120},
			{field:'jwdqs',title:'经纬度缺失',hidden:false,width:120},
			{field:'jwdwxs',title:'经纬度无效数',hidden:false,width:120},
			{field:'jwdwzs',title:'经纬度完整数',hidden:false,width:120},
			{field:'jwdcjl',title:'经纬度采集率',hidden:false,width:120}*/
	]]
});
}


function showGraph(){
	$("#searchGridPicDiv").show();
	$("#searchGridListDiv").hide();
	$("#searchGridStaticsDiv").hide();
	
	$("#searchGridPic").datagrid({
		toolbar : toolbar,
		queryParams:getQueryParams(),
		url : 'demoAction!listDemoByPage.do',
		columns : [[
		    {
				field: 'A',
				checkbox:'true',
				width:30
			},
		    {field:'alarmeventid',title:'alarmeventid',hidden:true,width:120, 
				formatter:function showClick(value,record,num){ 
					return "<a  href='javascript:void(0);' class='ahref' onclick='doUpdate("+num+")'>"+value+"</a>";
				}}
		]]
	});
}


function showExport(){
	$.showMsg("待开发");
}

function showJw(id){
	var url = top.sysUrl+"/yw/countalarm/jw/showJw.jsp";
	windowid = top.$.createWin({
		 title	: 	'无经纬度监控点列表',
		 width  :  '720',
		 height :  '400',
		 data:id,
		 url	:  url
	 });
}

function showCompute(id){
	var url = top.sysUrl+"/yw/countalarm/jw/showCompute.jsp";
	windowid = top.$.createWin({
		title	: 	'计算公式',
		width  :  '720',
		height :  '400',
		data:id,
		url	:  url
	});
}


