当前页合计

function getmeltSnowStock(pos,size){
	var select_year = $('#select_year').val();
	var orgName = $('#select_orgName').val();
	
	var tab1 = "<table style='width:100%;' class='table_two' cellpadding='0' cellspacing='0'>";
	tab1+= "<tbody>" +
		"<tr>"+
		  "<th></th>" +
		  "<th>录入机构</th>" +
		  "<th>防滑盐(吨)</th>" +
		  "<th>固态融雪剂(吨)</th> " +
		  "<th>液态融雪剂(吨)</th> " +
		  "<th>管理处</th>" +
		  "<th>录入人</th>" +
		  "<th>录入时间</th>" +
		  "</tr>";
	var opts = {
			cmd : "queryMeltSnowMaterial",
			meltSnowMaterial : {
				orgName:orgName,
				date:select_year,
				isStock:1,
				pos : pos,
				size : size
			}
	};
	
	$.ajax({
			url:"../../meltSnow",
			data: $.toJSON(opts),
			type:"post",
			dataType:"json",
			success:function(data) {
				var result = data.result;
				var reason = data.reason;
				if("OK"==result){
					if(data.meltSnowMaterialList!=null){
						if(data.meltSnowMaterialList.length>0){
							var saltCount = 0;
							var solidMeltSnowCount = 0;
							var liquidMeltSnowCount = 0;
							
							for(var i=0;i<data.meltSnowMaterialList.length;i++){
								saltCount += Number(data.meltSnowMaterialList[i].salt);
								solidMeltSnowCount += Number(data.meltSnowMaterialList[i].solidMeltSnow);
								liquidMeltSnowCount += Number(data.meltSnowMaterialList[i].liquidMeltSnow);
								
							}
							var count = {
									 institution : "合计",
									 salt : saltCount,
									 solidMeltSnow : solidMeltSnowCount,
									 liquidMeltSnow : liquidMeltSnowCount
							};
							data.meltSnowMaterialList.push(count);
							for(var i=0;i<data.meltSnowMaterialList.length;i++){								
								if(data.page.pos>=4){
									value = i+4+1;
								}else{
									value = i+1;
								}
								if(i%2 == 0){
									tab1+="<tr class=\"table1-tr2 \" align=\"center\">";
								}else{
									tab1+="<tr class=\"table1-tr1 \" align=\"center\">";
								}
								var num = i+1;
								if(num==data.meltSnowMaterialList.length){
									num="";
								}
								tab1+="<td>"+num+"</td>";
								tab1+="<td>"+changeStrNull(data.meltSnowMaterialList[i].institution)+"</td>";
								tab1+="<td>"+changeStrNull(data.meltSnowMaterialList[i].salt)+"</td>";
								tab1+="<td>"+changeStrNull(data.meltSnowMaterialList[i].solidMeltSnow)+"</td>";
								tab1+="<td>"+changeStrNull(data.meltSnowMaterialList[i].liquidMeltSnow)+"</td>";		
								tab1+="<td>"+changeStrNull(data.meltSnowMaterialList[i].orgName)+"</td>";	
								tab1+="<td>"+changeStrNull(data.meltSnowMaterialList[i].people)+"</td>";	
								tab1+="<td>"+changeStrNull(data.meltSnowMaterialList[i].date)+"</td>";	
								tab1+="</td></tr>";
							}
						}
					}else{
						tab1+="<tr class=\"table1-tr1 \" align=\"center\">";
						tab1+="<td colspan='9'>"+"暂无信息"+"</td>";	
						tab1+="</td></tr>";
					}
					value = 0;
					tab1+="</tbody>";
					tab1+="</table>";
					$("#itemActivitytableA").html(tab1);
					if(data.page!=null){
						totalCount = data.page.totalCount;
						if(totalCount>4){
							$("#totalCountA").html("每页显示4条,共有"+totalCount+"条记录");
							$(".pageA").pagination(totalCount, {
					            num_edge_entries: 1,
					            num_display_entries: 3,
					            callback: pageselectCallback,
					            items_per_page:4,
								current_page:parseInt(opts.meltSnowMaterial.pos/4)
					        });
							$(".pageA").show();	
							$(".everyA").show();	
						}else{
							$(".pageA").hide();	
							$(".everyA").hide();	
						}
					}			
				}else{
					alert(reason);
				}
			},
			error:function(msg){
				alert(msg);
			}
		});
	
	function pageselectCallback(page_index, jq) {
		var currentpage=page_index*4;
		getmeltSnowStock(currentpage,opts.meltSnowMaterial.size);
	};
}

你可能感兴趣的:(JavaScript)