rpt_main.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /**
  2. * Created by Tony on 2017/6/26.
  3. */
  4. 'use strict'
  5. const PRE_PAGE_OFFSET = 150;
  6. const NEXT_PAGE_OFFSET = 160;
  7. const FIRST_PAGE_OFFSET = 50;
  8. const LAST_PAGE_OFFSET = 60;
  9. let rptTplObj = {
  10. hasInitialized: false,
  11. iniPage: function() {
  12. let me = this;
  13. if (!me.hasInitialized) {
  14. zTreeOprObj.getCustomerCfg();
  15. zTreeOprObj.getReportTemplateTree();
  16. me.hasInitialized = true;
  17. let canvas = document.getElementById("rptCanvas");
  18. canvas.onclick = canvasOprObj.canvasOnClick;
  19. canvas.onmousemove = canvasOprObj.canvasOnMouseMove;
  20. }
  21. }
  22. }
  23. let zTreeOprObj = {
  24. treeObj: null,
  25. currentNode: null,
  26. checkedRptTplNodes: null,
  27. currentRptPageRst: null,
  28. reportPageCfg: null,
  29. defReportPageCfg: null,
  30. currentPage: 1,
  31. maxPages: 0,
  32. countChkedRptTpl: function () {
  33. let me = zTreeOprObj;
  34. if (me.treeObj) {
  35. me.checkedRptTplNodes = [];
  36. let chkNodes = me.treeObj.getCheckedNodes(true), cnt = 0, hasCurrentNode = false;
  37. for (let node of chkNodes) {
  38. if (node.nodeType === TPL_TYPE_TEMPLATE) {
  39. cnt++;
  40. me.checkedRptTplNodes.push(node);
  41. if (me.currentNode === node) hasCurrentNode = true;
  42. }
  43. }
  44. if (!hasCurrentNode && cnt === 0 && me.currentNode !== null) {
  45. //这里根据实际需求再做处理
  46. cnt++;
  47. me.checkedRptTplNodes.push(me.currentNode);
  48. }
  49. $("#export_div").find("span").each(function(cIdx,elementSpan){
  50. elementSpan.innerText = cnt;
  51. });
  52. $("#print_div").find("span").each(function(cIdx,elementSpan){
  53. elementSpan.innerText = cnt;
  54. });
  55. }
  56. },
  57. getReportTemplateTree: function() {
  58. let me = zTreeOprObj, params = {};
  59. params.engineerId = projectInfoObj.projectInfo.property.engineering;
  60. CommonAjax.postEx("report_tpl_api/getRptTplTree", params, 20000, true, function(result){
  61. let private_remove_hide_item = function (items) {
  62. if (items && items.length > 0) {
  63. for (let i = items.length - 1; i >= 0; i--) {
  64. if (!(items[i].released) && items[i].nodeType === 2) {
  65. items.splice(i, 1);
  66. } else {
  67. if (items[i].items && items[i].items.length > 0) {
  68. private_remove_hide_item(items[i].items);
  69. }
  70. }
  71. }
  72. }
  73. }
  74. private_remove_hide_item(result);
  75. for (let topNode of result) {
  76. if (topNode.userId === "-100") {
  77. topNode.name = topNode.name + " - 标准报表";
  78. } else {
  79. topNode.name = topNode.name + " - 定制报表";
  80. }
  81. }
  82. zTreeHelper.createTreeDirectly(result, rpt_tpl_setting, "rptTplTree", me);
  83. me.refreshNodes();
  84. }, null, null);
  85. },
  86. getCustomerCfg: function() {
  87. let me = zTreeOprObj, params = {};
  88. params.engineerId = projectInfoObj.projectInfo.property.engineering;
  89. CommonAjax.postEx("report_tpl_api/getCustomizeCfg", params, 20000, true, function(result){
  90. if (result) {
  91. me.defReportPageCfg = result[0];
  92. me.reportPageCfg = result[1];
  93. me.renderRptCfg(result[1]);
  94. } else {
  95. me.reportPageCfg = null;
  96. me.defReportPageCfg = null;
  97. }
  98. }, null, null
  99. );
  100. },
  101. renderRptCfg: function (cfg) {
  102. $("#elementMargin_Left").get(0).value = cfg.margins.Left;
  103. $("#elementMargin_Right").get(0).value = cfg.margins.Right;
  104. $("#elementMargin_Top").get(0).value = cfg.margins.Top;
  105. $("#elementMargin_Bottom").get(0).value = cfg.margins.Bottom;
  106. for (let font of cfg.fonts) {
  107. let fontPropSuffix = "title";
  108. if (font.CfgDispName === "表标题") {
  109. fontPropSuffix = "title";
  110. } else if (font.CfgDispName === "列标题") {
  111. fontPropSuffix = "column";
  112. } else if (font.CfgDispName === "正文内容") {
  113. fontPropSuffix = "content";
  114. } else if (font.CfgDispName === "合计") {
  115. fontPropSuffix = "summary";
  116. } else if (font.CfgDispName === "表眉/表脚") {
  117. fontPropSuffix = "header_footer";
  118. }
  119. document.getElementById("fontName_" + fontPropSuffix).value = font.Name;
  120. document.getElementById("fontHeight_" + fontPropSuffix).value = font.FontHeight;
  121. document.getElementById("font_bold_" + fontPropSuffix).className = (font.FontBold === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  122. document.getElementById("font_italic_" + fontPropSuffix).className = (font.FontItalic === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  123. document.getElementById("font_underline_" + fontPropSuffix).className = (font.FontUnderline === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  124. }
  125. document.getElementById("rpt_vertical_line").checked = cfg.showVerticalLine;
  126. document.getElementById("rpt_narrow").checked = cfg.isNarrow;
  127. document.getElementById("rpt_fill_zero").checked = cfg.fillZero;
  128. },
  129. extractRptCfg: function (cfg) {
  130. cfg.margins.Left = $("#elementMargin_Left").get(0).value;
  131. cfg.margins.Right = $("#elementMargin_Right").get(0).value;
  132. cfg.margins.Top = $("#elementMargin_Top").get(0).value;
  133. cfg.margins.Bottom = $("#elementMargin_Bottom").get(0).value;
  134. for (let font of cfg.fonts) {
  135. let fontPropSuffix = "title";
  136. if (font.CfgDispName === "表标题") {
  137. fontPropSuffix = "title";
  138. } else if (font.CfgDispName === "列标题") {
  139. fontPropSuffix = "column";
  140. } else if (font.CfgDispName === "正文内容") {
  141. fontPropSuffix = "content";
  142. } else if (font.CfgDispName === "合计") {
  143. fontPropSuffix = "summary";
  144. } else if (font.CfgDispName === "表眉/表脚") {
  145. fontPropSuffix = "header_footer";
  146. }
  147. font.Name = document.getElementById("fontName_" + fontPropSuffix).value;
  148. font.FontHeight = document.getElementById("fontHeight_" + fontPropSuffix).value;
  149. font.FontBold = (document.getElementById("font_bold_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  150. font.FontItalic = (document.getElementById("font_italic_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  151. font.FontUnderline = (document.getElementById("font_underline_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  152. }
  153. cfg.showVerticalLine = document.getElementById("rpt_vertical_line").checked;
  154. cfg.isNarrow = document.getElementById("rpt_narrow").checked;
  155. cfg.fillZero = document.getElementById("rpt_fill_zero").checked;
  156. },
  157. refreshNodes: function() {
  158. let me = this;
  159. let private_setupIsParent = function(node){
  160. node.isParent = (node.nodeType === RT.NodeType.NODE || node.level === 0);
  161. if (node.items && node.items.length) {
  162. for (let i = 0; i < node.items.length; i++) {
  163. private_setupIsParent(node.items[i]);
  164. }
  165. }
  166. };
  167. let topNodes = me.treeObj.getNodes();
  168. for (let i = 0; i < topNodes.length; i++) {
  169. private_setupIsParent(topNodes[i]);
  170. }
  171. me.treeObj.refresh();
  172. },
  173. onCheck: function(event, treeId, treeNode) {
  174. zTreeOprObj.countChkedRptTpl();
  175. },
  176. onClick: function(event,treeId,treeNode) {
  177. let me = zTreeOprObj;
  178. if (treeNode.nodeType === TPL_TYPE_TEMPLATE && treeNode.refId > 0) {
  179. let params = {};
  180. let pageSize = rptControlObj.getCurrentPageSize();
  181. params.pageSize = pageSize;
  182. params.rpt_tpl_id = treeNode.refId;
  183. params.prj_id = projectInfoObj.projectInfo.ID;
  184. params.custCfg = me.reportPageCfg;
  185. me.currentNode = treeNode;
  186. me.requestReport(params);
  187. me.countChkedRptTpl();
  188. }
  189. },
  190. changePageSize: function(dom) {
  191. let me = zTreeOprObj,
  192. targetDom = document.getElementById("btnRptPageSize");
  193. let tmpStr = targetDom.innerHTML.trim();
  194. targetDom.innerHTML = dom.innerHTML.trim();
  195. dom.innerHTML = tmpStr;
  196. me.changeCfg();
  197. },
  198. changeOrientation: function(dom) {
  199. let me = zTreeOprObj,
  200. targetDom = document.getElementById("btnRptOrientation");
  201. let tmpStr = targetDom.innerHTML.trim();
  202. targetDom.innerHTML = dom.innerHTML.trim();
  203. dom.innerHTML = tmpStr;
  204. me.changeCfg();
  205. },
  206. changeCfg: function() {
  207. let me = zTreeOprObj;
  208. let params = {};
  209. params.pageSize = rptControlObj.getCurrentPageSize();
  210. params.orientation = rptControlObj.getCurrentOrientation();
  211. params.rpt_tpl_id = me.currentNode.refId;
  212. params.prj_id = projectInfoObj.projectInfo.ID;
  213. params.custCfg = me.reportPageCfg;
  214. me.requestReport(params);
  215. },
  216. resetAfter: function (pageRst) {
  217. let size = pageRst[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE].slice(0);
  218. if (size[0] > size[1]) {
  219. document.getElementById("btnRptOrientation").innerHTML = "横向";
  220. document.getElementById("hrefRptOrientation").innerHTML = "纵向";
  221. } else {
  222. document.getElementById("btnRptOrientation").innerHTML = "纵向";
  223. document.getElementById("hrefRptOrientation").innerHTML = "横向";
  224. }
  225. },
  226. requestReport: function (params) {
  227. let me = zTreeOprObj;
  228. CommonAjax.postEx("report_api/getReport", params, 5000, true,
  229. function(result){
  230. let pageRst = result;
  231. if (pageRst) {
  232. me.resetAfter(pageRst);
  233. let canvas = document.getElementById("rptCanvas");
  234. me.currentRptPageRst = pageRst;
  235. me.maxPages = pageRst.items.length;
  236. me.currentPage = 1;
  237. me.displayPageValue();
  238. let size = JpcCanvasOutput.getReportSizeInPixel(me.currentRptPageRst, getScreenDPI());
  239. canvas.width = size[0] + 20;
  240. if (size[1] > size[0]) {
  241. canvas.height = size[1] + 100;
  242. } else {
  243. canvas.height = size[1] + 50;
  244. }
  245. me.showPage(1, canvas);
  246. }
  247. }, null, null
  248. );
  249. },
  250. showPage: function (pageNum, canvas) {
  251. let me = zTreeOprObj;
  252. if (pageNum >= 1 && pageNum <= me.maxPages) {
  253. me.currentPage = pageNum;
  254. JpcCanvasOutput.cleanCanvas(canvas);
  255. JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
  256. JpcCanvasOutput.drawToCanvas(me.currentRptPageRst, canvas, me.currentPage);
  257. }
  258. me.displayPageValue();
  259. },
  260. displayPageValue: function() {
  261. let me = zTreeOprObj;
  262. $("#rpt_page_num").get(0).value = me.currentPage + "/" + me.maxPages;
  263. }
  264. };
  265. let canvasOprObj = {
  266. canvasOnMouseMove: function (event) {
  267. if (zTreeOprObj.currentNode) {
  268. let x = event.offsetX - JpcCanvasOutput.offsetX, canvas = event.originalTarget;
  269. if (!(canvas)) canvas = event.target; //chrome浏览器不认event.originalTarget,只认event.target或event.currentTarget
  270. if (x < FIRST_PAGE_OFFSET) {
  271. canvas.style.cursor = "url(/web/building_saas/img/FirstPageSimple.cur), auto";
  272. } else if (x < PRE_PAGE_OFFSET) {
  273. canvas.style.cursor = "url(/web/building_saas/img/PreviousPageSimple.cur), auto";
  274. } else if ((canvas.width - x) < LAST_PAGE_OFFSET) {
  275. canvas.style.cursor = "url(/web/building_saas/img/LastPageSimple.cur), auto";
  276. } else if ((canvas.width - x) < NEXT_PAGE_OFFSET) {
  277. canvas.style.cursor = "url(/web/building_saas/img/NextPageSimple.cur), auto";
  278. } else {
  279. canvas.style.cursor = "";
  280. }
  281. }
  282. },
  283. canvasOnClick: function(event){
  284. if (zTreeOprObj.currentNode) {
  285. let x = event.offsetX - JpcCanvasOutput.offsetX, canvas = event.originalTarget;
  286. if (!(canvas)) canvas = event.target; //chrome浏览器不认event.originalTarget,只认event.target或event.currentTarget
  287. if (x < FIRST_PAGE_OFFSET) {
  288. zTreeOprObj.showPage(1, canvas);
  289. } else if (x < PRE_PAGE_OFFSET) {
  290. zTreeOprObj.showPage(zTreeOprObj.currentPage - 1, canvas);
  291. } else if ((canvas.width - x) < LAST_PAGE_OFFSET) {
  292. zTreeOprObj.showPage(zTreeOprObj.maxPages, canvas);
  293. } else if ((canvas.width - x) < NEXT_PAGE_OFFSET) {
  294. zTreeOprObj.showPage(zTreeOprObj.currentPage + 1, canvas);
  295. }
  296. }
  297. }
  298. };
  299. let rptControlObj = {
  300. currentOutputType: "Excel",
  301. currentDownloadUrl: null,
  302. currentDownloadIdx: 0,
  303. getCurrentPageSize: function() {
  304. // let rst = "A4";
  305. let rst = document.getElementById("btnRptPageSize").innerHTML.trim();
  306. //btnRptPageSize
  307. return rst;
  308. },
  309. getCurrentOrientation: function() {
  310. // let rst = "横向";
  311. let rst = document.getElementById("btnRptOrientation").innerHTML.trim();
  312. return rst;
  313. },
  314. getCurrentReportOption: function() {
  315. //
  316. },
  317. changeType: function(newType) {
  318. let me = rptControlObj;
  319. let excelDom = document.getElementById("EXCEL_TYPE");
  320. let pdfDom = document.getElementById("PDF_TYPE");
  321. if (newType === "Excel") {
  322. excelDom.className = "btn btn-block btn-primary";
  323. pdfDom.className = "btn btn-block btn-outline-secondary";
  324. me.currentOutputType = newType;
  325. } else if (newType === "PDF") {
  326. excelDom.className = "btn btn-block btn-outline-secondary";
  327. pdfDom.className = "btn btn-block btn-primary";
  328. me.currentOutputType = newType;
  329. } else {
  330. //me.currentOutputType = newType;
  331. }
  332. },
  333. outputRpt: function() {
  334. let me = rptControlObj;
  335. if (me.currentOutputType === "Excel") {
  336. me.getExcel();
  337. } else if (me.currentOutputType === "PDF") {
  338. me.getPDF();
  339. } else {
  340. //other types if needed.
  341. }
  342. },
  343. getAllInOneBook: function () {
  344. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  345. let orgRptName = projectInfoObj.projectInfo.name;
  346. let refRptTplIds = [];
  347. for (let node of zTreeOprObj.checkedRptTplNodes) {
  348. refRptTplIds.push(node.refId);
  349. }
  350. window.location = "/report_api/getExcelInOneBook/" + projectInfoObj.projectInfo.ID + "/" + refRptTplIds.join(",") + "/" +
  351. rptControlObj.getCurrentPageSize() + "/" + orgRptName + "/" + 'normal';
  352. }
  353. },
  354. getAllIndividualExcelBook: function () {
  355. let me = rptControlObj;
  356. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  357. let urls = [];
  358. let orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  359. for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
  360. let orgRptName = tplNode.name;
  361. let url = "/report_api/getExcel/" + projectInfoObj.projectInfo.ID + "/" + tplNode.refId + "/" +
  362. me.getCurrentPageSize() + "/" + orientation + "/" + orgRptName + "/" + true + "/" + 'normal';
  363. urls.push(url);
  364. }
  365. downloadReport(urls);
  366. }
  367. },
  368. checkAndGetExcel: function () {
  369. if (zTreeOprObj.treeObj) {
  370. let chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
  371. if (chkNodes.length > 0) {
  372. $("#show_excel_output_cfg").trigger("click");
  373. } else {
  374. rptControlObj.getAllIndividualExcelBook();
  375. }
  376. }
  377. },
  378. getExcel: function () {
  379. let me = rptControlObj;
  380. if ($("#excelExportType_AllInOneBook").get(0).checked) {
  381. me.getAllInOneBook();
  382. } else if ($("#excelExportType_IndividualBook").get(0).checked) {
  383. me.getAllIndividualExcelBook();
  384. }
  385. },
  386. getPDF: function() {
  387. let me = rptControlObj;
  388. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  389. let urls = [];
  390. let orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  391. for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
  392. let orgRptName = tplNode.name;
  393. let url = "/report_api/getPDF/" + projectInfoObj.projectInfo.ID + "/" + tplNode.refId + "/" +
  394. me.getCurrentPageSize() + "/" + orientation + "/" + orgRptName;
  395. urls.push(url);
  396. }
  397. downloadReport(urls);
  398. }
  399. },
  400. firstPage: function(dom) {
  401. let canvas = document.getElementById("rptCanvas");
  402. zTreeOprObj.showPage(1, canvas);
  403. },
  404. prePage: function(dom) {
  405. let canvas = document.getElementById("rptCanvas");
  406. zTreeOprObj.showPage(zTreeOprObj.currentPage - 1, canvas);
  407. },
  408. nextPage: function(dom) {
  409. let canvas = document.getElementById("rptCanvas");
  410. zTreeOprObj.showPage(zTreeOprObj.currentPage + 1, canvas);
  411. },
  412. lastPage: function(dom) {
  413. let me = zTreeOprObj;
  414. let canvas = document.getElementById("rptCanvas");
  415. zTreeOprObj.showPage(me.maxPages, canvas);
  416. },
  417. onKeydown: function (event, dom) {
  418. let me = zTreeOprObj, keyPressed = null;
  419. if (window.event) {
  420. keyPressed = window.event.keyCode; // IE/Chrome
  421. } else {
  422. keyPressed = event.which; // Firefox
  423. }
  424. if (keyPressed === 13) {
  425. let pageNum = 1;
  426. try {
  427. pageNum = parseInt(dom.value);
  428. } catch (e) {
  429. pageNum = 1;
  430. }
  431. let canvas = document.getElementById("rptCanvas");
  432. if (pageNum < 1) {
  433. pageNum = 1;
  434. } else if (pageNum > me.maxPages) {
  435. pageNum = me.maxPages;
  436. }
  437. zTreeOprObj.showPage(pageNum, canvas);
  438. return false;
  439. }
  440. },
  441. changeMargin: function(marginPropStr, marginDom) {
  442. zTreeOprObj.reportPageCfg.margins[marginPropStr] = marginDom.value;
  443. },
  444. changeFontMain: function(CfgDispName, fontProperty, fontDom) {
  445. for (let font of zTreeOprObj.reportPageCfg.fonts) {
  446. if (font["CfgDispName"] === CfgDispName) {
  447. font[fontProperty] = fontDom.value;
  448. break;
  449. }
  450. }
  451. },
  452. changeCfgOption: function (optStr, dom) {
  453. zTreeOprObj.reportPageCfg[optStr] = dom.checked;
  454. },
  455. changeFontAdhoc: function(CfgDispName, fontProperty, fontDom) {
  456. for (let font of zTreeOprObj.reportPageCfg.fonts) {
  457. if (font["CfgDispName"] === CfgDispName) {
  458. if (font[fontProperty] === 'T') {
  459. font[fontProperty] = 'F';
  460. fontDom.className = "btn btn-sm btn-outline-secondary";
  461. } else {
  462. font[fontProperty] = 'T';
  463. fontDom.className = "btn btn-sm btn-outline-secondary active";
  464. }
  465. break;
  466. }
  467. }
  468. },
  469. restoreCustCFG: function () {
  470. let me = this;
  471. zTreeOprObj.renderRptCfg(zTreeOprObj.defReportPageCfg);
  472. zTreeOprObj.extractRptCfg(zTreeOprObj.reportPageCfg);
  473. me.saveCustCfg();
  474. },
  475. saveCustCfg: function() {
  476. let params = {};
  477. params.custCfg = zTreeOprObj.reportPageCfg;
  478. CommonAjax.postEx("report_tpl_api/saveCustomerCfg", params, 20000, true, function(result){
  479. // alert("Save successfully!");
  480. $("#update_msg_response")[0].style.color = "green";
  481. $("#update_msg_response")[0].innerHTML = " (保存成功!)";
  482. setTimeout(function(){
  483. $("#update_msg_response")[0].innerHTML = "";
  484. }, 1000);
  485. }, function (failRst) {
  486. $("#update_msg_response")[0].style.color = "red";
  487. $("#update_msg_response")[0].innerHTML = " (保存失败!)";
  488. setTimeout(function(){
  489. $("#update_msg_response")[0].innerHTML = "";
  490. }, 1000);
  491. }, null
  492. );
  493. },
  494. confirmCfgChange: function() {
  495. let treeNode = zTreeOprObj.currentNode;
  496. if (treeNode.nodeType === TPL_TYPE_TEMPLATE && treeNode.refId > 0) {
  497. let params = {};
  498. params.pageSize = rptControlObj.getCurrentPageSize();
  499. params.rpt_tpl_id = treeNode.refId;
  500. params.prj_id = projectInfoObj.projectInfo.ID;
  501. params.custCfg = zTreeOprObj.reportPageCfg;
  502. zTreeOprObj.requestReport(params);
  503. }
  504. }
  505. };
  506. function downloadReport(urls) {
  507. //考虑到多个报表下载,一些浏览器(如chrome)不允许一下子下载多个文件,得缓缓处理,统一在这处理
  508. rptControlObj.currentDownloadUrl = null;
  509. rptControlObj.currentDownloadIdx = 0;
  510. let private_download = function() {
  511. if (rptControlObj.currentDownloadIdx >= 0 && rptControlObj.currentDownloadIdx < urls.length) {
  512. rptControlObj.currentDownloadUrl = urls[rptControlObj.currentDownloadIdx];
  513. rptControlObj.currentDownloadIdx++;
  514. window.location = rptControlObj.currentDownloadUrl;
  515. setTimeout(private_download, 2000);
  516. }
  517. }
  518. private_download();
  519. }