//查询列表
function findForAjax(currentPage,userId)
{
$.ajax({
url : "/bills/bill/findForAjax",
data : {"currentPage": currentPage,"userId" : userId},
type : "post",
dataType : "json",
async:false, // 如果为异步加载无法给分页标签绑定事件(执行js的时候ajax数据还未加载完成),如果用异步加载需要使用live动态绑定
success : function (data)
{
dealData(data);
dealTable(data);
dealPage(data);
},
error : function(XMLHttpRequest, textStatus, errorThrown)
{
alert(textStatus);
stateCode(XMLHttpRequest);
}
});
}
//查询列表
function findForAjax(currentPage,userId)
{
$.ajax({
url : "/bills/bill/findForAjax",
data : {"currentPage": currentPage,"userId" : userId},
type : "post",
dataType : "json",
async:false, // 如果为异步加载无法给分页标签绑定事件(执行js的时候ajax数据还未加载完成),如果用异步加载需要使用live动态绑定
success : function (data)
{
dealData(data);
dealTable(data);
dealPage(data);
},
error : function(XMLHttpRequest, textStatus, errorThrown)
{
alert(textStatus);
stateCode(XMLHttpRequest);
}
});
}
// 页码展示
function dealPage(data)
{
var str = "";
for ( var i = 1; i <= data.totalPage; i++)
{
var strRed = "";
var strOther = "";
//str += "
"+i+"";
if (i == data.currentPage)
{
strRed = "
"+i+"";
}
else
{
strOther = "
"+i+"";
}
str = str + strRed + strOther;
}
var str1 = "
共";
var str2 = "
"+data.totalCount+"";
var str3 = "
条";
var str4 = "";
var str5 = "";
if (data.totalPage > 0)
{
str4 = "
第";
str5 = "
页";
}
var strAll = str1 + str2 + str3 + str4 + str + str5;
$("#page").html(strAll);
}
// jquery实现动态绑定 分页
$("#page").off("click").on("click","li[page = 'page']",function()
{
//alert("click");
currentPage = $(this).attr("pageNo");
findForAjax(currentPage,userId);
});
// 用户账单总行数
Integer totalCount = billsServiceImpl.findTotalConut(userId);
// 开始行
Integer startRow = null;
if (currentPage == null)
{
startRow = (Constant.bill.CURRENTPAGE - 1)*PAGESIZE;
}
else
{
// 开始行
startRow = (currentPage - 1)*PAGESIZE;
}
// 总页数
Integer totalPage = (totalCount % PAGESIZE == 0 ? totalCount/PAGESIZE : totalCount/PAGESIZE + 1);
Map param = new HashMap();
param.put("userId", userId);
param.put("start", startRow);
param.put("pageSize", PAGESIZE);
List bills = billsServiceImpl.findBillsForPage(param);
model.put("bills", bills);
model.put("totalCount", totalCount);
model.put("pageSize", PAGESIZE);
model.put("currentPage", currentPage);
model.put("totalPage", totalPage);