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 = {};
	if(obj.deviceType=="ydpOnline"){
			sParam.sbzt = 1;
	}else if(obj.deviceType=="ydpUnOnline"){
			sParam.tableparam ="and  (sbzt ='0' or sbzt is null) ";
	}
	sParam.LIKEledmc = $("#LIKEledmc").textbox("getValue");
	//sParam.order = "order by xjsj desc ";
	return sParam;
}
//加载列表
function initGrid(){	
	var toolbar = [{
    	text	:	'查询',
        iconCls	:	'icon-search',
        handler	:	doSearch
    }];
	var  urlstr="listNhywjtledydpglUnonlineStatusByPage.do";
	if(obj.deviceType=="ydpOnline"){
		urlstr="listNhywjtledydpglStatusByPage.do";
	}

	$('#tableGrid').datagrid({
		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : 'nhywjtledydpglAction!'+urlstr,
		columns : [[
		    {
				field: 'A',
				checkbox:'true',
				width:30
			},
			{field: 'ledmc', title: 'LED名称', hidden: false, width: 120},
		{field: 'ledbh', title: 'LED编号', hidden: false, width: 120},
		{field: 'qymc', title: '区域名称', hidden: false, width: 120},
		{field: 'lkmc', title: '路口名称', hidden: false, width: 120},
		{field: 'xjsj', title: '检测时间', hidden: false, width: 125,
			formatter: function (value, row, index) {
				if(value==null || value=='' ||value=='null' || value===undefined) {
					return "";
				}else {
					return new Date(value).format("yyyy-MM-dd hh:mm:ss");
				}
			}
		},
		{
			field: 'sbzt', 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>";
				}
// 					else{
//						return value;
//					}
			}
		}
		]]
	});
}
//查询
function doSearch(){	
	$('#tableGrid').datagrid('load',getQueryParams());
}

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