var windowId,proName = window.location.pathname.split("/")[1],sysUrl = "http://"+window.location.host+"/"+proName,toEdit;
var winId	= $.getUrlParam("winId");
var obj = top.$("#"+winId).panel("options").data;
$(function(){
	initDefault();	
});
//默认
function initDefault(){
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	sParam.sblb='3';
	if(obj.deviceType=="xhdOnline"){
			sParam.tableparam = " and state is not null and state!='20' ";
	}else if(obj.deviceType=="xhdUnOnline"){
			sParam.tableparam ='and (state=20 or state is null) ';
	}
	sParam.LIKExhdmc = $("#LIKExhdmc").textbox("getValue");
	sParam.order = "order by xhdmc desc ";
	return sParam;
}
//加载列表
function initGrid(){	
	var toolbar = [{
    	text	:	'查询',
        iconCls	:	'icon-search',
        handler	:	doSearch
    }];
	var  urlstr="nhywjtxhdglAction!getALLxhdStatusData.do";
	if(obj.deviceType=="xhdOnline") {
		urlstr='szMapStatisAction!getMapDeviceStatusData.do';
	}
	$('#tableGrid').datagrid({
		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : urlstr,
		columns : [[
		    {
				field: 'A',
				checkbox:'true',
				width:30
			},
			{field: 'xhdmc', title: '信号灯名称', hidden: false, width: 120},
		{field: 'xhdbh', title: '信号灯编号', hidden: false, width: 120},
		{field: 'qymc', title: '区域名称', hidden: false, width: 120},
		{field: 'lkmc', title: '路口名称', hidden: false, width: 120},
		]]
	});
}
//查询
function doSearch(){
	$('#tableGrid').datagrid('load',getQueryParams());
}

function transEmpty(str){
	if(!str || str==null ||str=="null"){
		return "-";
	}
	return str;
}