复制代码 代码如下:
(function ($) {
var PageFunc = function PageFunc() { }
$.PageFunc = function (Total, PageSize, curPageNum, FunUrl) {
if (PageSize == "" || PageSize == null || PageSize == undefined) {
PageSize = 10;
}
if (curPageNum == "" || curPageNum == null || curPageNum == undefined) {
curPageNum = 1;
}
//计算总页数
Total = parseInt(Total); //总记录数
PageSize = parseInt(PageSize); //每页显示数
curPageNum = parseInt(curPageNum); //当前页
//总页数
var AllPage = Math.floor(Total / PageSize);
if (Total % PageSize != 0) {
AllPage++;
}

var navHtml = "";

if (curPageNum <= 0)
curPageNum = 1;
if (AllPage > 1) {
if (curPageNum != 1) {
//处理首页连接
navHtml += "<span><a href=\"javascript:" + FunUrl + "('1')\" >|<</a></span>&nbsp;&nbsp;";
}
if (curPageNum > 1) {
//处理上一页的连接
navHtml += "<span><a href=\"javascript:" + FunUrl + "('" + (curPageNum - 1) + "')\" ><<</a></span>&nbsp;&nbsp;";
}
else {
navHtml += "<span class=\"disabled\"><<</span>&nbsp;&nbsp;";
}

var currint = 5;
for (var i = 0; i <= 10; i++) {
//一共最多显示10个页码,前面5个,后面5个
if ((curPageNum + i - currint) >= 1 && (curPageNum + i - currint) <= AllPage)
if (currint == i) {
//当前页处理
navHtml += "<span lass=\"current\">[" + curPageNum + "]</span>&nbsp;&nbsp;";
}
else {
//一般页处理
var n = curPageNum + i - currint;
navHtml += "<a href=\"javascript:" + FunUrl + "('" + (parseInt(n)) + "')\">" + n + "</a>&nbsp;&nbsp;";
}
}
if (curPageNum < AllPage) {
//处理下一页的链接
navHtml += "<span><a href=\"javascript:" + FunUrl + "('" + (parseInt(curPageNum) + 1) + "')\"></a></span>&nbsp;&nbsp;";
}
else {
navHtml += "<span class=\"disabled\"></span>&nbsp;&nbsp;";
}

if (curPageNum != AllPage) {
navHtml += "<span><a href=\"javascript:" + FunUrl + "('" + AllPage + "')\" |</a></span>&nbsp;&nbsp";
}

}

navHtml += "<span>[" + curPageNum + "/" + AllPage + "]</span>&nbsp;&nbsp;";

return navHtml;

};

})(jQuery);

下边是调用方法:
复制代码 代码如下:
function QueryList(curpage) {
if (curpage == "" || curpage == null || curpage == undefined) {
curpage = 1;
}
var pagesize = 10;

var Countys = $("#Countys").val(); //县
var enddate = $("#enddate").val(); //结束时间
var begindate = $("#begindate").val(); //开始时间
$.ajax({
url: "",
type: "POST",
data: { "Countys": Countys, "enddate": enddate, "begindate": begindate, "curpage": curpage, "pagesize": pagesize },
dataType: "json",
error: function (xhr, status, errMsg) { window.location.href = "/CommonError/index/" + errMsg.code + "?txt=" + errMsg.msg; },
success: function (mydata) {
var str = "";
$.each(mydata.Tdata, function (i, item) {

str += "<tr>"
str += "<td>" + $.FormatDateTime(item.ControlBeginTime, false) + "</td>";
str += "<td>" + $.FormatDateTime(item.ControlEndTime, false) + "</td>";
str += "<td>" + item.Name + "</td>";
str += "<td>" + item.PlateNumber + "</td>";
str += "<td>" + item.ControlDept + "</td>";
if (item.IsAll == "0") {
str += "<td>全县布控</td>";
}
else {
str += "<td>按卡口点布控</td>";
}
str += "<td>" + item.IsAll == "0" ? "全县布控" : "按卡口点布控" + "</td>";
str += "<td>修改</td>";
str += "<td>删除</td>";
str += "<td>详细</td>";
str + "</tr>";
});

$("#srh_rslt tbody").html(str);

$(".pagination").html($.PageFunc(mydata.total, pagesize, curpage, "QueryList"));
}
});
}
标签:
js分页

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“基于jquery封装的一个js分页”

暂无“基于jquery封装的一个js分页”评论...

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。