shiftuehiclemanth.html 8.44 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">
		<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; margin-left: 33px;" id="gsdmDiv_manth">
						<span class="item-label" style="width: 80px;">公司: </span>
						<select class="form-control" name="company" id="gsdmManth" style="width: 140px;"></select>
					</div> 
					<div style="display: inline-block; margin-left: 24px;" id="fgsdmDiv_manth">
						<span class="item-label" style="width: 80px;">分公司: </span>
						<select class="form-control" name="subCompany" id="fgsdmManth" 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: 136px;"></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="startDate" style="width: 120px;"/>
                    </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: 120px;"/>
                    </div>
                    <div style="display: inline-block;margin-left: 15px">
                        <span class="item-label" style="width: 150px;">统计: </span>
                    </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>
								<th>增加班次</th>
								<th>实际班次</th>
							</tr>
						</thead>
						<tbody>
							
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
	$(function(){
		// 关闭左侧栏
		if (!$('body').hasClass('page-sidebar-closed'))
			$('.menu-toggler.sidebar-toggler').click();
		
		$("#startDate,#endDate").datetimepicker({
			format : 'YYYY-MM-DD',
			locale : 'zh-cn'
		});
		
		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>';
			}
			
			if(obj.length ==0){
				 $("#gsdmDiv_manth").css('display','none');
				 $('#fgsdmDiv_manth').css('display','none');
			}else if(obj.length ==1){
				 $("#gsdmDiv_manth").css('display','none');
				if(obj[0].children.length == 1  || obj[0].children.length ==0)
					$('#fgsdmDiv_manth').css('display','none');
			}
			$('#gsdmManth').html(options);
			updateCompany();
		});

		$("#gsdmManth").on("change",updateCompany);
		function updateCompany(){
			var company = $('#gsdmManth').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>';
					}
				}
			}
			$('#fgsdmManth').html(options);
		}

		
		$.get('/basic/lineCode2Name',function(result){
			var data=[];
			
			for(var code in result){
				data.push({id: code, text: result[code]});
			}
			initPinYinSelect2('#line',data,'');
			
		})
        $('#lpName').select2({
            ajax: {
                url: '/realSchedule/findLpName',
                type: 'post',
                dataType: 'json',
                delay: 150,
                data: function(params){
                    return{lpName: 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>';
                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>';
               }
            }
        });
		$("#query").on("click",function(){
		    var line = $("#line").val();
		    var startDate = $("#startDate").val();
		    var endDate = $("#endDate").val();
		    var lpName = $("#lpName").val(); 
		    var gsdmManth= $("#gsdmManth").val();
		    var fgsdmManth= $("#fgsdmManth").val(); 
		   	$post("/mcy_forms/shiftuehiclemanth",{gsdmManth:gsdmManth,fgsdmManth:fgsdmManth, line:line,startDate:startDate,endDate:endDate ,lpName:lpName},function(result){		        
		   		$("#sDate").text(startDate);
		        $("#eDate").text(endDate);
		        var temp = {};
		        var today_account = 0;
		        temp["line"] = $("#line").text(); 	        
		        $.each(result, function(i, obj) {
		            if(moment(obj.schedule_date_str).format("YYYY-MM-DD") == moment(obj.startDate).format("YYYY-MM-DD")){
		                today_account++;
		            } 
                    obj.updateDate = moment(obj.startDate).format("YYYY-MM-DD HH:mm:ss");
                }); 
              
		        var list_shiftuehiclemanth = template('list_shiftuehiclemanth',{list:result});
                // 把渲染好的模版html文本追加到表格中
		        $('#forms tbody').html(list_shiftuehiclemanth);
                
		    }); 
		});
		
		$("#export").on("click",function(){
			 var line = $("#line").val();
			    var startDate = $("#startDate").val();
			    var endDate = $("#endDate").val();
			    var lpName = $("#lpName").val(); 
			    var gsdmManth= $("#gsdmManth").val();
			    var fgsdmManth= $("#fgsdmManth").val(); 
			$post('/mcy_export/shiftuehiclemanthExport',{gsdmManth:gsdmManth,fgsdmManth:fgsdmManth,line:line,startDate:startDate,endDate:endDate,type:'export'},function(result){
				window.open("/downloadFile/download?fileName=班次车辆人员月报表"+moment(startDate).format("YYYYMMDD"));
			});
		});
		
	});
</script>
<script type="text/html" id="list_shiftuehiclemanth">
	{{each list as obj i}}
		<tr>
			<td>{{i+1}}</td>
			<td>{{obj.jName}}</td>
			<td>{{obj.jhlc}}</td>
 			<td>{{obj.emptMileage}}</td>
			<td>{{obj.remMileage}}</td>
			<td>{{obj.addMileage}}</td>
			<td>{{obj.totalm}}</td>
			<td>{{obj.cjbc}}</td>
			<td>{{obj.ljbc}}</td>
			<td>{{obj.sjbc}}</td>
		</tr>
	{{/each}}
	{{if list.length == 0}}
		<tr>
			<td colspan="10"><h6 class="muted">没有找到相关数据</h6></td>
		</tr>
	{{/if}}
</script>
</script>