lbStatuAnaly.html 14.3 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 id="history" class="form-inline" action="">
					<div style="display: inline-block;margin-left: 15px;">
						<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>
					<br/>
					<div style="display: inline-block;margin-left: 15px;">
						<span class="item-label" style="width: 80px;">公司: </span>
						<select class="form-control" name="company" id="company" style="width: 180px;"></select>
					</div>
					<div style="display: inline-block;margin-left: 15px;">
						<span class="item-label" style="width: 80px;">分公司: </span>
						<select class="form-control" name="subCompany" id="subCompany" style="width: 180px;"></select>
					</div>
					<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;">
						<span class="item-label" style="width: 80px;">时刻类型: </span>
						<select class="form-control" name="model" id="model" style="width: 180px;">
							<option value="">请选择...</option>
						</select>
					</div>
					<br/>
					<div style="display: inline-block;margin-left: 15px;">
						<span class="item-label" style="width: 80px;">开始时间: </span>
						<input class="form-control" type="text" id="startDate" style="width: 180px;"/>
					</div>
					<div style="display: inline-block;margin-left: 15px;">
						<span class="item-label" style="width: 80px;">结束时间: </span>
						<input class="form-control" type="text" id="endDate" style="width: 180px;"/>
					</div>
					<div style="display: inline-block;">
						<span class="item-label" style="width: 80px;">时间段: </span>
						<select class="form-control" name="model" id="times" style="width: 180px;">
							<option value="05:00-06:00">05:00-06:00</option>
							<option value="06:00-07:00">06:00-07:00</option>
							<option value="07:00-08:00">07:00-08:00</option>
							<option value="08:00-09:00">08:00-09:00</option>
							<option value="09:00-10:00">09:00-10:00</option>
							<option value="10:00-11:00">10:00-11:00</option>
							<option value="11:00-12:00">11:00-12:00</option>
							<option value="12:00-13:00">12:00-13:00</option>
							<option value="13:00-14:00">13:00-14:00</option>
							<option value="14:00-15:00">14:00-15:00</option>
							<option value="15:00-16:00">15:00-16:00</option>
							<option value="16:00-17:00">16:00-17:00</option>
							<option value="17:00-18:00">17:00-18:00</option>
							<option value="18:00-19:00">18:00-19:00</option>
							<option value="19:00-20:00">19:00-20:00</option>
							<option value="20:00-21:00">20:00-21:00</option>
							<option value="21:00-22:00">21:00-22:00</option>
							<option value="22:00-23:00">22:00-23:00</option>
							<option value="23:00-00:00">23:00-00:00</option>
						</select>
					</div>
					<div class="form-group">
						<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'
		});
		
		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);
		}
		
		$.get('/basic/lineCode2Name', function(result){
			var data=[];
			
			for(var code in result){
				data.push({id: code, text: result[code]});
			}
// 			console.log(data);
			initPinYinSelect2('#line',data,'');

			line = data[0].id;
			updateModel();
		})
		
		var obj = [];
		$.get('/user/companyData', function(result){
			obj = result;
			var options = '';
			for(var i = 0; i < obj.length; i++){
// 				alert(obj[i].children.length);
				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 = $("#times").val();
		function jsDoQuery(pagination){
			var reason = $("input[name='reason']");
			var params = {};
			line = $("#line").val();
			startDate = $("#startDate").val();
			endDate = $("#endDate").val();
			model = $("#model").val();
			times = $("#times").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);
			});
		}
		
		$("#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();
			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;
			});
		}
		
		
	});
	
</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="41"><h6 class="muted">没有找到相关数据</h6></td>
		</tr>
	{{/if}}
</tbody>
</script>