车辆派遣管理系统-13-结算明细

今日完成任务:结算明细查询功能及页面设计

核心代码:见下列插入的代码

遇到的问题:无

解决的方法:无

 

功能模块:结算明细查询

需要角色:任意

数据加载:已结算的结算信息列表、结算的年月

数据验证:非空验证

导出报表:excel文件

列表分页:AJAX分页查询

业务描述:

统计某年内单月所有车辆费用明细信息,可以生成报表

点击左侧“查询统计”下的“结算明细”菜单,在右侧主题区域加载已结算的明细子页面,并加载所有已结算的结算明细信息进行分页显示,选择不同的年月查询不同的结算明细,查询后可以点击“生成报表”生成查询统计的指定年月的已结算明细excel信息。

视频演示地址:https://www.bilibili.com/video/BV15K411n7oD/

图文演示:

已结算明细信息列表

 

指定年月的结算明细生成报表

结算明细子页面html代码:

<table id="table0" width='100%' cellspacing="0" border='0'>
	<tr align="left">
		<td style="height:32px;">
			<div class="cxtjDiv">
				<input type="text" name="cxtj" value="" readonly="readonly"/>
				<ul>
				</ul>
			</div>
			<b id="tjtb"><img src="img/down.png" width="10px"/></b>
			<div class="cxtjDiv2">
				<input type="text" name="yue" value="" readonly="readonly"/>
				<ul>
					<li>1</li>
					<li>2</li>
					<li>3</li>
					<li>4</li>
					<li>5</li>
					<li>6</li>
					<li>7</li>
					<li>8</li>
					<li>9</li>
					<li>10</li>
					<li>11</li>
					<li>12</li>
				</ul>
			</div>
			<b id="tjtb2"><img src="img/down.png" width="10px"/></b>
			<span style="margin-top:4px;margin-bottom:4px;margin-left:10px;">
				<button onclick="mxcx()">明 细 查 询</button>
		</span>
		<span style="margin-top:4px;margin-bottom:4px;margin-left:10px;">
			<button onclick="scbb()">生 成 报 表</button>
			</span>
		</td>
	</tr>
</table>
<table class="table1" width='100%' cellspacing="0" border='0'>
	<tr align="left">
		<td width="5%">编号</td>
		<td width="8%">结算日期</td>
		<td width="8%">车牌号码</td>
		<td width="8%">结算年份</td>
		<td width="8%">结算月份</td>
		<td width="8%">月公里数</td>
		<td width="8%">月油费</td>
		<td width="8%">修理费</td>
		<td width="8%">轮胎费</td>
		<td width="8%">过桥费</td>
		<td width="8%">停车费</td>
		<td width="8%">总营业额</td>
		<td width="">毛利润</td>
	</tr>
</table>
<table class="list" width='100%' cellspacing="0">
</table>
<p class="pageManager">
	<span><input type="hidden" name="rows" value="10"/></span>
	<b >
	<button onclick="first()">首页</button>
<button onclick="prev()">上一页</button>
<button onclick="next()">下一页</button>
<button onclick="last()">尾页</button>
	&nbsp;
	第
	<select name="toNumPage" onchange="changeNumPage()">
		<option value="1">1</option>
	</select>
	页
	&nbsp;
	共
	<span></span>
	页
	</b>
</p>

结算明细子页面js代码:

function loadPage(rows,page,nian,yue){
	var cphm='';
	$.ajax({
		url:'yjsList',
		type:'post',
		data:'rows='+rows+'&row='+((page-1)*rows)+'&nian='+nian+'&yue='+yue+'&cphm='+cphm,
		async:false,
		success:function(data){
			var arr = eval(data);
			if(arr.length==0){
				$("#message").html("暂无结算信息!");
    			var left = $("#message").width()/2;
				$("#message").css("left",$(window).width()/2-left);
				$("#message").css("top",270);
    			$("#message").fadeIn(1000);
    			messageOut();
				return;
			}
			var row="";
			$.each(arr,function(i,o){
				row +="<tr>";
				row +="<td width='5%'>"+o.jsbh+"</td>";
				row +="<td width='8%'>"+o.jsrq+"</td>";
				row +="<td width='8%'>"+o.cphm+"</td>";
				row +="<td width='8%'>"+o.jsnf+"年</td>";
				row +="<td width='8%'>"+o.jsyf+"月</td>";
				row +="<td width='8%'>"+o.zgls+"(km)</td>";
				row +="<td width='8%'>"+o.yf+".00</td>";
				row +="<td width='8%'>"+o.xlf+".00</td>";
				row +="<td width='8%'>"+o.ltf+".00</td>";
				row +="<td width='8%'>"+o.gqf+".00</td>";
				row +="<td width='8%'>"+o.tcf+".00</td>";
				row +="<td width='8%'>"+o.zyye+".00</td>";
				row +="<td width=''>"+o.mlr+".00</td>";
				row +="</tr>";
			});
			$(".list").html(row);
			$.ajax({
				url:'yjsPages',
				type:'post',
				data:'rows='+$('.pageManager>span>input').val(),
				aysnc:false,
				success:function(data){
					$(".pageManager>b>span").html(data);
					var options = "";
					var n = parseInt(data);
					for(var i=1;i<=n;i++){
						if(page==i){
							options+="<option value='"+i+"' selected>"+i+"</option>";
						}else{
							options+="<option value='"+i+"'>"+i+"</option>";
						}
					}
					$(".pageManager select[name='toNumPage']").html(options);
				}
			});
		}
	});
}

var bj=0;
var bj2=0;
$(function(){
	var rows = $('.pageManager>span>input').val();
	var page = $('.pageManager>b>select').val();
	var lis="";
	var year = new Date().getYear()+1900;
	for(var i=year;i>year-3;i--){
		lis+="<li>"+i+"</li>";
	}
	$(".cxtjDiv input[name='cxtj']").val(year);
	$(".cxtjDiv ul").html(lis);
	$(".cxtjDiv input[name='cxtj'] , #tjtb").click(function(){
		$(".cxtjDiv>ul").slideDown();
		$("#tjtb>img").prop("src","img/up.png");
		bj=1;
	});
	$(document).mousedown(function(){
		if(bj==1){
			var ulLeft = $(".cxtjDiv ul").offset().left;
			var ulTop = $(".cxtjDiv ul").offset().top;
			if(event.x>=ulLeft && event.x<=ulLeft+180 &&event.y>=ulTop&&event.y<=ulTop+116){
			}else{
				$(".cxtjDiv ul").slideUp();
				bj=0;
			}
		}
	});
	$(".cxtjDiv ul li").click(function(){
		var cxtj = $(this).html();
		$(".cxtjDiv input[name='cxtj']").val(cxtj);
		$("#tjtb img").attr("src","img/down.png"); 
		$(".cxtjDiv input[name='cxtj']").css("padding-left","15px").css("color","#069");
		bj=0;
		$(".cxtjDiv ul").slideUp();
	});
	$(".cxtjDiv2 input[name='yue']").val(1);
	$(".cxtjDiv2 input[name='yue'] , #tjtb2").click(function(){
		$(".cxtjDiv2>ul").slideDown();
		$("#tjtb2>img").prop("src","img/up.png");
		bj2=1;
	});
	$(document).mousedown(function(){
		if(bj2==1){
			var ulLeft = $(".cxtjDiv2 ul").offset().left;
			var ulTop = $(".cxtjDiv2 ul").offset().top;
			if(event.x>=ulLeft && event.x<=ulLeft+180 &&event.y>=ulTop&&event.y<=ulTop+116){
			}else{
				$(".cxtjDiv2 ul").slideUp();
				bj2=0;
			}
		}
	});
	$(".cxtjDiv2 ul li").click(function(){
		var cxtj = $(this).html();
		$(".cxtjDiv2 input[name='yue']").val(cxtj);
		$("#tjtb2 img").attr("src","img/down.png"); 
		$(".cxtjDiv2 input[name='yue']").css("padding-left","15px").css("color","#069");
		bj2=0;
		$(".cxtjDiv2 ul").slideUp();
	});
	loadPage(rows,page,'','');
});

function changeNumPage(){
	var rows = $(".pageManager input[name='rows']").val();
	var page = $(".pageManager select[name='toNumPage']").val();
	var cxtj = $("input[name='cxtj']").val();
	var yue = $("input[name='yue']").val();
	loadPage(rows,page,cxtj,yue);
}
function first(){
	var rows = $(".pageManager input[name='rows']").val();
	var page = 1;
	var cxtj = $("input[name='cxtj']").val();
	var yue = $("input[name='yue']").val();
	loadPage(rows,page,cxtj,yue);
}
function last(){
	var rows = $(".pageManager input[name='rows']").val();
	var pages = $(".pageManager>b>span").html();
	var cxtj = $("input[name='cxtj']").val();
	var yue = $("input[name='yue']").val();
	loadPage(rows,pages,cxtj,yue);
}
function prev(){
	var rows = $(".pageManager input[name='rows']").val();
	var page = parseInt($(".pageManager select[name='toNumPage']").val());
	if(page-1<1){
		$(".pageManager select[name='toNumPage']").children(":last").prop("selected","true");
		last();
	}else{
		$(".pageManager select[name='toNumPage']").children(":eq("+(page-1)+")").prop("selected","true");
		var cxtj = $("input[name='cxtj']").val();
		var yue = $("input[name='yue']").val();
		loadPage(rows,page-1,cxtj,yue);
	}
}
function next(){
	var rows = $(".pageManager input[name='rows']").val();
	var page = parseInt($(".pageManager select[name='toNumPage']").val());
	var pages = parseInt($(".pageManager>b>span").html());
	if(page+1>pages){
		$(".pageManager select[name='toNumPage']").children(":eq(0)").prop("selected","true");
		first();
	}else{
		$(".pageManager select[name='toNumPage']").children(":eq("+(page+1)+")").prop("selected","true");
		var cxtj = $("input[name='cxtj']").val();
		var yue = $("input[name='yue']").val();
		loadPage(rows,page+1,cxtj,yue);
	}
}
function mxcx(){
	var rows = $('.pageManager>span>input').val();
	var page = $('.pageManager>b>select').val();
	var cxtj = $("input[name='cxtj']").val();
	var yue = $("input[name='yue']").val();
	loadPage(rows,page,cxtj,yue);
	sc=1;
}
var sc=0;
function scbb(){
	if(sc==0){
		$("#message").html("请查询后再进行报表导出!");
  			var left = $("#message").width()/2;
		$("#message").css("left",$(window).width()/2-left);
		$("#message").css("top",270);
  			$("#message").fadeIn(1000);
  			messageOut();
  			return;
	}
	var page = $('.pageManager>b>select').val();
	var rows = $('.pageManager>span>input').val();
	var cxtj = $("input[name='cxtj']").val();
	var yue = $("input[name='yue']").val();
	var cphm='';
	$.ajax({
		url:'yjsList2',
		type:'post',
		data:'rows='+rows+'&row='+((page-1)*rows)+'&nian='+cxtj+'&yue='+yue+'&cphm='+cphm,
		async:false,
		success:function(data){
			var arrData = eval(data);
			if(arrData.length==0){
				$("#message").html("暂无结算信息!");
    			var left = $("#message").width()/2;
				$("#message").css("left",$(window).width()/2-left);
				$("#message").css("top",270);
    			$("#message").fadeIn(1000);
    			messageOut();
				return;
			}
			var ShowLabel = [{ "value": "结算编号" },
				{ "value": "结算日期" }, 
				{ "value": "车牌号码" }, 
				{ "value": "结算年份" }, 
				{ "value": "结算月份" }, 
				{ "value": "月公里数" }, 
				{ "value": "月油费" },
				{ "value": "修理费" },
				{ "value": "轮胎费" },
				{ "value": "过桥费" },
				{ "value": "停车费" },
				{ "value": "总营业额" },
				{ "value": "毛利润" }
				];
	        var excel = '<table>';
	        var row = "<tr>";
	        for (var i = 0, l = ShowLabel.length; i < l; i++) {
	            row += "<td style=\"color:blue\">" + ShowLabel[i].value + '</td>';
	        }
	        excel += row + "</tr>";
	        for (var i = 0; i < arrData.length; i++) {
	            var row = "<tr>";
                row += '<td>' + arrData[i].jsbh + '</td>';
                row += '<td>' + arrData[i].jsrq + '</td>';
                row += '<td>' + arrData[i].cphm + '</td>';
                row += '<td>' + arrData[i].jsnf + '</td>';
                row += '<td>' + arrData[i].jsyf + '</td>';
                row += '<td>' + arrData[i].zgls + '</td>';
                row += '<td>' + arrData[i].yf + '</td>';
                row += '<td>' + arrData[i].xlf + '</td>';
                row += '<td>' + arrData[i].ltf + '</td>';
                row += '<td>' + arrData[i].gqf + '</td>';
                row += '<td>' + arrData[i].tcf + '</td>';
                row += '<td>' + arrData[i].zyye + '</td>';
                row += '<td>' + arrData[i].mlr + '</td>';
	            excel += row + "</tr>";
	        }
	        excel += "</table>";
	        var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
	        excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';
	        excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel';
	        excelFile += '; charset=UTF-8">';
	        excelFile += "<head>";
	        excelFile += "<!--[if gte mso 9]>";
	        excelFile += "<xml>";
	        excelFile += "<x:ExcelWorkbook>";
	        excelFile += "<x:ExcelWorksheets>";
	        excelFile += "<x:ExcelWorksheet>";
	        excelFile += "<x:Name>";
	        excelFile += "{worksheet}";
	        excelFile += "</x:Name>";
	        excelFile += "<x:WorksheetOptions>";
	        excelFile += "<x:DisplayGridlines/>";
	        excelFile += "</x:WorksheetOptions>";
	        excelFile += "</x:ExcelWorksheet>";
	        excelFile += "</x:ExcelWorksheets>";
	        excelFile += "</x:ExcelWorkbook>";
	        excelFile += "</xml>";
	        excelFile += "<![endif]-->";
	        excelFile += "</head>";
	        excelFile += "<body>";
	        excelFile += excel;
	        excelFile += "</body>";
	        excelFile += "</html>";
	        var uri = 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(excelFile);
	        var link = document.createElement("a");
	        link.href = uri;
	        link.style = "visibility:hidden";
	        link.download = "结算明细报表.xls";
	        document.body.appendChild(link);
	        link.click();
	        document.body.removeChild(link);
		}
	});
}

结算明细子页面css代码:

.xg{
	color:#fff;
	border-radius:5px;
	border:none;
	line-height:25px;
	width:70px;
	background-color:#01AAED;
	outline:none;
	cursor:pointer;
}
#table0{
	background-color:#01AAED;
	color:#fff;
	font-size:12px;
	padding-left:30px;
	font-weight:bolder;
	
}
#table0 span{
	float:left;
	margin-top:5px;
	margin-bottom:5px;
	margin-left:5px;
	line-height:20px;
}
#table0 button{
	outline:none;
	border:none;
	padding:3px 15px;
	background-color:#fff;
	color:#069;
	cursor:pointer;
	margin-left:15px;
	box-shadow:2px 2px 2px #666;
}
#table0 button:hover{
	color:#01AAED;
}
.table1{
	background-color:#eef;
	line-height:41px;
	font-size:12px;
	padding-left:25px;
	font-weight:bolder;
	color:#666;
}
.table1 tr td{
	padding-left:10px;
}
.list{
	font-size:12px;
	padding-left:25px;
	margin-top:15px;
	color:#666;
}
.list tr{
	background-color:#fff;
	height:50px;
	outline:3px solid #def;
}
.list tr:hover{
	background-color:#aef;
}
.list tr td{
	padding-left:10px;
}

.pageManager{
	margin-top:10px;
	margin-left:25px;
	background-color:#fff;
	padding:5px 10px;
	color:#999;
	box-shadow:2px 2px 3px #999;
}
.pageManager>span{
	font-size:9px;
}
.pageManager>span>input{
	width:40px;
	border:1px solid #ccc;
	outline:none;
	padding-left:5px;
	border-radius:5px;
	margin-left:5px;
}
.pageManager>b{
	font-weight:100;
	font-size:9px;
	margin-left:15px;
}
.pageManager>b>select{
	border:1px solid #ccc;
	outline:none;
	border-radius:5px;
}
.pageManager>b>button{
	border:1px solid #ccc;
	outline:none;
	background-color:#fff;
	color:#666;
	font-size:9px;
	padding:1px 2px;
	cursor:pointer;
}
.pageManager>b>button:hover{
	color:white;
	font-weight:bolder;
	background-color:#0DE;
}
#xz{
	box-shadow:2px 2px 2px #aaa;
	cursor:pointer;
}
.pcddjForm{
	border:1px dotted #ccc;
	margin-bottom:0px;
	background-color:#fff;
}
.list1{
	font-size:12px;
	margin-top:15px;
	color:#666;
}
.pcddjForm input[type='text']{
	height:30px;
	color:#666;
}
.pcddjForm input[type='number']{
	height:30px;
}
.cxtjDiv{
	float:left;
	overflow: auto;
	box-shadow:2px 2px 2px #666;
}
.cxtjDiv ul{
	display:none;
	list-style:none;
	outline:none;
	position:absolute;
	background-color:#fff;
	margin-top:5px;
	width:168px;
	border:1px solid #eee;
	padding-bottom:10px;
	box-shadow:2px 2px 2px #666;
	height:250px;
	overflow:scroll;
}
.cxtjDiv ul li{
	padding-left:18px;
	line-height:25px;
	border-bottom:1px dotted #eee;
	cursor:pointer;
	color:#777;
}
.cxtjDiv ul li:hover{
	background-color:#01AAED;
	color:#fff;
}
.cxtjDiv>input{
	padding-left:15px;
	line-height:22px;
	margin-top:4px;
	width:170px;
	border:none;
	outline:none;
	color:#777;
	font-size:8px;
	font-family:'宋体';
	cursor:pointer;
}
#tjtb{
	float:left;
	margin-left:-18px;
	display:block;
	width:16px;
	height:16px;
	color:red;
	margin-top:7px;
	padding-top:6px;
	cursor:pointer;
}
.cxtjDiv2{
	float:left;
	overflow: auto;
	box-shadow:2px 2px 2px #666;
	margin-left:10px;
}
.cxtjDiv2 ul{
	display:none;
	list-style:none;
	outline:none;
	position:absolute;
	background-color:#fff;
	margin-top:5px;
	width:168px;
	border:1px solid #eee;
	padding-bottom:10px;
	box-shadow:2px 2px 2px #666;
	height:250px;
	overflow:scroll;
}
.cxtjDiv2 ul li{
	padding-left:18px;
	line-height:25px;
	border-bottom:1px dotted #eee;
	cursor:pointer;
	color:#777;
}
.cxtjDiv2 ul li:hover{
	background-color:#01AAED;
	color:#fff;
}
.cxtjDiv2>input{
	padding-left:15px;
	line-height:22px;
	margin-top:4px;
	width:170px;
	border:none;
	outline:none;
	color:#777;
	font-size:8px;
	font-family:'宋体';
	cursor:pointer;
}
#tjtb2{
	float:left;
	margin-left:-18px;
	display:block;
	width:16px;
	height:16px;
	color:red;
	margin-top:7px;
	padding-top:6px;
	cursor:pointer;
}

 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页