|
@@ -271,6 +271,8 @@ let canvasOprObj = {
|
|
|
|
|
|
let rptControlObj = {
|
|
|
currentOutputType: "Excel",
|
|
|
+ currentDownloadUrl: null,
|
|
|
+ currentDownloadIdx: 0,
|
|
|
getCurrentPageSize: function() {
|
|
|
// let rst = "A4";
|
|
|
let rst = document.getElementById("btnRptPageSize").innerHTML.trim();
|
|
@@ -311,59 +313,47 @@ let rptControlObj = {
|
|
|
//other types if needed.
|
|
|
}
|
|
|
},
|
|
|
- getCurrentExcel: function() {
|
|
|
- let me = rptControlObj;
|
|
|
- //目前只支持当前打开报表
|
|
|
- //zTreeOprObj.currentRptPageRst
|
|
|
- if (zTreeOprObj.currentNode && zTreeOprObj.currentNode.refId) {
|
|
|
- let orgRptName = zTreeOprObj.currentNode.name;
|
|
|
- orgRptName = orgRptName.replace('【', '').replace('】','').replace('-','_').replace(' ','');
|
|
|
- let url = "/report_api/getExcel/" + projectInfoObj.projectInfo.ID + "/" + zTreeOprObj.currentNode.refId + "/" +
|
|
|
- me.getCurrentPageSize() + "/" + me.getCurrentOrientation() + "/" + orgRptName + "/" + true + "/" + 'normal';
|
|
|
- window.location = url;//这里不能使用get方法跳转,否则下载不成功
|
|
|
- }
|
|
|
- },
|
|
|
getAllInOneBook: function () {
|
|
|
let me = rptControlObj;
|
|
|
if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
|
|
|
let orgRptName = zTreeOprObj.checkedRptTplNodes[0].name;
|
|
|
- orgRptName = orgRptName.replace('【', '').replace('】','').replace('-','_').replace(' ','');
|
|
|
let refRptTplIds = [];
|
|
|
for (let node of zTreeOprObj.checkedRptTplNodes) {
|
|
|
refRptTplIds.push(node.refId);
|
|
|
}
|
|
|
let url = "/report_api/getExcelInOneBook/" + projectInfoObj.projectInfo.ID + "/" + refRptTplIds.join(",") + "/" +
|
|
|
me.getCurrentPageSize() + "/" + orgRptName + "/" + 'normal';
|
|
|
- window.location = url;//这里不能使用get方法跳转,否则下载不成功
|
|
|
+ window.location = url;
|
|
|
}
|
|
|
},
|
|
|
- chkAndGetExcel: function () {
|
|
|
+ getExcel: function () {
|
|
|
let me = rptControlObj;
|
|
|
if ($("#excelExportType_AllInOneBook").get(0).checked) {
|
|
|
me.getAllInOneBook();
|
|
|
} else if ($("#excelExportType_IndividualBook").get(0).checked) {
|
|
|
if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
|
|
|
+ let urls = [];
|
|
|
for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
|
|
|
let orgRptName = tplNode.name;
|
|
|
- orgRptName = orgRptName.replace('【', '').replace('】','').replace('-','_').replace(' ','');
|
|
|
let url = "/report_api/getExcel/" + projectInfoObj.projectInfo.ID + "/" + tplNode.refId + "/" +
|
|
|
me.getCurrentPageSize() + "/" + me.getCurrentOrientation() + "/" + orgRptName + "/" + true + "/" + 'normal';
|
|
|
- // window.location = url;//这里不能使用get方法跳转,否则下载不成功
|
|
|
- window.open(url);
|
|
|
+ urls.push(url);
|
|
|
}
|
|
|
+ downloadReport(urls);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
getPDF: function() {
|
|
|
let me = rptControlObj;
|
|
|
- //目前只支持当前打开报表
|
|
|
- //zTreeOprObj.currentRptPageRst
|
|
|
- if (zTreeOprObj.checkedRptTplIds && zTreeOprObj.checkedRptTplIds.length > 0) {
|
|
|
- let orgRptName = zTreeOprObj.currentNode.name;
|
|
|
- orgRptName = orgRptName.replace('【', '').replace('】','').replace('-','_');
|
|
|
- let url = "/report_api/getPDF/" + projectInfoObj.projectInfo.ID + "/" + zTreeOprObj.currentNode.refId + "/" +
|
|
|
- me.getCurrentPageSize() + "/" + me.getCurrentOrientation() + "/" + orgRptName;
|
|
|
- window.location = url;//这里不能使用get方法跳转,否则下载不成功
|
|
|
+ if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
|
|
|
+ let urls = [];
|
|
|
+ for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
|
|
|
+ let orgRptName = tplNode.name;
|
|
|
+ let url = "/report_api/getPDF/" + projectInfoObj.projectInfo.ID + "/" + tplNode.refId + "/" +
|
|
|
+ me.getCurrentPageSize() + "/" + me.getCurrentOrientation() + "/" + orgRptName;
|
|
|
+ urls.push(url);
|
|
|
+ }
|
|
|
+ downloadReport(urls);
|
|
|
}
|
|
|
},
|
|
|
firstPage: function(dom) {
|
|
@@ -390,7 +380,7 @@ let rptControlObj = {
|
|
|
} else {
|
|
|
keyPressed = event.which; // Firefox
|
|
|
}
|
|
|
- if (keyPressed == 13) {
|
|
|
+ if (keyPressed === 13) {
|
|
|
let pageNum = 1;
|
|
|
try {
|
|
|
pageNum = parseInt(dom.value);
|
|
@@ -444,12 +434,10 @@ let rptControlObj = {
|
|
|
);
|
|
|
},
|
|
|
confirmCfgChange: function() {
|
|
|
- // let me = zTreeOprObj;
|
|
|
let treeNode = zTreeOprObj.currentNode;
|
|
|
if (treeNode.nodeType === TPL_TYPE_TEMPLATE && treeNode.refId > 0) {
|
|
|
let params = {};
|
|
|
- let pageSize = rptControlObj.getCurrentPageSize();
|
|
|
- params.pageSize = pageSize;
|
|
|
+ params.pageSize = rptControlObj.getCurrentPageSize();
|
|
|
params.rpt_tpl_id = treeNode.refId;
|
|
|
params.prj_id = projectInfoObj.projectInfo.ID;
|
|
|
params.custCfg = zTreeOprObj.reportPageCfg;
|
|
@@ -458,3 +446,18 @@ let rptControlObj = {
|
|
|
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+function downloadReport(urls) {
|
|
|
+ //考虑到多个报表下载,一些浏览器(如chrome)不允许一下子下载多个文件,得缓缓处理,统一在这处理
|
|
|
+ rptControlObj.currentDownloadUrl = null;
|
|
|
+ rptControlObj.currentDownloadIdx = 0;
|
|
|
+ let private_download = function() {
|
|
|
+ if (rptControlObj.currentDownloadIdx >= 0 && rptControlObj.currentDownloadIdx < urls.length) {
|
|
|
+ rptControlObj.currentDownloadUrl = urls[rptControlObj.currentDownloadIdx];
|
|
|
+ rptControlObj.currentDownloadIdx++;
|
|
|
+ window.location = rptControlObj.currentDownloadUrl;
|
|
|
+ setTimeout(private_download, 2000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private_download();
|
|
|
+}
|