var windowId,proName = window.location.pathname.split("/")[1],sysUrl = "http://"+window.location.host+"/"+proName,toEdit;
var winId	= $.getUrlParam("winId");
var records = top.$("#"+winId).panel("options").data;
$(function(){
	initDefault();	
});
//默认
function initDefault(){
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	var xzqh = records.xzqh;
	if(!xzqh || xzqh=="" || xzqh==null){
		sParam.videocatalog = "error";
		return sParam;
	}
	sParam.videocatalog = xzqh;
	var tableparam = "";
	var type = records.type;
	var state = records.state;
	if(type=="isonline"){//监控点是否在线详细展示
		if(state=='1'){//正常
			tableparam = " and isonline=1";
		}else{
			tableparam = " and isonline=0";
		}
	}else if(type=="video"){//监控点设备异常详细展示
		if(state=='1'){//正常
			tableparam = " and vqdstate=1";
		}else{
			tableparam = " and (vqdstate in (2,3,4))";
		}
	}
	sParam.tableparam =tableparam;
	sParam.order = "order by videonum desc ";
	return sParam;
}
//加载列表
function initGrid(){	
	$('#tableGrid').datagrid({
//		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : 'ywvideocurrentstateAction!listVideoDetailByPage.do',
		columns : [[
//			{field:'areacode',title:'行政区划编号',hidden:false,width:120},
			{field:'areaname',title:'行政区划名称',hidden:false,width:120,
				formatter:function showClick(value,record,num){ 
					return records.name;
				}
			},
			{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());
}

