package cn.cerc.ui.other;

import cn.cerc.mis.core.IForm;
import cn.cerc.ui.core.HtmlWriter;
import cn.cerc.ui.grid.MutiPage;
import cn.cerc.ui.parts.UIComponent;
import cn.cerc.ui.parts.UISheet;

import javax.servlet.http.HttpServletRequest;

public class OperaPages extends UISheet {
    private IForm form;
    private MutiPage pages;

    public OperaPages(UIComponent owner, IForm form, MutiPage pages) {
        super(owner);
        this.form = form;
        this.pages = pages;
    }

    @Override
    public void output(HtmlWriter html) {
        if (pages.getCount() <= 1)
            return;

        HttpServletRequest request = form.getRequest();
        StringBuffer url = new StringBuffer();
        if (request.getQueryString() != null) {
            String[] items = request.getQueryString().split("&");
            for (String str : items) {
                if (!str.startsWith("pageno=")) {
                    url.append("&");
                    url.append(str);
                }
            }
        }
        boolean isPhone = form.getClient().isPhone();
        if (isPhone) {
            html.println("<div class=\"foot-page\">");
        } else {
            html.println("<section>");
            html.println("<div class=\"title\">数据分页</div>");
            html.println("<div class=\"contents\">");
            html.println("总记录数：%d, 当前页：%d，总页数：%d <br/>", pages.getRecordCount(), pages.getCurrent(), pages.getCount());
            html.println("<div align=\"center\">");
        }
        html.println("<a href=\"?pageno=1%s\">首页</a>", url);
        html.println("<a href=\"?pageno=%d%s\">上一页</a>", pages.getPrior(), url);
        html.println("<a href=\"?pageno=%d%s\">下一页</a>", pages.getNext(), url);
        html.println("<a href=\"?pageno=%d%s\">尾页</a>", pages.getCount(), url);
        if (isPhone) {
            html.println("笔数：%s, 页数：%d / %d", pages.getRecordCount(), pages.getCurrent(), pages.getCount());
            html.println("</div>");
        } else {
            html.println("</div>");
            html.println("</div>");
            html.println("</section>");
        }
    }
}

@@ -51,16 +51,47 @@
 .IForm;%0A
+import cn.cerc.mis.language.R;%0A
 import c
@@ -1290,19 +1290,55 @@
 e%5C%22%3E
-%E6%95%B0%E6%8D%AE%E5%88%86%E9%A1%B5
+%25s
 %3C/div%3E%22
+, R.asString(form.getHandle(), %22%E6%95%B0%E6%8D%AE%E5%88%86%E9%A1%B5%22)
 );%0A 
@@ -1420,27 +1420,23 @@
 ln(%22
-%E6%80%BB%E8%AE%B0%E5%BD%95%E6%95%B0
+%25s
 %EF%BC%9A%25d, 
-%E5%BD%93%E5%89%8D%E9%A1%B5
+%25s
 %EF%BC%9A%25d%EF%BC%8C
-%E6%80%BB%E9%A1%B5%E6%95%B0
+%25s
 %EF%BC%9A%25d 
@@ -1447,51 +1447,203 @@
 %3E%22, 
-pages.getRecordCount(), pages.getCurrent(),
+R.asString(form.getHandle(), %22%E6%80%BB%E8%AE%B0%E5%BD%95%E6%95%B0%22), pages.getRecordCount(),%0A                    R.asString(form.getHandle(), %22%E5%BD%93%E5%89%8D%E9%A1%B5%22), pages.getCurrent(), R.asString(form.getHandle(), %22%E6%80%BB%E9%A1%B5%E6%95%B0%22),%0A                   
  pag
@@ -1770,10 +1770,10 @@
 s%5C%22%3E
-%E9%A6%96%E9%A1%B5
+%25s
 %3C/a%3E
@@ -1774,24 +1774,60 @@
 %25s%3C/a%3E%22, url
+, R.asString(form.getHandle(), %22%E9%A6%96%E9%A1%B5%22)
 );%0A        h
@@ -1868,11 +1868,10 @@
 s%5C%22%3E
-%E4%B8%8A%E4%B8%80%E9%A1%B5
+%25s
 %3C/a%3E
@@ -1890,24 +1890,61 @@
 Prior(), url
+, R.asString(form.getHandle(), %22%E4%B8%8A%E4%B8%80%E9%A1%B5%22)
 );%0A        h
@@ -1985,11 +1985,10 @@
 s%5C%22%3E
-%E4%B8%8B%E4%B8%80%E9%A1%B5
+%25s
 %3C/a%3E
@@ -2002,32 +2002,69 @@
 s.getNext(), url
+, R.asString(form.getHandle(), %22%E4%B8%8B%E4%B8%80%E9%A1%B5%22)
 );%0A        html.
@@ -2101,10 +2101,10 @@
 s%5C%22%3E
-%E5%B0%BE%E9%A1%B5
+%25s
 %3C/a%3E
@@ -2127,16 +2127,52 @@
 t(), url
+, R.asString(form.getHandle(), %22%E5%B0%BE%E9%A1%B5%22)
 );%0A     
@@ -2219,17 +2219,17 @@
 ln(%22
-%E7%AC%94%E6%95%B0
+%25s
 %EF%BC%9A%25s, 
-%E9%A1%B5%E6%95%B0
+%25s
 %EF%BC%9A%25d 
@@ -2235,37 +2235,129 @@
  / %25d%22, 
-pages.getRecordCount(
+R.asString(form.getHandle(), %22%E7%AC%94%E6%95%B0%22), pages.getRecordCount(),%0A                    R.asString(form.getHandle(), %22%E9%A1%B5%E6%95%B0%22
 ), pages

Update OperaPages.java