waybillday.html 7.9 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;
	    text-align: center; }
	 
	 .table > tbody + tbody {
	   border-top: 1px solid; }
</style>

<div class="page-head">
	<div class="page-title" style="width:99%;">
		<h1 style="float:left;">行车路单日报表</h1>
		<i class="fa fa-info" style="float:right;" title="本表计算能耗加注量时,油车统计油量,电车统计电量;&#10;25年3月底更新后电量保留三位小数。"></i>
	</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="" method="post">
				 <div style="display: inline-block; margin-left: 33px;" id="gsdmDiv_waybillday">
						<span class="item-label" style="width: 80px;">公司: </span>
						<select class="form-control" name="company" id="gsdmWaybillday" style="width: 140px;"></select>
					</div> 
					<div style="display: inline-block; margin-left: 24px;" id="fgsdmDiv_waybillday">
						<span class="item-label" style="width: 80px;">分公司: </span>
						<select class="form-control" name="subCompany" id="fgsdmWaybillday" style="width: 140px;"></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;margin-left: 15px;">
                        <span class="item-label" style="width: 80px;">时间: </span>
                        <input class="form-control" type="text" id="date" style="width: 180px;"/>
                    </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>
							<tr>
								<th>车号</th>
								<th>空驶公里</th>
								<th>加注量</th>
								<th>机油</th>
								<th>损耗</th>
								<th>驾驶员</th>
								<th>里程</th>
								<th>油耗</th>
							</tr>
						</thead>
						<tbody>
							
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
	$(function(){
		var reqCodeMap = {"0xA1": '请求恢复运营', "0xA2": '申请调档', "0xA3": '出场请求', "0xA5": '进场请求', "0xA7": '加油请求', "0x50": '车辆故障', "0x70": '路阻报告', "0x60": '事故报告', "0x11": '扣证纠纷', "0x12" : '报警'};
		// 关闭左侧栏
		if (!$('body').hasClass('page-sidebar-closed'))
			$('.menu-toggler.sidebar-toggler').click();
		
		$("#date").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 < 10)
			month = "0" + month;
		if(day < 10)
			day = "0" + day;
		$("#date").val(year + "-" + month + "-" + day);
		var fage=false;
		var obj = [];
		var xlList;
		$.get('/report/lineList',function(result){
			xlList=result;
			$.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>';
				}
				
				if(obj.length ==0){
					 $("#gsdmDiv_waybillday").css('display','none');
				}else if(obj.length ==1){
					 $("#gsdmDiv_waybillday").css('display','none');
					if(obj[0].children.length == 1  || obj[0].children.length ==0)
						$('#fgsdmDiv_waybillday').css('display','none');
				}
				$('#gsdmWaybillday').html(options);
				updateCompany();
			});
		})
		$("#gsdmWaybillday").on("change",updateCompany);
		function updateCompany(){
			var company = $('#gsdmWaybillday').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>';
					}
				}
			}
			$('#fgsdmWaybillday').html(options);
// 			initXl();
		}
		
		var tempData = {};
		$.get('/report/lineList',function(xlList){
			var data = [];
// 			data.push({id: " ", text: "全部线路"});
			$.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"]});
								tempData[xlList[k]["xlbm"]] = companyCode+":"+code;
							}
						}
					}
				}
				initPinYinSelect2('#line',data,'');
				
			});
		});
		
		$("#line").on("change", function(){
			if($("#line").val() == " "){
				$("#gsdmWaybillday").attr("disabled", false);
				$("#fgsdmWaybillday").attr("disabled", false);
			} else {
				var temp = tempData[$("#line").val()].split(":");
				$("#gsdmWaybillday").val(temp[0]);
				updateCompany();
				$("#fgsdmWaybillday").val(temp[1]);
				$("#gsdmWaybillday").attr("disabled", true);
				$("#fgsdmWaybillday").attr("disabled", true);
			}
		});
		
		var line;
		var date;
		var gsdmWaybillday;
		var fgsdmWaybillday;
		$("#query").on("click",function(){
			line = $("#line").val();
			date = $("#date").val();
			gsdmWaybillday=$("#gsdmWaybillday").val();
			fgsdmWaybillday = $("#fgsdmWaybillday").val();
			if(date=="" || date ==null){
				 layer.msg('请选择日期.');
			}else{
				var i = layer.load(2);
				$post('/mcy_forms/waybillday',{line:line,date:date,type:'query'},function(result){
					 $.each(result, function(i, obj) {
						obj.requestType = reqCodeMap[obj.requestType];
	                }); 
					// 把数据填充到模版中
					var tbodyHtml = template('waybillday',{list:result});
					// 把渲染好的模版html文本追加到表格中
					$('#forms tbody').html(tbodyHtml);
					layer.close(i);
				});
			}
		});
		
		$("#export").on("click",function(){
			line = $("#line").val();
			date = $("#date").val();
			lineName = $('#line option:selected').text();
			gsdmWaybillday=$("#gsdmWaybillday").val();
			fgsdmWaybillday = $("#fgsdmWaybillday").val();
			$post('/mcy_export/waybilldayExport',{gsdmWaybillday:gsdmWaybillday,fgsdmWaybillday:fgsdmWaybillday,line:line,date:date,lineName:lineName,type:'export'},function(result){
				window.open("/downloadFile/download?fileName="
						+moment(date).format("YYYYMMDD")
						+"-"+lineName+"-行车路单日报表");
			});
		});
	});
</script>
<script type="text/html"  id="waybillday">
	{{each list as obj i}}
		<tr>
			<td>{{obj.nbbm}}</td>
			<td>{{obj.jzl1}} </td>
			<td>{{obj.jzl}}</td>
			<td> </td>
			<td>{{obj.sh}}</td>
			<td>{{obj.jName}}</td>
			<td>{{obj.zlc}}</td>
            <td>{{obj.yh}}</td>
		</tr>
	{{/each}}
	{{if list.length == 0}}
		<tr>
			<td colspan="8"><h6 class="muted">没有找到相关数据</h6></td>
		</tr>
	{{/if}}
</script>