shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.walker.common;
 
import java.util.LinkedHashMap;
import java.util.Map;
 
/**
 * <pre>
 * 默认的分页实现,如需扩展可继承SplitPageInfo类,并实现getPaginateHtml()即可。
 * getPaginateHtml()方法为自己组装的html代码。
 * </pre>
 *
 * @author 时克英
 */
@Deprecated
public class HtmlSplitPageInfo extends SplitPageInfo {
 
    private static final long serialVersionUID = -4354826336645108958L;
 
    private static Map<Integer, String> pageSizeDef;
 
    public HtmlSplitPageInfo() {
        super();
        pageSizeDef = new LinkedHashMap<>();
        pageSizeDef.put(8, "每页 8 条");
        pageSizeDef.put(10, "每页 10 条");
        pageSizeDef.put(12, "每页 12 条");
        pageSizeDef.put(20, "每页 20 条");
        pageSizeDef.put(30, "每页 30 条");
        pageSizeDef.put(50, "每页 50 条");
        pageSizeDef.put(100, "每页 100 条");
        pageSizeDef.put(200, "每页 200 条");
    }
 
    @Override
    public String getPaginateHtml() {
        String html = "";
        if(!this.isDefaultShow()){
            if(this.getTotalRowsAmount()<this.getPageSize()){
                return html;
            }
        }
        html = html + "<div class=\"dataTables_bottom\">\n";
        html = html + "<div class=\"dataTables_info\">显示 " + this.getPageRowBegin() + " 到 " + this.getPageRowEnd() + " 项,共 " + this.getTotalRowsAmount() + " 项</div>\n";
        html = html + "<div class=\"dataTables_paginate\">\n";
        html = html + "<ul class=\"pagination\">\n";
        if (super.getHasPrevious()) {
            html = html + "<li class=\"first\"><a href=\"####\" onclick=\"submitPaginate(" + 1 + ")\"><i class=\"iconfont icon-jiantou\"></i></a></li>";//首页
            html = html + "<li class=\"previous\"><a href=\"####\" onclick=\"submitPaginate(" + super.getPreviousPage() + ")\"><i class=\"iconfont icon-jiantouleft\"></i></a></li>";//上一页
        } else {
            html = html + "<li class=\"first disabled\"><a href=\"####\" ><i class=\"iconfont icon-jiantou\"></i></a></li>";//首页 disable
            html = html + "<li class=\"previous disabled\"><a href=\"####\" ><i class=\"iconfont icon-jiantouleft\"></i></a></li>";//上一页 disable
        }
        for (int i = super.getStartPage(); i <= super.getEndPage(); i++) {
            if (i == super.getCurrentPage()) {
                // 输出@符号,代表当前页
                html = html + "<li class=\"active\"><a href=\"###\" onclick=\"submitPaginate(" + i + ")\">" + i + "</a></li>";
            } else {
                html = html + "<li><a href=\"###\" onclick=\"submitPaginate(" + i + ")\">" + i + "</a></li>";
            }
        }
        if (super.getHasNext()) {
            html = html + "<li class=\"next\"><a href=\"####\" onclick=\"submitPaginate(" + super.getNextPage() + ")\"><i class=\"iconfont icon-jiantouleft\"></i></a></li>";//下一页
            html = html + "<li class=\"last\"> <a href=\"####\" onclick=\"submitPaginate(" + super.getTotalPages() + ")\"><i class=\"iconfont icon-jiantou\"></i></a></li>";//尾页
        } else {
            html = html + "<li class=\"next disabled\"><a href=\"####\" ><i class=\"iconfont icon-jiantouleft\"></i></a></li>";//下一页 disable
            html = html + "<li class=\"last disabled\"><a href=\"####\" ><i class=\"iconfont icon-jiantou\"></i></a></li>";//尾页 disable
        }
        html = html + "<input id=\"currentPage\" name=\"currentPage\" type=\"hidden\" value=\"" + super.getCurrentPage() + "\"  />";
        html = html + "</ul>\n";
        html = html + "</div>\n";
 
        html = html + "<div class=\"dataTables_number\">\n" +
                "          <select class=\"form-control\" name=\"pageSize\" onchange=\"submitPaginate(" + super.getCurrentPage() + ")\">\n";
 
        for (Map.Entry<Integer, String> entry : pageSizeDef.entrySet()) {
            if (super.getPageSize() == entry.getKey()) {
                html = html + "            <option value=\"" + entry.getKey() + "\" selected>" + entry.getValue() + "</option>\n";
            } else {
                html = html + "            <option value=\"" + entry.getKey() + "\">" + entry.getValue() + "</option>\n";
            }
        }
        html = html + "          </select>\n" +
                "      </div>\n";
 
        html = html + "</div>\n";
        return html;
    }
    public String getPaginateTableHtml() {
        String html = "";
        if(!this.isDefaultShow()){
            if(this.getTotalRowsAmount()<this.getPageSize()){
                return html;
            }
        }
        html = html + "<div class=\"dataTables_bottom nofix\">\n";
        html = html + "<div class=\"dataTables_info\">显示 " + this.getPageRowBegin() + " 到 " + this.getPageRowEnd() + " 项,共 " + this.getTotalRowsAmount() + " 项</div>\n";
        html = html + "<div class=\"dataTables_paginate\">\n";
        html = html + "<ul class=\"pagination\">\n";
        if (super.getHasPrevious()) {
            html = html + "<li class=\"first\"><a href=\"####\" onclick=\"submitPaginate(" + 1 + ")\"><i class=\"iconfont icon-jiantou\"></i></a></li>";//首页
            html = html + "<li class=\"previous\"><a href=\"####\" onclick=\"submitPaginate(" + super.getPreviousPage() + ")\"><i class=\"iconfont icon-jiantouleft\"></i></a></li>";//上一页
        } else {
            html = html + "<li class=\"first disabled\"><a href=\"####\" ><i class=\"iconfont icon-jiantou\"></i></a></li>";//首页 disable
            html = html + "<li class=\"previous disabled\"><a href=\"####\" ><i class=\"iconfont icon-jiantouleft\"></i></a></li>";//上一页 disable
        }
        for (int i = super.getStartPage(); i <= super.getEndPage(); i++) {
            if (i == super.getCurrentPage()) {
                // 输出@符号,代表当前页
                html = html + "<li class=\"active\"><a href=\"###\" onclick=\"submitPaginate(" + i + ")\">" + i + "</a></li>";
            } else {
                html = html + "<li><a href=\"###\" onclick=\"submitPaginate(" + i + ")\">" + i + "</a></li>";
            }
        }
        if (super.getHasNext()) {
            html = html + "<li class=\"next\"><a href=\"####\" onclick=\"submitPaginate(" + super.getNextPage() + ")\"><i class=\"iconfont icon-jiantouleft\"></i></a></li>";//下一页
            html = html + "<li class=\"last\"> <a href=\"####\" onclick=\"submitPaginate(" + super.getTotalPages() + ")\"><i class=\"iconfont icon-jiantou\"></i></a></li>";//尾页
        } else {
            html = html + "<li class=\"next disabled\"><a href=\"####\" ><i class=\"iconfont icon-jiantouleft\"></i></a></li>";//下一页 disable
            html = html + "<li class=\"last disabled\"><a href=\"####\" ><i class=\"iconfont icon-jiantou\"></i></a></li>";//尾页 disable
        }
        html = html + "<input id=\"currentPage\" name=\"currentPage\" type=\"hidden\" value=\"" + super.getCurrentPage() + "\"  />";
        html = html + "</ul>\n";
        html = html + "</div>\n";
 
        html = html + "<div class=\"dataTables_number\">\n" +
                "          <select class=\"form-control\" name=\"pageSize\" onchange=\"submitPaginate(" + super.getCurrentPage() + ")\">\n";
 
        for (Map.Entry<Integer, String> entry : pageSizeDef.entrySet()) {
            if (super.getPageSize() == entry.getKey()) {
                html = html + "            <option value=\"" + entry.getKey() + "\" selected>" + entry.getValue() + "</option>\n";
            } else {
                html = html + "            <option value=\"" + entry.getKey() + "\">" + entry.getValue() + "</option>\n";
            }
        }
        html = html + "          </select>\n" +
                "      </div>\n";
 
        html = html + "</div>\n";
        return html;
    }
}