lbStatuAnaly.html 15 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; }
	#forms > tbody > tr{
		background-color: #FFFFFF;
	}
</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 id="history" class="form-inline" action="">
					<div style="display: inline-block;margin-left: 5px;">
						<span class="item-label" style="width: 80px;">烂班原因: </span>
						<input class="form-control" type="checkbox" id="totalLb" style="width: 20px;" checked="true"/>全选 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="0" checked="true"/>路阻 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="1" checked="true"/>吊慢 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="2" checked="true"/>故障 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="3" checked="true"/>纠纷 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="4" checked="true"/>肇事 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="5" checked="true"/>缺人 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="6" checked="true"/>缺车 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="7" checked="true"/>客稀 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="8" checked="true"/>气候 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="9" checked="true"/>外援 
						<input class="form-control" type="checkbox" name="reason" style="width: 20px;" value="10" checked="true"/>其他 
					</div>
					<div style="margin-top: 5px"></div>
					<div style="display: inline-block;">
						<span class="item-label" style="width: 80px; margin-left: 33px">公司: </span>
						<select class="form-control" name="company" id="company" style="width: 140px;"></select>
					</div>
					<div style="display: inline-block;">
						<span class="item-label" style="width: 80px; margin-left: 24px">分公司: </span>
						<select class="form-control" name="subCompany" id="subCompany" style="width: 140px;"></select>
					</div>
					<div style="display: inline-block;">
						<span class="item-label" style="width: 80px; margin-left: 24px">线路: </span>
						<select class="form-control" name="line" id="line" style="width: 140px;"></select>
					</div>
					<div style="display: inline-block; margin-left: 10px">
						<span class="item-label" style="width: 80px;">时刻类型: </span>
						<select class="form-control" name="model" id="model" style="width: 165px;">
							<option value="">请选择...</option>
						</select>
					</div>
					<div style="margin-top: 10px"></div>
					<div style="display: inline-block;margin-left: 5px;">
						<span class="item-label" style="width: 80px;">开始时间: </span>
						<input class="form-control" type="text" id="startDate" style="width: 140px;"/>
					</div>
					<div style="display: inline-block;margin-left: 10px;">
						<span class="item-label" style="width: 80px;">结束时间: </span>
						<input class="form-control" type="text" id="endDate" style="width: 140px;"/>
					</div>
					<div style="display: inline-block;margin-left: 10px;">
						<span class="item-label" style="width: 80px;">时间段: </span>
						<input class="form-control" type="text" id="times1" style="width: 60px;"/>
					</div>
					<div style="display: inline-block;">
						<span class="item-label" style="width: 80px;"> - </span>
						<input class="form-control" type="text" id="times2" style="width: 60px;"/>
					</div>
					<div class="form-group" style="margin-left: 10px">
						<input class="btn btn-default" type="button" id="query" value="筛选"/>
<!-- 						<input class="btn btn-default" type="button" id="export" value="导出"/> -->
					</div>
				</form>
			</div>
			<div class="portlet-body">
				<div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px">
					<table class="table table-bordered table-hover table-checkable" id="forms">
						<thead>
						
						</thead>
						<tbody>
							
						</tbody>
					</table>
					<div style="text-align: right;">
						<ul id="pagination" class="pagination"></ul>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
	$(function(){

		
		// 关闭左侧栏
		if (!$('body').hasClass('page-sidebar-closed'))
			$('.menu-toggler.sidebar-toggler').click();
		
		$("#startDate").datetimepicker({
			format : 'YYYY-MM-DD',
			locale : 'zh-cn'
		});
		$("#endDate").datetimepicker({
			format : 'YYYY-MM-DD',
			locale : 'zh-cn'
		});
		$("#times1").datetimepicker({
			format : 'HH:mm',
			locale : 'zh-cn'
		});
		$("#times2").datetimepicker({
			format : 'HH:mm',
			locale : 'zh-cn'
		});
		
		var d = new Date();
		var year = d.getFullYear();
		var month = d.getMonth() + 1;
		var day = d.getDate();
		if(month > 9){
			$("#startDate").val(year + "-" + month + "-" + day);
			$("#endDate").val(year + "-" + month + "-" + day);
		} else {
			$("#startDate").val(year + "-0" + month + "-" + day);
			$("#endDate").val(year + "-0" + month + "-" + day);
		}
		$("#times1").val("06:00");
		$("#times2").val("07:00");
		
		$.get('/basic/lineCode2Name', function(result){
			var data=[];
			
			data.push({id: " ", text: "全部线路"});
			for(var code in result){
				data.push({id: code, text: result[code]});
			}
			console.log(data);
			initPinYinSelect2('#line',data,'');

			line = "";
			updateModel();
		})
		
		var obj = [];
		$.get('/user/companyData', function(result){
			obj = result;
			var options = '';
			for(var i = 0; i < obj.length; i++){
				options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
			}
			$('#company').html(options);
			updateCompany();
		});

		$("#company").on("change",updateCompany);
		function updateCompany(){
			var company = $('#company').val();
			var options = '';
			for(var i = 0; i < obj.length; i++){
				if(obj[i].companyCode == company){
					var children = obj[i].children;
					for(var j = 0; j < children.length; j++){
						options += '<option value="'+children[j].code+'">'+children[j].name+'</option>';
					}
				}
			}
			$('#subCompany').html(options);
		}
		
		var lb = 0;		//标志是否有选择至少一个烂班类型
		$("#totalLb").on("change", function(){
			var reason = $("input[name='reason']");
			var checked = this.checked;
			$.each(reason, function(i, g){
				g.checked = checked;
			});
			if(checked == true)
				lb = 30;
			else
				lb = 0;
		});
		
		$("input[name='reason']").on("change", function(){
			var totalLb = $("#totalLb")[0];
			totalLb.checked = true;
			lb = 0;
			$.each($("input[name='reason']"), function(i, g){
				if(g.checked == false){
					totalLb.checked = false;
				}else{
					lb += 3;
				}
			});
		});
		
		$("#query").on("click",jsDoQuery);

		var line = $("#line").val();
		var startDate = $("#startDate").val();
		var endDate = $("#endDate").val();
		var model = $("#model").val();
		var times = $("#times1").val() + "-" + $("#times2").val();
		function jsDoQuery(pagination){
			var reason = $("input[name='reason']");
			var params = {};
// 			line = $("#line").val();
			startDate = $("#startDate").val();
			endDate = $("#endDate").val();
			model = $("#model").val();
			times = $("#times1").val() + "-" + $("#times2").val();
			params['line'] = line;
			params['startDate'] = startDate;
			params['endDate'] = endDate;
			params['model'] = model;
			params['times'] = times;
			params['type'] = "query";
// 			$(".hidden").removeClass("hidden");
			$get('/busInterval/lbStatuAnaly', params, function(result){
				// 把数据填充到模版中
				var tbodyHtml = template('list_lbAnaly',{list:result, reason:reason, lb:lb});
				// 把渲染好的模版html文本追加到表格中
				$('#forms').html(tbodyHtml);
				_w_table_rowspan("#forms", 1);
				_w_table_rowspan("#forms", 2);
				_w_table_rowspan("#forms", 3);
				_w_table_rowspan("#forms", 4);
				_w_table_rowspan("#forms", 5);
			});
		}
		
		$("#export").on("click", function(){
			$get('/pcpc/workDaily',{line:line,date:date,type:'export'},function(result){
				window.open("/downloadFile/download?fileName=营运服务日报表"+moment(date).format("YYYYMMDD"));
			});
		});
		
		
		$("#line").on("change", function(){
			line = $("#line").val();
			if(line == " ")
				line = "";
			updateModel();
		});
		$('#startDate').on("blur", function(){
			startDate = $("#startDate").val();
			endDate = $("#endDate").val();
			updateModel();
		});
		$('#endDate').on("blur", function(){
			startDate = $("#startDate").val();
			endDate = $("#endDate").val();
			updateModel();
		});
		
		var flag = 0;
		function updateModel(){
			if(flag == 1)
				return;
			flag = 1;
			var treeData = [];
			var params = {};
			params['line'] = line;
			params['startDate'] = startDate;
			params['endDate'] = endDate;
			$get('/pcpc/getModel', params, function(result){
				treeData = createTreeData(result);
				var options = '<option value="">请选择...</option>';
				$.each(treeData, function(i, g){
					options += '<option value="'+g.id+'">'+g.name+'</option>';
				});
				$('#model').html(options)/* .select2() */;
				flag = 0;
			});
		}
		
		
		function _w_table_rowspan(_w_table_id, _w_table_colnum){
		    _w_table_firsttd = "";
		    _w_table_currenttd = "";
		    _w_table_SpanNum = 0;
		    _w_table_Obj = jQuery(_w_table_id + " tr td:nth-child(" + _w_table_colnum + ")");
		    _w_table_Obj.each(function(i){
		        if(i==0){
		            _w_table_firsttd = jQuery(this);
		            _w_table_SpanNum = 1;
		        }else{
		            _w_table_currenttd = jQuery(this);
		            if(_w_table_firsttd.text()==_w_table_currenttd.text()){
		                _w_table_SpanNum++;
		                _w_table_currenttd.hide(); //remove();
		                _w_table_firsttd.attr("rowSpan",_w_table_SpanNum);
		            }else{
		                _w_table_firsttd = jQuery(this);
		                _w_table_SpanNum = 1;
		            }
		        }
		    });
		}
		
		
	});
	
</script>
<script type="text/html" id="list_lbAnaly">
<thead>
	<tr>
		<th class="hidden"></th>
		<th rowspan="3">日期</th>
		<th rowspan="3">时段</th>
		<th rowspan="3">公司</th>
		<th rowspan="3">分公司</th>
		<th rowspan="3">线路</th>
		<th rowspan="2" colspan="3">总班次</th>
		<th rowspan="2" colspan="3">总营运公里</th>
		{{if lb != 0}}
			<th colspan={{lb}}>烂班原因</th>
		{{/if}}
	</tr>
	<tr>
		<th class="hidden"></th>
		{{if reason[0].checked == true}}<th colspan="3">路阻</th>{{/if}}
		{{if reason[1].checked == true}}<th colspan="3">吊慢</th>{{/if}}
		{{if reason[2].checked == true}}<th colspan="3">故障</th>{{/if}}
		{{if reason[3].checked == true}}<th colspan="3">纠纷</th>{{/if}}
		{{if reason[4].checked == true}}<th colspan="3">肇事</th>{{/if}}
		{{if reason[5].checked == true}}<th colspan="3">缺人</th>{{/if}}
		{{if reason[6].checked == true}}<th colspan="3">缺车</th>{{/if}}
		{{if reason[7].checked == true}}<th colspan="3">客稀</th>{{/if}}
		{{if reason[8].checked == true}}<th colspan="3">气候</th>{{/if}}
		{{if reason[9].checked == true}}<th colspan="3">外援</th>{{/if}}
		{{if reason[10].checked == true}}<th colspan="3">其他</th>{{/if}}
	</tr>
	<tr>
		<th class="hidden"></th>
		<th>计划</th><th>实际</th><th>百分比</th>
		<th>计划</th><th>实际</th><th>百分比</th>
		{{if reason[0].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[1].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[2].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[3].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[4].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[5].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[6].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[7].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[8].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[9].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
		{{if reason[10].checked==true}}<th>烂班班次</th><th>烂班公里</th><th>百分比</th>{{/if}}
	</tr>
</thead>
<tbody>
	{{each list as obj i}}
		<tr>
			<td>{{obj.date}}</td>
			<td>{{obj.times}}</td>
			<td>{{obj.company}}</td>
			<td>{{obj.subCompany}}</td>
			<td>{{obj.line}}</td>
			<td>{{obj.jhbc}}</td><td>{{obj.sjbc}}</td><td>{{obj.bcbfb}}</td>
			<td>{{obj.jhlc}}</td><td>{{obj.sjlc}}</td><td>{{obj.lcbfb}}</td>
			{{if reason[0].checked==true}}<td>{{obj.lzbc}}</td><td>{{obj.lzlc}}</td><td>{{obj.lzbfb}}</td>{{/if}}
			{{if reason[1].checked==true}}<td>{{obj.dmbc}}</td><td>{{obj.dmlc}}</td><td>{{obj.dmbfb}}</td>{{/if}}
			{{if reason[2].checked==true}}<td>{{obj.gzbc}}</td><td>{{obj.gzlc}}</td><td>{{obj.gzbfb}}</td>{{/if}}
			{{if reason[3].checked==true}}<td>{{obj.jfbc}}</td><td>{{obj.jflc}}</td><td>{{obj.jfbfb}}</td>{{/if}}
			{{if reason[4].checked==true}}<td>{{obj.zsbc}}</td><td>{{obj.zslc}}</td><td>{{obj.zsbfb}}</td>{{/if}}
			{{if reason[5].checked==true}}<td>{{obj.qrbc}}</td><td>{{obj.qrlc}}</td><td>{{obj.qrbfb}}</td>{{/if}}
			{{if reason[6].checked==true}}<td>{{obj.qcbc}}</td><td>{{obj.qclc}}</td><td>{{obj.qcbfb}}</td>{{/if}}
			{{if reason[7].checked==true}}<td>{{obj.kxbc}}</td><td>{{obj.kxlc}}</td><td>{{obj.kxbfb}}</td>{{/if}}
			{{if reason[8].checked==true}}<td>{{obj.qhbc}}</td><td>{{obj.qhlc}}</td><td>{{obj.qhbfb}}</td>{{/if}}
			{{if reason[9].checked==true}}<td>{{obj.wybc}}</td><td>{{obj.wylc}}</td><td>{{obj.wybfb}}</td>{{/if}}
			{{if reason[10].checked==true}}<td>{{obj.qtbc}}</td><td>{{obj.qtlc}}</td><td>{{obj.qtbfb}}</td>{{/if}}
		</tr>
	{{/each}}
	{{if list.length == 0}}
		<tr>
			<td colspan="44"><h6 class="muted">没有找到相关数据</h6></td>
		</tr>
	{{/if}}
</tbody>
</script>