//查詢列表
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);