var currentstateid = $.getUrlParam("xh");

$(function(){
//	console.log("历史记录：",currentstateid);
	initDefault();	
});
//默认
function initDefault(){
	// 设置默认时间
	$("#startTime").datetimebox("setValue",$.getTodayStart(0,"00:00:00"));
	$("#endTime").datetimebox("setValue",$.getTodayEnd("23:59:59"));
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	sParam.sbid = currentstateid;
	sParam.startTime = $('#startTime').datetimebox("getValue");	
	sParam.endTime = $('#endTime').datetimebox("getValue");
	//sParam.order = "order by xjsj desc"
//	console.log("查询参数：",sParam);
	return sParam;
}
//加载列表
function initGrid(){	
	var toolbar = [/*{
    	text    :	'刷新',
        iconCls : 	'icon-refresh',
        handler : 	function(){location.reload(true);}
    },*/{
    	text	:	'查询',
        iconCls	:	'icon-search',
        handler	:	doSearch
    }];
	$('#tableGrid').datagrid({
		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : 'nhywjtledydpglAction!listYwydphistorystateByPage.do',
		columns : [[
			{field: 'xh', title: '编码', hidden: true, width: 120},
			{field: 'ledmc', title: 'led名称', hidden: false, width: 120},
			{
				field: 'ledbh', title: 'led编号', hidden: false, width: 120,},
			{field: 'pp', title: '品牌', hidden: false, width: 120},
			{field: 'ggxh', title: '规格型号', hidden: false, width: 120},
			{field: 'qybh', title: '区域编号', hidden: false, width: 120},
			{field: 'qymc', title: '区域名称', hidden: false, width: 120},
			{field: 'lkh', title: '路口号', hidden: false, width: 120},
			{field: 'lkmc', title: '路口名称', hidden: false, width: 120},
			{field:'xjsj',title:'巡检时间',hidden:true,width:120},
			{field: 'sbzt', title: '设备状态', hidden: true, width: 120,
				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>";
					}
				}
			}
			
		]]
	});
}

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

