var windowId,proName = window.location.pathname.split("/")[1],sysUrl = "http://"+window.location.host+"/"+proName,toEdit;
var winId	= $.getUrlParam("winId");
var record = top.$("#"+winId).panel("options").data;
$(function(){
	initDefault();	
});
//默认
function initDefault(){
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	sParam.areacode = record.xzqh;
	var tableparam = "";
	var type = record.type;
	if(type=="1"){//无经纬度
		tableparam = " and (longitude='' or longitude is null) and (dimension='' or dimension is null)";
	}else if(type=="2"){//缺失
		tableparam = " and (longitude='' or longitude is null) or (dimension='' or dimension is null)";
	}else if(type=="3"){//无效
		tableparam = " and (longitude+0) NOT BETWEEN  -180 and 180  or (dimension+0) NOT BETWEEN -90 and 90 "
	}else if(type=="4"){//正常
		tableparam = " and (longitude+0) BETWEEN  -180 and 180  or (dimension+0) BETWEEN -90 and 90 ";
	}
	sParam.tableparam =tableparam;
	sParam.order = "order by videonum desc ";
	return sParam;
}
//加载列表
function initGrid(){	
	$('#tableGrid').datagrid({
//		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : 'ywarchivevideoinfoAction!listYwarchivevideoinfoByPage.do',
		columns : [[
		   /* {
				field: 'A',
				checkbox:'true',
				width:30
			},
		    {field:'countId',title:'countId',hidden:true,width:120, 
				formatter:function showClick(value,record,num){ 
					return "<a  href='javascript:void(0);' class='ahref' onclick='doUpdate("+num+")'>"+value+"</a>";
				}
 			},*/
			{field:'areacode',title:'行政区划编号',hidden:false,width:120},
//			{field:'areaname',title:'行政区划名称',hidden:false,width:120},
			
			{field:'channelname',title:'通道名称',hidden:false,width:120},
			{field:'videonum',title:'设备编号',hidden:false,width:120},
			{field:'channelnum',title:'通道编号',hidden:false,width:120},
			{field:'videoip',title:'IP',hidden:false,width:120},
		]]
	});
}

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

//导出
function doExport(){
	var model = getQueryParams();
	$.ajax({
		type : 'post',
		dataType : 'json',
		data : model,
		url : 'ywcountlalcollectAction!count_Ywcountlalcollect.do',
		success : function(value) {
			if(!$.isNull(value)){
				countExport(value);
			}else{
				$.showMsg("操作失败！");
			}
		}
	});
}
// 导出传参条件
function countExport(totalSize) {
	var limit = 5000;
	if (totalSize > 5000) {
		top.$.dlg.confirm('记录过多支持前5000条,确定要将记录导出Excel为表格吗?',function(){ 
			execExport();
		});		
	} else {
		top.$.dlg.confirm('确认导出?',function(){ 
			execExport();
		})
	}
}
// 调用后台
function execExport() {
	var model = getQueryParams();
	var downParam = "";
	document.excelForm.action = 'ywcountlalcollectAction!exp_Ywcountlalcollect.do?'+downParam;
	document.excelForm.submit(); 
}
