|
|
@@ -29,6 +29,7 @@ var rendering = false;
|
|
|
var nextRenderingPage;
|
|
|
|
|
|
document.title = getParameter("reportName");
|
|
|
+showExportButtons();
|
|
|
getWindowWidth();
|
|
|
loadData();
|
|
|
|
|
|
@@ -102,46 +103,6 @@ $("#print").click(function() {
|
|
|
printPdf();
|
|
|
});
|
|
|
|
|
|
-// 下载pdf
|
|
|
-$("#downloadPdf").click(function() {
|
|
|
- if (!pdfDoc) {
|
|
|
- return;
|
|
|
- }
|
|
|
- window.open(downloadUrl("pdf"));
|
|
|
-});
|
|
|
-
|
|
|
-// 下载word
|
|
|
-$("#downloadWord").click(function() {
|
|
|
- if (!pdfDoc) {
|
|
|
- return;
|
|
|
- }
|
|
|
- window.open(downloadUrl("doc"));
|
|
|
-});
|
|
|
-
|
|
|
-// 下载excel
|
|
|
-$("#downloadExcel").click(function () {
|
|
|
- if (!pdfDoc) {
|
|
|
- return;
|
|
|
- }
|
|
|
- downloadExcel(false);
|
|
|
-});
|
|
|
-
|
|
|
-// 下载纯数据excel
|
|
|
-$("#downloadExcelData").click(function () {
|
|
|
- if (!pdfDoc) {
|
|
|
- return;
|
|
|
- }
|
|
|
- downloadExcel(true);
|
|
|
-});
|
|
|
-
|
|
|
-//下载text
|
|
|
-$("#downloadText").click(function() {
|
|
|
- if (!pdfDoc) {
|
|
|
- return;
|
|
|
- }
|
|
|
- window.open(downloadUrl("txt"));
|
|
|
-});
|
|
|
-
|
|
|
// 键盘左右键进行翻页
|
|
|
$("body").keydown(function(event) {
|
|
|
// 如果在选中input输入框或select下拉列表时按左右键,不进行翻页
|
|
|
@@ -156,6 +117,36 @@ $("body").keydown(function(event) {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+/**
|
|
|
+ * 显示导出按钮
|
|
|
+ */
|
|
|
+function showExportButtons() {
|
|
|
+ $.ajax({
|
|
|
+ type: "get",
|
|
|
+ async: false,
|
|
|
+ url: "print/exportButtons",
|
|
|
+ success: function (exportButtons) {
|
|
|
+ if(exportButtons.length){
|
|
|
+ for(var i = 0; i < exportButtons.length; i++){
|
|
|
+ var buttonPrefix = "export_";
|
|
|
+ var button = $("#" + buttonPrefix + exportButtons[i]);
|
|
|
+ button.removeAttr("hidden");
|
|
|
+ button.click(function() {
|
|
|
+ if (!pdfDoc) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ window.open("print/export" + window.location.search + "&exportFileType=" + this.id.substr(buttonPrefix.length) + "&flush=true");
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (XMLHttpRequest) {
|
|
|
+ showError(XMLHttpRequest);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 获取窗口宽度
|
|
|
*/
|
|
|
@@ -317,54 +308,6 @@ function printPdf() {
|
|
|
1000);
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 下载报表
|
|
|
- *
|
|
|
- * @param exportFileType
|
|
|
- * 导出文件的格式
|
|
|
- * @returns {String} 下载链接
|
|
|
- */
|
|
|
-function downloadUrl(exportFileType) {
|
|
|
- var downloadUrl = "print/export" + window.location.search;
|
|
|
- exportFileType = exportFileType || "pdf";
|
|
|
- // 导出文件的格式
|
|
|
- downloadUrl += "&exportFileType=" + exportFileType + "&flush=true";
|
|
|
- return downloadUrl;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 下载 excel
|
|
|
- * @param onlyData 是否仅下载数据
|
|
|
- */
|
|
|
-function downloadExcel(onlyData) {
|
|
|
- $.ajax({
|
|
|
- type: "get",
|
|
|
- async: true,
|
|
|
- url: "print/isUseXlsx",
|
|
|
- success: function (isUseXlsx) {
|
|
|
- var excelType;
|
|
|
- // 根据结果决定使用 xls 还是 xlsx
|
|
|
- if (isUseXlsx) {
|
|
|
- if (onlyData) {
|
|
|
- excelType = "xlsx_data";
|
|
|
- } else {
|
|
|
- excelType = "xlsx";
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (onlyData) {
|
|
|
- excelType = "xls_data";
|
|
|
- } else {
|
|
|
- excelType = "xls";
|
|
|
- }
|
|
|
- }
|
|
|
- window.open(downloadUrl(excelType));
|
|
|
- },
|
|
|
- error: function (XMLHttpRequest) {
|
|
|
- showError(XMLHttpRequest);
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* 检查浏览器并提示
|
|
|
*/
|