speedingListmh.html 12.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
<div class="page-head">
	<div class="page-title">
		<h1>超速异常</h1>
	</div>
</div>

<ul class="page-breadcrumb breadcrumb">
	<li><a href="/pages/home.html" data-pjax>主页</a> <i class="fa fa-circle"></i></li>
	<li><span class="active">异常查看</span> <i class="fa fa-circle"></i></li>
	<li><span class="active">超速异常</span></li>
</ul>

<div class="row">
	<div class="col-md-12">
		<!-- Begin: life time stats -->
		<div class="portlet light portlet-fit portlet-datatable bordered">
			<div class="portlet-title">
				<div class="caption">
					 <i class="fa fa-times-circle"></i> <span
						class="caption-subject font-dark sbold uppercase">超速异常数据表</span>
				</div>
				<div class="actions">
<!-- 					<a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加用户</a> -->
					<!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> ɾ���û�</button> -->
					<!-- <div class="btn-group">
						<a class="btn red btn-outline btn-circle" href="javascript:;"
							data-toggle="dropdown"> <i class="fa fa-share"></i> <span
							class="hidden-xs"> 系统工具</span> <i class="fa fa-angle-down"></i>
						</a>
						<ul class="dropdown-menu pull-right" id="datatable_ajax_tools">
							<li><a href="javascript:;" data-action="0"
								class="tool-action"> <i class="fa fa-print"></i>打印
							</a></li>
							<li><a href="javascript:;" data-action="1"
								class="tool-action"> <i class="fa fa-copy"></i> 复制
							</a></li>
							<li><a href="javascript:;" data-action="3"
								class="tool-action"> <i class="fa fa-file-excel-o"></i>
									导出Excel
							</a></li>
							<li class="divider"></li>
							<li><a href="javascript:;" data-action="5"
								class="tool-action"> <i class="fa fa-refresh"></i> 刷新数据
							</a></li>
						</ul>
					</div> -->
				</div>
			</div>
			<div class="portlet-body">
				<div class="table-container" style="margin-top: 10px">
					<table
						class="table table-striped table-bordered table-hover table-checkable"
						id="datatable_speeding">
						<thead>
							<tr role="row" class="heading">
								<th width="3%">#</th>
								<th width="4%">线路</th>
								<th width="6%">车辆自编号</th>
								<th width="8%">上下行</th>
								<th width="10%">开始时间</th>
								<th width="10%">结束时间</th>
								<th width="8%">持续时间</th>
								<th width="8%">查看轨迹</th>
								<th width="6%">操作</th>
							</tr>
							<tr role="row" class="filter">
								<td></td>
								<td>
										<select class="form-control" name="line" id="line" style="width: 100px;"></select>
								</td>
								<td>
										<select class="form-control" name="nbbm" id="nbbm" style="width: 100px;"></select>
								</td>
								<!-- <td>
									
								</td>
								<td>
								</td> -->
								<td>
									<select class="form-control form-filter " name="updown" style="width: 90px;">
                                         <option value="">请选择...</option>
                                         <option value="0">上行</option>
                                         <option value="1">下行</option>
                                         <option value="-1">无效</option>
                                     </select>
								</td>
								<td> 
									<input class="form-control" type="date" name="startDate" />
									-
									<input class="form-control" type="date" name="endDate" />
								</td>
								<td>
								</td>
								<td>
								</td>
								<td>
								</td>
								<td>
									<button class="btn btn-sm green btn-outline filter-submit margin-bottom" >
                                                                <i class="fa fa-search"></i> 搜索</button>
                                                                
									<button class="btn btn-sm red btn-outline filter-cancel">
                                                            <i class="fa fa-times"></i> 重置</button>
								</td>
							</tr>
						</thead>
						<tbody></tbody>
					</table>
					<div style="text-align: right;">
						<ul id="pagination" class="pagination"></ul>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script id="speeding_list_temp" type="text/html">
{{each list as obj i}}
<tr>
	<td style="vertical-align: middle;">
		<input type="checkbox" class="group-checkable icheck" data-id="{{obj.id}}">
	</td>
	<td>
		{{obj.lineName}}
	</td>
	<td>
		{{obj.vehicle}}
	</td>
	<td>
		{{if obj.up_down==0}}
			上行
		{{else if obj.up_down==1}}
			下行 
		{{else}}
			无效
		{{/if}}
	</td>	
	<td>
		{{obj.timestampDate}}
	</td>
	<td>
		{{obj.endtimestampDate}}
	</td>
	<td>
		{{(obj.endtimestamp-obj.timestamp)/1000}}
	</td>
	<td>
		<a class="btn default blue-stripe btn-sm lookTrajectory" data-vehicle ="{{obj.vehicle}}"
			data-startdate="{{obj.timestampDate}}" data-enddate="{{obj.endtimestampDate}}"
			data-lon="{{obj.lon}}"  data-lat="{{obj.lat}}" 
			data-endlon="{{obj.endlon}}"  data-endlat="{{obj.endlat}}" >
			查看轨迹
		</a>
	</td>
	<td>
		
	</td>
</tr>
{{/each}}
{{if list.length == 0}}
<tr>
	<td colspan=8><h6 class="muted">没有找到相关数据</h6></td>
</tr>
{{/if}}
</script>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script>

<script>
$(function(){
	var page = 0, initPagination;
	var icheckOptions = {
	    checkboxClass: 'icheckbox_flat-blue',
	    increaseArea: '20%'
	}
	
	var date = new Date();
	var week = date.getDay();//表明今天是周几。0-6表示周日到周六
	var dateTime = date.getTime();//当前时间的时间戳,单位秒。		
	
 	var endTime = dateTime-week*24*3600*1000;//上周末、格式为时间戳。
	var startTime = endTime-6*24*3600*1000;//上周一、格式为时间戳。
	debugger;
	var endDate = timeToData(endTime);
	var startDate = timeToData(startTime);
 	//表单默认选择上周一到上周日的超速信息。
 	$("input[name='endDate']")[0].value = endDate;
 	$("input[name='startDate']")[0].value = startDate;
 	var parameter = new Object();
 	parameter.endDate = $("input[name='endDate']")[0].value;
 	parameter.startDate = $("input[name='startDate']")[0].value;
 	 
 	//搜索线路
	$.get('/basic/lineCode2Name',function(result){
		var data=[];
		data.push({id: " ", text: "全部线路"});
		for(var code in result){
			data.push({id: code, text: result[code]});
		}
		initPinYinSelect2($('#line'),data,function(ldmcSelector) {
			ldmcSelector.select2("val",data[1].id);//因为数据量太大,所以默认一条线路作为查询参数
		});
		parameter.line = data[1].id;
		jsDoQuery(parameter,true);
	});
	
	//时间戳转换为年月日
	function timeToData(time){
		var date = new Date(time);
		var year = date.getFullYear();
		var Month = date.getMonth()+1>10?date.getMonth()+1:"0"+(date.getMonth()+1); 
 		var Day = date.getDate()>9?date.getDate():"0"+date.getDate();
		return year+"-"+Month+"-"+Day;
	}
	
	//重置
	$('tr.filter .filter-cancel').on('click', function(){
		$('tr.filter input, select').val('').change();
		jsDoQuery(null, true);
	});
	
	//提交
	$('tr.filter .filter-submit').on('click', function(){
		var cells = $('tr.filter')[0].cells
			,params = {}
			,name;
		$.each(cells, function(i, cell){
			var items = $('input,select', cell);
			for(var j = 0, item; item = items[j++];){
				name = $(item).attr('name');
				if(name){
					params[name] = $(item).val();
				}
			}
		});
		page = 0;
		jsDoQuery(params, true);
	});
	
	/*
	* 获取数据 p: 要提交的参数, pagination: 是否重新分页
	*/
 	function jsDoQuery(p, pagination){
		var params = {};
		if(p)
			params = p;
		//更新时间排序
		params['order'] = 'lastLoginDate';
		params['page'] = page;
		var i = layer.load(2);
		$get('/gps/pagequery' ,params, function(data){
			var bodyHtm = template('speeding_list_temp', {list: data.dataList});
			$('#datatable_speeding tbody').html(bodyHtm)
					.find('.icheck').iCheck(icheckOptions)
					.on('ifChanged', iCheckChange);
			if(pagination && data.dataList.length > 0){
				//重新分页
				initPagination = true;
				showPagination(data);
			}
			layer.close(i);
  			$(".lookTrajectory").click(function(){
  				var vehicle = $(this).data('vehicle');
  				var startDate = $(this).data('startdate');
  				var endDate = $(this).data('enddate');
  				var lon = $(this).data('lon');
  				var lat = $(this).data('lat');
  				var endLon = $(this).data('endlon');
  				var endLat = $(this).data('endlat');
  				var storage = window.localStorage;
  				storage.setItem("zbhAndDate",vehicle+","+startDate+","+endDate+","+lon+","+lat+","+endLon+","+endLat);
 				$.get('/pages/excep/speedingMap.html?',function (result) {
			    	layer.open({
						type: 1,
						title:'<i class="uk-icon-play-circle"></i>轨迹回放',
						shadeClose: true,
						shade: true,
						scrollbar: false,
						maxmin: false, //开启最大化最小化按钮
						area: ['100%', '100%'],
					    content:result,//内容
					});
			    });
			}) 
		});
	}
	
	function iCheckChange(){
		var tr = $(this).parents('tr');
		if(this.checked)
			tr.addClass('row-active');
		else
			tr.removeClass('row-active');
		
		if($('#datatable_resource input.icheck:checked').length == 1)
			$('#removeButton').removeAttr('disabled');
		else
			$('#removeButton').attr('disabled', 'disabled');
	}
	
	function showPagination(data){
		//分页
		$('#pagination').jqPaginator({
		    totalPages: data.totalPage,//总页数
		    visiblePages: 6,// 中间显示页数
		    currentPage: page + 1,
		    first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
            last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
		    onPageChange: function (num, type) {
		    	if(initPagination){
		    		initPagination = false;
		    		return;
		    	}	
		    	page = num - 1;
		    	var cells = $('tr.filter')[0].cells
				,params = {}
				,name;
				$.each(cells, function(i, cell){
					var items = $('input,select', cell);
					for(var j = 0, item; item = items[j++];){
						name = $(item).attr('name');
						if(name){
							params[name] = $(item).val();
						}
					}
				});
		    	jsDoQuery(params, false);
		    }
		});
	}
	
	
	//删除
	$('#removeButton').on('click', function(){
		if($(this).attr('disabled'))
			return;
		
		var id = $('#datatable_resource input.icheck:checked').data('id');
		
		removeConfirm('确定要删除选中的数据?', '/resource/' + id ,function(){
			$('tr.filter .filter-submit').click();
		});
	});

$("#line").on("change",initXl);
function initXl(){
$('#nbbm').select2({
    placeholder: '搜索车辆...',
    ajax: {
        url: '/report/carList',
        dataType: 'json',
        delay: 150,
        data: function (params) {
        	   return {nbbm: params.term,
           	    gsbm:"",
           	    fgsbm:"",
           	    xlbm:$('#line').val()}; 	
        },
        processResults: function (data) {
        	console.log(data);
            return {
                results: data
            };
        },
        cache: true
    },
    templateResult: function (repo) {
        if (repo.loading) return repo.text;
        var h = '<span>' + repo.text + '</span>';
        h += (repo.lineName ? '&nbsp;<span class="select2-desc">' + repo.lineName + '</span>' : '');
        return h;
    },
    escapeMarkup: function (markup) {
        return markup;
    },
    minimumInputLength: 1,
    templateSelection: function (repo) {
        return repo.text;
    },
    language: {
        noResults: function () {
            return '<span style="color:red;font-size: 12px;">没有搜索到车辆!</span>';
        },
        inputTooShort: function (e) {
            return '<span style="color:gray;font-size: 12px;"><i class="fa fa-search"></i> 输入自编号搜索车辆</span>';
        },
        searching: function () {
            return '<span style="color:gray;font-size: 12px;"> 正在搜索车辆...</span>';
        }
    }
});
}


//改变状态
function changeEnabled(id,enabled){
	$get('/user/changeEnabled',{id:id,enabled:enabled},function(result){
		jsDoQuery(null, true);
	})
}
});
</script>