var windowId,proName = window.location.pathname.split("/")[1],sysUrl = "http://"+window.location.host+"/"+proName,toEdit;

$(function(){
	initDefault();	
});
//默认
function initDefault(){
	// 默认时间
	$("#startTime").datetimebox("setValue",$.getTodayStart(0,"00:00:00"));
	$("#endTime").datetimebox("setValue",$.getTodayEnd("23:59:59"));
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	sParam.LIKEname = $("#LIKEname").textbox("getValue");
	sParam.startTime = $('#startTime').datetimebox("getValue");	
	sParam.endTime = $('#endTime').datetimebox("getValue");
	sParam.detectortype=$('#detectortype').val();
	sParam.order = "order by name desc"
	return sParam;
}
//加载列表
function initGrid(){	
	var toolbar = [{
    	text	:	'查询',
        iconCls	:	'icon-search',
        handler	:	doSearch
    }];
	$('#tableGrid').datagrid({
		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : 'detectorAction!listDetectorhistorystateByPage.do',
		columns : [[
			{field:'name',title:'名称',hidden:false,width:120},
			{field:'bianma',title:'备案编码18位',hidden:false,width:120},
			{field:'detfrequency',title:'数据采集频率',hidden:false,width:60},
			{field:'longitude',title:'经度',hidden:false,width:60},
			{field:'latitude',title:'纬度',hidden:false,width:60},
			{field:'roadname',title:'道路名称',hidden:false,width:110},
			{field:'roadid',title:'道路编码',hidden:false,width:120},
			{field:'bianma2',title:'设备私有编码',hidden:false,width:60},
			{field:'factoryid',title:'厂商编码',hidden:false,width:120},
			{field:'regionid',title:'行政区划编码',hidden:false,width:120},
			{field:'updatetime',title:'更新时间',hidden:false,width:250},
			{field:'create_time',title:'检测时间',hidden:false,width:250},
			{field:'zt',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==2){//2停用，//3报废
						return "<div style='height:13px;width:13px;background-color:red;border-radius:50%;-moz-border-radius: 50%;-webkit-border-radius: 50%;margin:0 auto;'></div>";
					}else{
						return "报废";
					}
				}
			}

		]]
	});
}

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

