Copy codeThe Code is as follows:
(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;
}
// Calculate the total number of pages
Total = parseInt (Total); // Total number of records
PageSize = parseInt (PageSize); // number of entries displayed per page
CurPageNum = parseInt (curPageNum); // current page
// Total number of pages
Var AllPage = Math. floor (Total/PageSize );
If (Total % PageSize! = 0 ){
AllPage ++;
}
Var navHtml = "";
If (curPageNum <= 0)
CurPageNum = 1;
If (AllPage> 1 ){
If (curPageNum! = 1 ){
// Process the homepage connection
NavHtml + = "<span> <a href = \" javascript: "+ FunUrl +" ('1') \ ">|< </a> </span> ";
}
If (curPageNum> 1 ){
// Process the connection of the previous page
NavHtml + = "<span> <a href = \" javascript: "+ FunUrl +" ('"+ (curPageNum-1) + "') \ "> </a> </span> ";
}
Else {
NavHtml + = "<span class = \" disabled \ "> </span> ";
}
Var currint = 5;
For (var I = 0; I <= 10; I ++ ){
// A total of 10 page numbers can be displayed, including the first 5 and the last 5
If (curPageNum + I-currint)> = 1 & (curPageNum + I-currint) <= AllPage)
If (currint = I ){
// Process the current page
NavHtml + = "<span lass = \" current \ "> [" + curPageNum + "] </span> ";
}
Else {
// General page processing
Var n = curPageNum + I-currint;
NavHtml + = "<a href = \" javascript: "+ FunUrl +" ('"+ (parseInt (n) + "') \ ">" + n + "</a> ";
}
}
If (curPageNum <AllPage ){
// Process the next page
NavHtml + = "<span> <a href = \" javascript: "+ FunUrl +" ('"+ (parseInt (curPageNum) + 1) + "') \ ">>></a> </span> ";
}
Else {
NavHtml + = "<span class = \" disabled \ ">></span> ";
}
If (curPageNum! = AllPage ){
NavHtml + = "<span> <a href = \" javascript: "+ FunUrl +" ('"+ AllPage + "') \ ">>| </a> </span> ";
}
}
NavHtml + = "<span> [" + curPageNum + "/" + AllPage + "] </span> ";
Return navHtml;
};
}) (JQuery );
The following is the call method:
Copy codeThe Code is as follows:
Function QueryList (curpage ){
If (curpage = "" | curpage = null | curpage = undefined ){
Curpage = 1;
}
Var pagesize = 10;
Var Countys = $ ("# Countys"). val (); // County
Var enddate = $ ("# enddate"). val (); // End Time
Var begindate = $ ("# begindate"). val (); // start time
$. 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> County Control </td> ";
}
Else {
Str + = "<td> control by bayonet points </td> ";
}
Str + = "<td>" + item. IsAll = "0 "? "County control": "control by bayonet points" + "</td> ";
Str + = "<td> modify </td> ";
Str + = "<td> Delete </td> ";
Str + = "<td> details </td> ";
Str + "</tr> ";
});
$ ("# Srh_rslt tbody" 2.16.html (str );
$ (". Pagination" ).html ($. PageFunc (mydata. total, pagesize, curpage, "QueryList "));
}
});
}