|
|
@@ -23,32 +23,13 @@ if (printType && printType == 'PRINT') {
|
|
|
}
|
|
|
|
|
|
// 上页
|
|
|
-$("#prev").click(function() {
|
|
|
- if (pageIndex <= 1) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 获取前一页的pdf
|
|
|
- url = url.replace(pageIndex + ".pdf", (--pageIndex) + ".pdf");
|
|
|
- getDocument();
|
|
|
-});
|
|
|
+$("#prev").click(prevPage);
|
|
|
|
|
|
// 下页
|
|
|
-$("#next").click(function() {
|
|
|
- if (pageIndex >= pageSize) {
|
|
|
- return;
|
|
|
- }
|
|
|
- url = url.replace(pageIndex + ".pdf", (++pageIndex) + ".pdf");
|
|
|
- getDocument();
|
|
|
-});
|
|
|
-
|
|
|
-// 打印
|
|
|
-$("#print").click(function() {
|
|
|
- hiddenframe.contentWindow.print();
|
|
|
-});
|
|
|
+$("#next").click(nextPage);
|
|
|
|
|
|
// 手动输入页码
|
|
|
-$("#page_index").keypress(function(e) {
|
|
|
- var event = e || window.event;
|
|
|
+$("#page_index").keypress(function(event) {
|
|
|
// 按Enter键
|
|
|
if (event.keyCode == 13) {
|
|
|
var value = document.getElementById("page_index").value;
|
|
|
@@ -67,6 +48,11 @@ $("#page_index").keypress(function(e) {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+// 打印
|
|
|
+$("#print").click(function() {
|
|
|
+ hiddenframe.contentWindow.print();
|
|
|
+});
|
|
|
+
|
|
|
// 下载pdf
|
|
|
$("#download_pdf").click(function() {
|
|
|
window.location = downloadUrl("pdf");
|
|
|
@@ -77,6 +63,20 @@ $("#download_excel_with_only_data").click(function() {
|
|
|
window.location = downloadUrl("xls_with_only_data");
|
|
|
});
|
|
|
|
|
|
+// 键盘左右键进行翻页
|
|
|
+$("body").keydown(function(event) {
|
|
|
+ // 如果在input输入框内按左右键,不进行翻页
|
|
|
+ var activeElement = document.activeElement;
|
|
|
+ if (activeElement.nodeName.toLowerCase() == "input") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (event.keyCode == 37) {// left
|
|
|
+ prevPage();
|
|
|
+ } else if (event.keyCode == 39) {// right
|
|
|
+ nextPage();
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
// 获取窗口宽度
|
|
|
function getWindowWidth() {
|
|
|
if (window.innerWidth)
|
|
|
@@ -163,4 +163,23 @@ function renderPage() {
|
|
|
};
|
|
|
var renderTask = page.render(renderContext);
|
|
|
});
|
|
|
+}
|
|
|
+
|
|
|
+// 预览前一页
|
|
|
+function prevPage() {
|
|
|
+ if (pageIndex <= 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 获取前一页的pdf
|
|
|
+ url = url.replace(pageIndex + ".pdf", (--pageIndex) + ".pdf");
|
|
|
+ getDocument();
|
|
|
+}
|
|
|
+
|
|
|
+// 预览后一页
|
|
|
+function nextPage() {
|
|
|
+ if (pageIndex >= pageSize) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ url = url.replace(pageIndex + ".pdf", (++pageIndex) + ".pdf");
|
|
|
+ getDocument();
|
|
|
}
|