account.html 8.17 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>
                    	<input class="btn btn-default" type="button" id="czcl" value="X"/>
                    
                    </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 class="nbbmPx">车辆</th>
								<th>所属公司</th>
								<th>请求类型</th>
								<th>请求时间</th>
							</tr>
						</thead>
						<tbody>
							
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
	$(function(){
		$("#export").attr('disabled',"true");
		
		
		var reqCodeMap = {"0xA1": '请求恢复运营', "0xA2": '申请调档', "0xA3": '出场请求', "0xA5": '进场请求', "0xA7": '加油请求', "0x50": '车辆故障', "0x70": '路阻报告', "0x60": '事故报告', "0x11": '扣证纠纷', "0x12" : '报警', 0x21: '单车有人伤', 0x22: '单车无人伤', 0x23: '双车有人伤', 0x24: '双车无人伤'};
		// 关闭左侧栏
		if (!$('body').hasClass('page-sidebar-closed'))
			$('.menu-toggler.sidebar-toggler').click();
		
		$("#date").datetimepicker({
			format : 'YYYY-MM-DD',
			locale : 'zh-cn'
		});
		
		/* $.get('/basic/lineCode2Name',function(result){
			var data=[];
			
			for(var code in result){
				data.push({id: code, text: result[code]});
			}
			initPinYinSelect2('#line',data,'');
			
		}) */
		
		$.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,'');
				initCl();
			});
		});
		//重置
        $('#czcl').on('click', function () {
            $('#code').val('').change();
        });
		$("#line").on("change",initCl);
	function initCl(){
        $('#code').select2({
            ajax: {
                url: '/report/carList',
                dataType: 'json',
                delay: 150,
                data: function(params){
                    return{nbbm: params.term,xlbm:$('#line').val()};
                },
                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 line = $("#line").val();
	var xlName = $("#select2-line-container").html();
	var date = $("#date").val();
	var code = $("#code").val();
	var px="desc";
	$(".nbbmPx").on("click",function(){
		if($("#date").val() == null || $("#date").val().trim().length == 0){
			layer.msg("请选择时间");
			return;
		}
		if(px=="desc"){
			px="asc";
		}else{
			px="desc";
		}
		line = $("#line").val();
		xlName = $("#select2-line-container").html();
		date = $("#date").val();
		code = $("#code").val();
		
		$get('/realSchedule/accountPx',{line:line,date:date,code:code,xlName:xlName,px:px},function(result){
			$.each(result, function(i, obj) {
				obj.requestType = reqCodeMap[obj.requestType];
            });
			// 把数据填充到模版中
			var tbodyHtml = template('list_account',{list:result});
			// 把渲染好的模版html文本追加到表格中
			$('#forms tbody').html(tbodyHtml);
		});	
	})
		
		$("#query").on("click",function(){
			if($("#date").val() == null || $("#date").val().trim().length == 0){
				layer.msg("请选择时间");
				return;
			}
			line = $("#line").val();
			xlName = $("#select2-line-container").html();
			date = $("#date").val();
			code = $("#code").val();
			var type = "query";
			$(".hidden").removeClass("hidden");
			$get('/realSchedule/account',{line:line,date:date,code:code,xlName:xlName,type:type},function(result){
				$.each(result, function(i, obj) {
					obj.requestType = reqCodeMap[obj.requestType];
                });
				// 把数据填充到模版中
				var tbodyHtml = template('list_account',{list:result});
				// 把渲染好的模版html文本追加到表格中
				$('#forms tbody').html(tbodyHtml);
				
				if(result.length == 0)
					$("#export").attr('disabled',"true");
				else
					$("#export").removeAttr("disabled");
				
			});	
		});
		
		$("#export").on("click",function(){
			var type = "export";
			$get('/realSchedule/account', {line:line,date:date,code:code,xlName:xlName,type:type}, function(result){
				window.open("/downloadFile/download?fileName="
						+moment(date).format("YYYYMMDD")
						+"-"+xlName+"-驾驶员请求台账");
			});
		});
		
	});
</script>
<script type="text/html" id="list_account">
	{{each list as obj i}}
		<tr>
			<td>{{i+1}}</td>
			<td>{{obj.xlName}}</td>
			<td>{{obj.clZbh}}</td>
			<td>{{obj.company}}</td>
			<td>{{obj.requestType}}</td>
			<td>{{obj.requestTime}}</td>
		</tr>
	{{/each}}
	{{if list.length == 0}}
		<tr>
			<td colspan="6"><h6 class="muted">没有找到相关数据</h6></td>
		</tr>
	{{/if}}
</script>