message.html 8.67 KB
<style type="text/css">
	.table-bordered {
	  border: 1px solid; }
	  .table-bordered > thead > tr > th,
	  .table-bordered > thead > tr > td,
	  .table-bordered > tbody > tr > th,
	  .table-bordered > tbody > tr > td,
	  .table-bordered > tfoot > tr > th,
	  .table-bordered > tfoot > tr > td {
	    border: 1px solid; }
	  .table-bordered > thead > tr > th,
	  .table-bordered > thead > tr > td {
	    border-bottom-width: 2px; }
	 
	 .table > tbody + tbody {
	   border-top: 1px solid; }
</style>

<div class="page-head">
	<div class="page-title">
		<h1>调度消息分析</h1>
	</div>
</div>

<div class="row">
	<div class="col-md-12">
		<div class="portlet light porttlet-fit bordered">
			<div class="portlet-title">
				<form class="form-inline" action="">
					<div style="display: inline-block;">
						<span class="item-label" style="width: 80px;">线路: </span>
						<select class="form-control" name="line" id="line" style="width: 180px;"></select>
					</div>
					<div style="display: inline-block;margin-left: 15px;">
						<span class="item-label" style="width: 80px;">时间: </span>
						<input class="form-control" type="text" id="date" style="width: 180px;"/>
					</div>
					<div style="display: inline-block;margin-left: 15px">
						<span class="item-label" style="width: 140px;">内部编码: </span>
						<select class="form-control" name="code" id="code" style="width: 180px;"></select>
					</div>
					<div class="form-group" style="display: inline-block;margin-left: 15px;">
						<input class="btn btn-default" type="button" id="query" value="查询"/>
						<input class="btn btn-default" type="button" id="export" value="导出"/>
<!-- 						<input class="btn btn-default" type="button" id="print" value="打印"/> -->
<!-- 						<input class="btn btn-default" type="button" id="exportMore" value="批量导出"/> -->
					</div>
				</form>
			</div>
			<div class="portlet-body">
				<div class="row">
					<div class="col-md-3">
						<div class="" id="left_table" style="margin-top: 10px;overflow:auto;height: 860px">
							<table class="table table-bordered table-hover table-checkable pre-scrollable" id="info_msg">
								<thead>
									<tr class="hidden">
										<th>线路</th>
										<th>自编号</th>
										<th>路牌</th>
										<th>请求次数</th>
									</tr>
								</thead>
								<tbody>
									
								</tbody>
							</table>
						</div>
					</div>
					<div class="col-md-9"  id="printArea">
						<div class="table-container" id="table" style="margin-top: 10px;overflow:auto;min-width: 906px">
							<table class="table table-bordered table-hover table-checkable" id="forms">
								<thead>
									<tr class="hidden">
										<th>序号</th>
										<th>线路</th>
<!-- 										<th>路牌</th> -->
										<th>运营车辆</th>
										<th>发送人</th>
										<th>发送时间</th>
										<th>调度消息内容</th>
									</tr>
								</thead>
								<tbody>
									
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
	$(function(){
		$('#print').attr('disabled', "true");
		$('#export').attr('disabled', "true");
		$('#printArea').hide();
		
		// 关闭左侧栏
		if (!$('body').hasClass('page-sidebar-closed'))
			$('.menu-toggler.sidebar-toggler').click();
		
		$("#date").datetimepicker({
			format : 'YYYY-MM-DD',
			locale : 'zh-cn'
		});
		
		$("#left_table").height($(window).height()-100);
		$("#table").height($(window).height()-100);
		
		var d = new Date();
		var year = d.getFullYear();
		var month = d.getMonth() + 1;
		var day = d.getDate();
		if(month < 9)
			month = "0" + month;
		if(day < 9)
			day = "0" + day;
		$("#date").val(year + "-" + month + "-" + day);
		
		$.get('/report/lineList',function(xlList){
			var data = [];
			$.get('/user/companyData', function(result){
				for(var i = 0; i < result.length; i++){
					var companyCode = result[i].companyCode;
					var children = result[i].children;
					for(var j = 0; j < children.length; j++){
						var code = children[j].code;
						for(var k=0;k < xlList.length;k++ ){
							if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){
								data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]});
							}
						}
					}
				}
				initPinYinSelect2('#line',data,'');
				
			});
		});
		$('#code').select2({
			ajax: {
				url: '/realSchedule/sreachVehic',
				dataType: 'json',
				delay: 150,
				data: function(params){
					return{nbbm: params.term};
				},
			    processResults: function (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>';
			   }
			}
		});
		
		var date = '';
		var line = $("#line").val();
		var lineName = $('#line option:selected').text();
		$("#query").on("click",function(){
			if($("#date").val() == null || $("#date").val().trim().length == 0){
				layer.msg("请选择时间!");
				return;
			}
			$("#left_table").height($(window).height()-100);
			line = $("#line").val();
			date = $("#date").val();
			var code = $("#code").val();
			$(".hidden").removeClass("hidden");
			$get('/report/historyMessageCount',{line:line,date:date,code:code},function(result){
				// 把数据填充到模版中
				var tbodyHtml = template('list_msg_info',{list:result});
				// 把渲染好的模版html文本追加到表格中
				$('#info_msg tbody').html(tbodyHtml);

				$('#print').attr('disabled', "true");
				$('#export').attr('disabled', "true");
				$('#printArea').hide();
				
			});
		});
		
		var params = new Array();
		var jName = '';
		$("#info_msg tbody").on("click","tr",function(){
			if($(this).children().size() < 2){
				return;
			}
			$("#table").height($(window).height()-100);
			$(this).children().each(function(index){
				params[index] = $(this).text();
			});
			jName = params[1];
			line = $("#line").val();
			date = $("#date").val();
			lineName = $('#line option:selected').text();
			var obj = $(this);
			$get('/report/historyMessageList',{line:line,date:date,code:jName,type:"query"},function(result){
				var list_history_msg = template('list_history_msg',{list:result});
				// 把渲染好的模版html文本追加到表格中
				$('#forms tbody').html(list_history_msg);

				if(result.length == 0){
					$('#export').attr('disabled', "true");
					$('#print').attr('disabled', "true");
				} else {
					$("#export").removeAttr("disabled");
					$("#print").removeAttr("disabled");
				}
				$('#printArea').show();
				
				$("#info_msg tbody tr").css('background-color', '');
			    obj.css('background-color', '#99CCFF');
			});
		});
		
		$("#export").on("click",function(){
			$get('/report/historyMessageList',{line:line,date:date,code:jName,type:"export_msg"},function(result){
				window.open("/downloadFile/download?fileName="
						+moment(date).format("YYYYMMDD")+"-"+lineName+"-调度消息分析");
			});
		});
		
		$("#print").click(function(){
			$("#printArea").printArea();
		});
		
		$("#exportMore").on("click",function(){
			return;
			$post('/realSchedule/exportWaybillMore',{date:date},function(result){
				window.open("/downloadFile/download?fileName="+jName);
			});
		});
		
	});
</script>
<script type="text/html" id="list_msg_info">
	{{each list as obj i}}
		<tr>
			<td width="25%">{{obj[0]}}\{{obj[1]}}</td>
			<td width="25%">{{obj[2]}}</td>
			<td width="25%">{{obj[1]}}</td>
			<td width="25%">{{obj[3]}}</td>
		</tr>
	{{/each}}
	{{if list.length == 0}}
		<tr>
			<td colspan="4"><h6 class="muted">没有找到相关数据</h6></td>
		</tr>
	{{/if}}
</script>
<script type="text/html" id="list_history_msg">
   {{each list as obj i}}
		<tr>
			<td>{{i+1}}</td>
			<td>{{obj[0]}}</td>
		<!--<td>{{obj[6]}}</td>-->
			<td>{{obj[1]}}</td>
			<td>{{obj[2]}}</td>
			<td>{{obj[3]}}</td>
			<td>{{obj[4]}}</td>
		</tr>
	{{/each}}
	{{if list.length == 0}}
		<tr>
			<td colspan="7"><h6 class="muted">没有找到相关数据</h6></td>
		</tr>
	{{/if}}	
</script>