<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    String rowCnt = pub.trimNull(request.getParameter("rowCnt"));
    String page_size = pub.trimNull(request.getParameter("page_size"));
    if("".equals(page_size))page_size = "10";
    String page_number = pub.trimNull(request.getParameter("page_number"));
    int page_count = 0;
    if("0".equals(rowCnt)){
        out.println("<div style='width:100%;text-align:center'>暂无数据</div>");
        return;
    }else{
        page_count = Integer.parseInt(rowCnt)/Integer.parseInt(page_size);
        if(Integer.parseInt(rowCnt)%Integer.parseInt(page_size)>0){
            page_count = page_count+1;
        }
    }
%>
<div class="page" style="margin-top:20px;text-align:center;">
    <div style="float:left;width:350px;margin-left:20%;">
        共&nbsp;<%=rowCnt%>&nbsp;条，
        共&nbsp;<%=page_count%>&nbsp;页&nbsp;
        <select id="p_size" style="border: solid 1px #AAE;height:28px;line-height:28px;" onchange="changeSize(this.value)">
            <option value="10" <%if("10".equals(page_size)){%>selected<%}%>>每页10条</option>
            <option value="15" <%if("15".equals(page_size)){%>selected<%}%>>每页15条</option>
            <option value="20" <%if("20".equals(page_size)){%>selected<%}%>>每页20条</option>
            <option value="50" <%if("50".equals(page_size)){%>selected<%}%>>每页50条</option>
            <option value="100000" <%if("100000".equals(page_size)){%>selected<%}%>>全部</option>
        </select>
    </div>
    <div id="Pagination"></div>
</div>
<script type="text/javascript">
    $(function () {//页面加载时，进行绑定
        bind(0);
    });

    //点击分页时调用的函数，page_id为当前页的索引
    function pageselectCallback(page_id, jq) {
        document.getElementById("page_number").value = page_id + 1;
        searchModel();
    }
    function changeSize(size){
        document.getElementById("page_size").value = size;
        searchModel();
    }
    function bind(pageIndex) {
        var temp = "";
        var total = <%=rowCnt%>;
        if (total != 0) {
            $("#Pagination").pagination(total, {
                callback: pageselectCallback, //点击分页时，调用的回调函数
                prev_text: '« 上一页', //显示上一页按钮的文本
                next_text: '下一页 »', //显示下一页按钮的文本
                items_per_page: <%=page_size%>, //每页显示的项数
                num_display_entries: 6, //分页插件中间显示的按钮数目
                current_page: <%=page_number%>-1, //当前页索引
                num_edge_entries: 1
            });
        }

    }
</script>