rpt_main.js 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  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 fontSuffixMapObj = {"表标题": "title", "列标题": "column", "正文内容": "content", "合计": "summary", "表眉/表脚": "header_footer"};
  10. let rptTplObj = {
  11. hasInitialized: false,
  12. iniPage: function() {
  13. let me = this;
  14. if (!me.hasInitialized) {
  15. zTreeOprObj.getCustomerCfg();
  16. zTreeOprObj.getReportTemplateTree();
  17. me.hasInitialized = true;
  18. let canvas = document.getElementById("rptCanvas");
  19. canvas.onclick = canvasOprObj.canvasOnClick;
  20. canvas.onmousemove = canvasOprObj.canvasOnMouseMove;
  21. }
  22. }
  23. }
  24. let zTreeOprObj = {
  25. treeObj: null,
  26. prjFolderTreeObj: null,
  27. currentNode: null,
  28. checkedRptTplNodes: null,
  29. currentRptPageRst: null,
  30. reportPageCfg: null,
  31. defReportPageCfg: null,
  32. currentPage: 1,
  33. maxPages: 0,
  34. countChkedRptTpl: function () {
  35. let me = zTreeOprObj;
  36. if (me.treeObj) {
  37. me.checkedRptTplNodes = [];
  38. let chkNodes = me.treeObj.getCheckedNodes(true), cnt = 0, hasCurrentNode = false;
  39. for (let node of chkNodes) {
  40. if (node.nodeType === TPL_TYPE_TEMPLATE) {
  41. cnt++;
  42. me.checkedRptTplNodes.push(node);
  43. if (me.currentNode === node) hasCurrentNode = true;
  44. }
  45. }
  46. if (!hasCurrentNode && cnt === 0 && me.currentNode !== null) {
  47. //这里根据实际需求再做处理
  48. cnt++;
  49. me.checkedRptTplNodes.push(me.currentNode);
  50. }
  51. $("#export_div").find("span").each(function(cIdx,elementSpan){
  52. elementSpan.innerText = cnt;
  53. });
  54. $("#print_div").find("span").each(function(cIdx,elementSpan){
  55. elementSpan.innerText = cnt;
  56. });
  57. }
  58. },
  59. getReportTemplateTree: function() {
  60. let me = zTreeOprObj, params = {};
  61. params.engineerId = projectObj.project.projectInfo.property.engineering;
  62. let private_chk_hide = function (chkTplItem) {
  63. //考虑未来拓展,统一在此判断报表模板是否显示
  64. let rst = false;
  65. // if (chkTplItem.hasOwnProperty('flags') && chkTplItem.flags.hasOwnProperty('taxType') && chkTplItem.flags['taxType'] !== null &&
  66. // parseInt(chkTplItem.flags['taxType']) !== parseInt(projectObj.project.projectInfo.property.taxType)) {
  67. // rst = true;
  68. // }
  69. //重庆养护系统的判断逻辑有所不同
  70. if (chkTplItem.hasOwnProperty('flags') && chkTplItem.flags.hasOwnProperty('valuationType') && chkTplItem.flags['valuationType'] !== null &&
  71. chkTplItem.flags['valuationType'] !== projectObj.project.projectInfo.property.valuationType) {
  72. rst = true;
  73. }
  74. return rst;
  75. };
  76. // projectObj.project.projectInfo.property.taxType === 1 //1: 一般计税 2: 简易计税
  77. CommonAjax.postEx("report_tpl_api/getRptTplTree", params, 20000, true, function(result){
  78. let private_remove_hide_item = function (items, nlv) {
  79. if (items && items.length > 0) {
  80. for (let i = items.length - 1; i >= 0; i--) {
  81. if (!(items[i].released) && items[i].nodeType === 2) {
  82. items.splice(i, 1);
  83. } else if(private_chk_hide(items[i])) {
  84. items.splice(i, 1);
  85. } else {
  86. if (items[i].items && items[i].items.length > 0) {
  87. private_remove_hide_item(items[i].items, nlv + 1);
  88. if (items[i].items.length === 0 && nlv > 0) {
  89. items.splice(i, 1);
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. let nodeLv = 0;
  97. private_remove_hide_item(result, nodeLv);
  98. for (let topNode of result) {
  99. if (topNode.userId === "-100") {
  100. topNode.name = topNode.name + " - 标准报表";
  101. } else {
  102. topNode.name = topNode.name + " - 定制报表";
  103. }
  104. }
  105. zTreeHelper.createTreeDirectly(result, rpt_tpl_setting, "rptTplTree", me);
  106. me.refreshNodes();
  107. }, null, null);
  108. },
  109. getCustomerCfg: function() {
  110. let me = zTreeOprObj, params = {};
  111. params.engineerId = projectObj.project.projectInfo.property.engineering;
  112. CommonAjax.postEx("report_tpl_api/getCustomizeCfg", params, 20000, true, function(result){
  113. if (result) {
  114. me.defReportPageCfg = result[0];
  115. me.reportPageCfg = result[1];
  116. me.iniFontCfgDom(me.reportPageCfg);
  117. me.renderRptCfg(result[1]);
  118. } else {
  119. me.reportPageCfg = null;
  120. me.defReportPageCfg = null;
  121. }
  122. }, null, null
  123. );
  124. },
  125. iniFontCfgDom: function (cfg) {
  126. for (let font of cfg.fonts) {
  127. let domArrs = [];
  128. let fontPropSuffix = fontSuffixMapObj[font.CfgDispName];
  129. domArrs.push("<div class='row mb-1'>");
  130. //1. label
  131. domArrs.push("<div class='col-3'>" + font.CfgDispName + "</div>");
  132. //2. font name
  133. domArrs.push("<div class='col-3'>");
  134. domArrs.push("<select class='form-control input-sm' id='fontName_" + fontPropSuffix + "' onchange='rptControlObj.changeFontMain(\"" + font.CfgDispName + "\", \"Name\", this)'>");
  135. domArrs.push("<option>宋体</option><option>楷体</option><option>黑体</option>");
  136. domArrs.push("</select>");
  137. domArrs.push("</div>");
  138. //3. font height
  139. domArrs.push("<div class='col-3'>");
  140. domArrs.push("<input class='form-control input-sm' id='fontHeight_" + fontPropSuffix + "' type='number' value='30' step='1' min='6' max='66' " +
  141. "onchange='rptControlObj.changeFontMain(\"" + font.CfgDispName + "\", \"FontHeight\", this)' " +
  142. "onkeyup='rptControlObj.changeFontMain(\"" + font.CfgDispName + "\", \"FontHeight\", this)'>");
  143. domArrs.push("</div>");
  144. //4. font bold italic underline
  145. domArrs.push("<div class='col-3'>");
  146. domArrs.push("<a id='font_bold_" + fontPropSuffix + "' class='btn btn-sm btn-outline-secondary' title='加粗' onclick='rptControlObj.changeFontAdhoc(\"" + font.CfgDispName + "\", \"FontBold\", this)'><i class='fa fa-bold'></i></a>");
  147. domArrs.push("<a id='font_italic_" + fontPropSuffix + "' class='btn btn-sm btn-outline-secondary' title='斜体' onclick='rptControlObj.changeFontAdhoc(\"" + font.CfgDispName + "\", \"FontItalic\", this)'><i class='fa fa-italic'></i></a>");
  148. domArrs.push("<a id='font_underline_" + fontPropSuffix + "' class='btn btn-sm btn-outline-secondary' title='下划线' onclick='rptControlObj.changeFontAdhoc(\"" + font.CfgDispName + "\", \"FontUnderline\", this)'><i class='fa fa-underline'></i></a>");
  149. domArrs.push("</div>");
  150. //
  151. domArrs.push("</div>");
  152. $(domArrs.join("")).insertBefore($("#font_cfg_blank_flag"));
  153. }
  154. },
  155. renderRptCfg: function (cfg) {
  156. $("#elementMargin_Left").get(0).value = cfg.margins.Left;
  157. $("#elementMargin_Right").get(0).value = cfg.margins.Right;
  158. $("#elementMargin_Top").get(0).value = cfg.margins.Top;
  159. $("#elementMargin_Bottom").get(0).value = cfg.margins.Bottom;
  160. for (let font of cfg.fonts) {
  161. let fontPropSuffix = fontSuffixMapObj[font.CfgDispName];
  162. document.getElementById("fontName_" + fontPropSuffix).value = font.Name;
  163. document.getElementById("fontHeight_" + fontPropSuffix).value = font.FontHeight;
  164. document.getElementById("font_bold_" + fontPropSuffix).className = (font.FontBold === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  165. document.getElementById("font_italic_" + fontPropSuffix).className = (font.FontItalic === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  166. document.getElementById("font_underline_" + fontPropSuffix).className = (font.FontUnderline === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  167. }
  168. document.getElementById("rpt_vertical_line").checked = cfg.showVerticalLine;
  169. document.getElementById("rpt_narrow").checked = cfg.isNarrow;
  170. // document.getElementById("rpt_narrow").checked = false;
  171. document.getElementById("rpt_fill_zero").checked = cfg.fillZero;
  172. },
  173. extractRptCfg: function (cfg) {
  174. cfg.margins.Left = $("#elementMargin_Left").get(0).value;
  175. cfg.margins.Right = $("#elementMargin_Right").get(0).value;
  176. cfg.margins.Top = $("#elementMargin_Top").get(0).value;
  177. cfg.margins.Bottom = $("#elementMargin_Bottom").get(0).value;
  178. for (let font of cfg.fonts) {
  179. let fontPropSuffix = fontSuffixMapObj[font.CfgDispName];
  180. font.Name = document.getElementById("fontName_" + fontPropSuffix).value;
  181. font.FontHeight = document.getElementById("fontHeight_" + fontPropSuffix).value;
  182. font.FontBold = (document.getElementById("font_bold_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  183. font.FontItalic = (document.getElementById("font_italic_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  184. font.FontUnderline = (document.getElementById("font_underline_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  185. }
  186. cfg.showVerticalLine = document.getElementById("rpt_vertical_line").checked;
  187. cfg.isNarrow = document.getElementById("rpt_narrow").checked;
  188. cfg.fillZero = document.getElementById("rpt_fill_zero").checked;
  189. },
  190. refreshNodes: function() {
  191. let me = this;
  192. let private_setupIsParent = function(node){
  193. node.isParent = (node.nodeType === RT.NodeType.NODE || node.level === 0);
  194. if (node.items && node.items.length) {
  195. for (let i = 0; i < node.items.length; i++) {
  196. private_setupIsParent(node.items[i]);
  197. }
  198. }
  199. };
  200. let topNodes = me.treeObj.getNodes();
  201. for (let i = 0; i < topNodes.length; i++) {
  202. private_setupIsParent(topNodes[i]);
  203. }
  204. me.treeObj.refresh();
  205. },
  206. onCheck: function(event, treeId, treeNode) {
  207. zTreeOprObj.countChkedRptTpl();
  208. },
  209. onClick: function(event,treeId,treeNode) {
  210. let me = zTreeOprObj;
  211. if (treeNode.nodeType === TPL_TYPE_TEMPLATE && treeNode.refId > 0) {
  212. me.currentNode = treeNode;
  213. if (treeNode.hasOwnProperty('flags') && treeNode.flags.hasOwnProperty('reportType') && treeNode['flags']['reportType'] !== 'NA') {
  214. if (treeNode['flags']['reportType'] === 'billSummary') {
  215. me.requestPrjFolderForBillsSummary();
  216. } else if (treeNode['flags']['reportType'] === 'gljSummary') {
  217. me.requestPrjFolderForGljSummary();
  218. }
  219. } else {
  220. let params = {};
  221. let pageSize = rptControlObj.getCurrentPageSize();
  222. params.pageSize = pageSize;
  223. params.rpt_tpl_id = treeNode.refId;
  224. params.prj_id = projectObj.project.projectInfo.ID;
  225. params.custCfg = me.reportPageCfg;
  226. me.requestReport(params);
  227. }
  228. me.countChkedRptTpl();
  229. }
  230. },
  231. changePageSize: function(dom) {
  232. let me = zTreeOprObj,
  233. targetDom = document.getElementById("btnRptPageSize");
  234. let tmpStr = targetDom.innerHTML.trim();
  235. targetDom.innerHTML = dom.innerHTML.trim();
  236. dom.innerHTML = tmpStr;
  237. me.changeCfg();
  238. },
  239. changeOrientation: function(dom) {
  240. let me = zTreeOprObj,
  241. targetDom = document.getElementById("btnRptOrientation");
  242. let tmpStr = targetDom.innerHTML.trim();
  243. targetDom.innerHTML = dom.innerHTML.trim();
  244. dom.innerHTML = tmpStr;
  245. me.changeCfg();
  246. },
  247. changeCfg: function() {
  248. let me = zTreeOprObj;
  249. let params = {};
  250. params.pageSize = rptControlObj.getCurrentPageSize();
  251. params.orientation = rptControlObj.getCurrentOrientation();
  252. params.rpt_tpl_id = me.currentNode.refId;
  253. params.prj_id = projectObj.project.projectInfo.ID;
  254. params.custCfg = me.reportPageCfg;
  255. me.requestReport(params);
  256. },
  257. resetAfter: function (pageRst) {
  258. let size = pageRst[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE].slice(0);
  259. if (size[0] > size[1]) {
  260. document.getElementById("btnRptOrientation").innerHTML = "横向";
  261. document.getElementById("hrefRptOrientation").innerHTML = "纵向";
  262. } else {
  263. document.getElementById("btnRptOrientation").innerHTML = "纵向";
  264. document.getElementById("hrefRptOrientation").innerHTML = "横向";
  265. }
  266. },
  267. requestReport: function (params) {
  268. let me = zTreeOprObj;
  269. hintBox.waitBox();
  270. CommonAjax.postEx("report_api/getReport", params, 60000, true,
  271. function(result){
  272. hintBox.unWaitBox();
  273. let pageRst = result;
  274. let canvas = document.getElementById("rptCanvas");
  275. if (pageRst && pageRst.items && pageRst.items.length > 0) {
  276. me.resetAfter(pageRst);
  277. me.currentRptPageRst = pageRst;
  278. me.maxPages = pageRst.items.length;
  279. me.currentPage = 1;
  280. me.displayPageValue();
  281. let size = JpcCanvasOutput.getReportSizeInPixel(me.currentRptPageRst, getScreenDPI());
  282. canvas.width = size[0] + 20;
  283. if (size[1] > size[0]) {
  284. canvas.height = size[1] + 100;
  285. } else {
  286. canvas.height = size[1] + 50;
  287. }
  288. me.showPage(1, canvas);
  289. } else {
  290. //返回了无数据表
  291. JpcCanvasOutput.cleanCanvas(canvas);
  292. JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
  293. }
  294. }, function(err){
  295. hintBox.unWaitBox();
  296. }, function(ex){
  297. hintBox.unWaitBox();
  298. }
  299. );
  300. },
  301. requestPrjFolderCommon: function () {
  302. let me = zTreeOprObj;
  303. hintBox.waitBox();
  304. $.ajax({
  305. type:"POST",
  306. url: '/pm/api/getProjects',
  307. data: {'data': JSON.stringify({"user_id": userID, "compilation": projectObj.project.projectInfo.compilation})},
  308. dataType: 'json',
  309. cache: false,
  310. timeout: 15000,
  311. success: function(result){
  312. hintBox.unWaitBox();
  313. if (result.error === 0) {
  314. //console.log(result.data);
  315. let currPrjParentID = projectObj.project.projectInfo.ParentID;
  316. let selectedProjects = [];
  317. for (let prj of result.data) {
  318. if (currPrjParentID === prj.ParentID) {
  319. selectedProjects.push({name: prj.name, ID: prj.ID});
  320. }
  321. }
  322. $("#show_project_folder").trigger("click");
  323. me.prjFolderTreeObj = $.fn.zTree.init($("#prjFolderTree"), rpt_prj_folder_setting, selectedProjects);
  324. me.prjFolderTreeObj.expandAll(true);
  325. } else {
  326. alert('error: ' + result.message);
  327. }
  328. },
  329. error: function(jqXHR, textStatus, errorThrown){
  330. hintBox.unWaitBox();
  331. alert('error ' + textStatus + " " + errorThrown);
  332. }
  333. });
  334. },
  335. requestPrjFolderForBillsSummary: function () {
  336. let me = zTreeOprObj;
  337. $("#divReqBillSummary")[0].style.display = "";
  338. $("#divReqGljSummary")[0].style.display = "none";
  339. $("#divReqCommonSummaryExcel")[0].style.display = "none";
  340. $("#divReqCommonSummaryMultiExcel")[0].style.display = "none";
  341. $("#divReqCommonSummaryPDF")[0].style.display = "none";
  342. me.requestPrjFolderCommon();
  343. },
  344. requestPrjFolderForGljSummary: function () {
  345. let me = zTreeOprObj;
  346. $("#divReqBillSummary")[0].style.display = "none";
  347. $("#divReqGljSummary")[0].style.display = "";
  348. $("#divReqCommonSummaryExcel")[0].style.display = "none";
  349. $("#divReqCommonSummaryMultiExcel")[0].style.display = "none";
  350. $("#divReqCommonSummaryPDF")[0].style.display = "none";
  351. me.requestPrjFolderCommon();
  352. },
  353. requestBillsSummaryRpt: function () {
  354. let me = zTreeOprObj;
  355. let nodes = me.prjFolderTreeObj.getCheckedNodes(true);
  356. if (nodes.length > 0) {
  357. hintBox.waitBox();
  358. let params = {};
  359. params.pageSize = rptControlObj.getCurrentPageSize();
  360. params.rpt_tpl_id = me.currentNode.refId;
  361. params.custCfg = me.reportPageCfg;
  362. params.prjIds = [];
  363. for (let node of nodes) {
  364. params.prjIds.push(node.ID);
  365. }
  366. CommonAjax.postEx("report_api/getBillsSummaryReport", params, 26000, true,
  367. function(result){
  368. hintBox.unWaitBox();
  369. let pageRst = result;
  370. let canvas = document.getElementById("rptCanvas");
  371. if (pageRst && pageRst.items && pageRst.items.length > 0) {
  372. me.resetAfter(pageRst);
  373. me.currentRptPageRst = pageRst;
  374. me.maxPages = pageRst.items.length;
  375. me.currentPage = 1;
  376. me.displayPageValue();
  377. let size = JpcCanvasOutput.getReportSizeInPixel(me.currentRptPageRst, getScreenDPI());
  378. canvas.width = size[0] + 20;
  379. if (size[1] > size[0]) {
  380. canvas.height = size[1] + 100;
  381. } else {
  382. canvas.height = size[1] + 50;
  383. }
  384. me.showPage(1, canvas);
  385. } else {
  386. //返回了无数据表
  387. JpcCanvasOutput.cleanCanvas(canvas);
  388. JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
  389. }
  390. }, function(err){
  391. hintBox.unWaitBox();
  392. }, function(ex){
  393. hintBox.unWaitBox();
  394. }
  395. );
  396. }
  397. },
  398. requestGljSummaryRpt: function () {
  399. let me = zTreeOprObj;
  400. let nodes = me.prjFolderTreeObj.getCheckedNodes(true);
  401. if (nodes.length > 0) {
  402. hintBox.waitBox();
  403. let params = {};
  404. params.pageSize = rptControlObj.getCurrentPageSize();
  405. params.rpt_tpl_id = me.currentNode.refId;
  406. params.custCfg = me.reportPageCfg;
  407. params.prjIds = [];
  408. for (let node of nodes) {
  409. params.prjIds.push(node.ID);
  410. }
  411. CommonAjax.postEx("report_api/getGljSummaryReport", params, 26000, true,
  412. function(result){
  413. hintBox.unWaitBox();
  414. let pageRst = result;
  415. let canvas = document.getElementById("rptCanvas");
  416. if (pageRst && pageRst.items && pageRst.items.length > 0) {
  417. me.resetAfter(pageRst);
  418. me.currentRptPageRst = pageRst;
  419. me.maxPages = pageRst.items.length;
  420. me.currentPage = 1;
  421. me.displayPageValue();
  422. let size = JpcCanvasOutput.getReportSizeInPixel(me.currentRptPageRst, getScreenDPI());
  423. canvas.width = size[0] + 20;
  424. if (size[1] > size[0]) {
  425. canvas.height = size[1] + 100;
  426. } else {
  427. canvas.height = size[1] + 50;
  428. }
  429. me.showPage(1, canvas);
  430. } else {
  431. //返回了无数据表
  432. JpcCanvasOutput.cleanCanvas(canvas);
  433. JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
  434. }
  435. }, function(err){
  436. hintBox.unWaitBox();
  437. }, function(ex){
  438. hintBox.unWaitBox();
  439. }
  440. );
  441. }
  442. },
  443. requestSumAndNormalRptForPDF: function () {
  444. let me = rptControlObj;
  445. let rpt_names = [], bill_rpt_names = [], glj_rpt_names = [];
  446. let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
  447. for (let node of zTreeOprObj.checkedRptTplNodes) {
  448. if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
  449. if (node['flags']['reportType'] === 'billSummary') {
  450. refBillSumPrjsIds.push(node.refId);
  451. bill_rpt_names.push(node.name);
  452. } else if (node['flags']['reportType'] === 'gljSummary') {
  453. refGljSumPrjsIds.push(node.refId);
  454. glj_rpt_names.push(node.name);
  455. }
  456. } else {
  457. refRptTplIds.push(node.refId);
  458. rpt_names.push(node.name);
  459. }
  460. }
  461. let nodes = zTreeOprObj.prjFolderTreeObj.getCheckedNodes(true);
  462. let params = {};
  463. params.prj_id = projectObj.project.projectInfo.ID;
  464. params.rpt_ids = refRptTplIds;
  465. params.rpt_bill_tpl_ids = refBillSumPrjsIds;
  466. params.rpt_glj_tpl_ids = refGljSumPrjsIds;
  467. params.prjIds = [];
  468. for (let node of nodes) {
  469. params.prjIds.push(node.ID);
  470. }
  471. params.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
  472. params.rpt_names = rpt_names;
  473. params.isOneSheet = true;
  474. params.pageSize = me.getCurrentPageSize();
  475. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  476. params.custCfg = zTreeOprObj.reportPageCfg;
  477. params.option = "normal";
  478. CommonAjax.postEx("report_api/createPdfFiles", params, 120000, true, function(result){
  479. if (result) {
  480. let uuIdUrls = [];
  481. for (let uuIdObj of result) {
  482. let uuIdUrl = "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/pdf";
  483. uuIdUrls.push(uuIdUrl);
  484. }
  485. downloadReport(uuIdUrls);
  486. } else {
  487. //
  488. }
  489. }, null, null
  490. );
  491. },
  492. requestSumAndNormalRptForMultiExcel: function () {
  493. let me = rptControlObj;
  494. let rpt_names = [], bill_rpt_names = [], glj_rpt_names = [];
  495. let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
  496. for (let node of zTreeOprObj.checkedRptTplNodes) {
  497. if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
  498. if (node['flags']['reportType'] === 'billSummary') {
  499. refBillSumPrjsIds.push(node.refId);
  500. bill_rpt_names.push(node.name);
  501. } else if (node['flags']['reportType'] === 'gljSummary') {
  502. refGljSumPrjsIds.push(node.refId);
  503. glj_rpt_names.push(node.name);
  504. }
  505. } else {
  506. refRptTplIds.push(node.refId);
  507. rpt_names.push(node.name);
  508. }
  509. }
  510. let nodes = zTreeOprObj.prjFolderTreeObj.getCheckedNodes(true);
  511. let params = {};
  512. params.prj_id = projectObj.project.projectInfo.ID;
  513. params.rpt_ids = refRptTplIds;
  514. params.rpt_bill_tpl_ids = refBillSumPrjsIds;
  515. params.rpt_glj_tpl_ids = refGljSumPrjsIds;
  516. params.prjIds = [];
  517. for (let node of nodes) {
  518. params.prjIds.push(node.ID);
  519. }
  520. params.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
  521. params.rpt_names = rpt_names;
  522. params.isOneSheet = true;
  523. params.pageSize = me.getCurrentPageSize();
  524. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  525. params.custCfg = zTreeOprObj.reportPageCfg;
  526. params.option = "normal";
  527. CommonAjax.postEx("report_api/createExcelFiles", params, 120000, true, function(result){
  528. if (result) {
  529. let uuIdUrls = [];
  530. for (let uuIdObj of result) {
  531. let uuIdUrl = "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/xlsx";
  532. uuIdUrls.push(uuIdUrl);
  533. }
  534. downloadReport(uuIdUrls);
  535. } else {
  536. //
  537. }
  538. }, null, null
  539. );
  540. },
  541. requestSumAndNormalRptForAllInOneExcel: function () {
  542. let me = rptControlObj;
  543. let orgRptName = projectObj.project.projectInfo.name;
  544. let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
  545. for (let node of zTreeOprObj.checkedRptTplNodes) {
  546. if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
  547. if (node['flags']['reportType'] === 'billSummary') {
  548. refBillSumPrjsIds.push(node.refId);
  549. } else if (node['flags']['reportType'] === 'gljSummary') {
  550. refGljSumPrjsIds.push(node.refId);
  551. }
  552. } else {
  553. refRptTplIds.push(node.refId);
  554. }
  555. }
  556. let nodes = zTreeOprObj.prjFolderTreeObj.getCheckedNodes(true);
  557. let params = {};
  558. params.prj_id = projectObj.project.projectInfo.ID;
  559. params.rpt_ids = refRptTplIds;
  560. params.rpt_bill_tpl_ids = refBillSumPrjsIds;
  561. params.rpt_glj_tpl_ids = refGljSumPrjsIds;
  562. params.prjIds = [];
  563. for (let node of nodes) {
  564. params.prjIds.push(node.ID);
  565. }
  566. params.rptName = orgRptName;
  567. params.pageSize = me.getCurrentPageSize();
  568. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  569. params.custCfg = zTreeOprObj.reportPageCfg;
  570. params.option = "normal";
  571. CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, 120000, true, function(result){
  572. if (result) {
  573. let uuIdUrls = [];
  574. let uuIdUrl = "/report_api/getFileByUUID/" + result.uuid + "/" + stringUtil.replaceAll(result.reportName, "#", "_") + "/xlsx";
  575. uuIdUrls.push(uuIdUrl);
  576. downloadReport(uuIdUrls);
  577. } else {
  578. //
  579. }
  580. }, null, null
  581. );
  582. },
  583. showPage: function (pageNum, canvas) {
  584. let me = zTreeOprObj;
  585. if (pageNum >= 1 && pageNum <= me.maxPages) {
  586. me.currentPage = pageNum;
  587. JpcCanvasOutput.cleanCanvas(canvas);
  588. JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
  589. JpcCanvasOutput.drawToCanvas(me.currentRptPageRst, canvas, me.currentPage);
  590. }
  591. me.displayPageValue();
  592. },
  593. displayPageValue: function() {
  594. let me = zTreeOprObj;
  595. $("#rpt_page_num").get(0).value = me.currentPage + "/" + me.maxPages;
  596. }
  597. };
  598. let canvasOprObj = {
  599. canvasOnMouseMove: function (event) {
  600. if (zTreeOprObj.currentNode) {
  601. let x = event.offsetX - JpcCanvasOutput.offsetX, canvas = event.originalTarget;
  602. if (!(canvas)) canvas = event.target; //chrome浏览器不认event.originalTarget,只认event.target或event.currentTarget
  603. if (x < FIRST_PAGE_OFFSET) {
  604. canvas.style.cursor = "url(/web/building_saas/img/FirstPageSimple.cur), auto";
  605. } else if (x < PRE_PAGE_OFFSET) {
  606. canvas.style.cursor = "url(/web/building_saas/img/PreviousPageSimple.cur), auto";
  607. } else if ((canvas.width - x) < LAST_PAGE_OFFSET) {
  608. canvas.style.cursor = "url(/web/building_saas/img/LastPageSimple.cur), auto";
  609. } else if ((canvas.width - x) < NEXT_PAGE_OFFSET) {
  610. canvas.style.cursor = "url(/web/building_saas/img/NextPageSimple.cur), auto";
  611. } else {
  612. canvas.style.cursor = "";
  613. }
  614. }
  615. },
  616. canvasOnClick: function(event){
  617. if (zTreeOprObj.currentNode) {
  618. let x = event.offsetX - JpcCanvasOutput.offsetX, canvas = event.originalTarget;
  619. if (!(canvas)) canvas = event.target; //chrome浏览器不认event.originalTarget,只认event.target或event.currentTarget
  620. if (x < FIRST_PAGE_OFFSET) {
  621. zTreeOprObj.showPage(1, canvas);
  622. } else if (x < PRE_PAGE_OFFSET) {
  623. zTreeOprObj.showPage(zTreeOprObj.currentPage - 1, canvas);
  624. } else if ((canvas.width - x) < LAST_PAGE_OFFSET) {
  625. zTreeOprObj.showPage(zTreeOprObj.maxPages, canvas);
  626. } else if ((canvas.width - x) < NEXT_PAGE_OFFSET) {
  627. zTreeOprObj.showPage(zTreeOprObj.currentPage + 1, canvas);
  628. }
  629. }
  630. }
  631. };
  632. let rptControlObj = {
  633. currentOutputType: "Excel",
  634. currentDownloadUrl: null,
  635. currentDownloadIdx: 0,
  636. getCurrentPageSize: function() {
  637. // let rst = "A4";
  638. let rst = document.getElementById("btnRptPageSize").innerHTML.trim();
  639. //btnRptPageSize
  640. return rst;
  641. },
  642. getCurrentOrientation: function() {
  643. // let rst = "横向";
  644. let rst = document.getElementById("btnRptOrientation").innerHTML.trim();
  645. return rst;
  646. },
  647. getCurrentReportOption: function() {
  648. //
  649. },
  650. changeType: function(newType) {
  651. let me = rptControlObj;
  652. let excelDom = document.getElementById("EXCEL_TYPE");
  653. let pdfDom = document.getElementById("PDF_TYPE");
  654. if (newType === "Excel") {
  655. excelDom.className = "btn btn-block btn-primary";
  656. pdfDom.className = "btn btn-block btn-outline-secondary";
  657. me.currentOutputType = newType;
  658. } else if (newType === "PDF") {
  659. excelDom.className = "btn btn-block btn-outline-secondary";
  660. pdfDom.className = "btn btn-block btn-primary";
  661. me.currentOutputType = newType;
  662. } else {
  663. //me.currentOutputType = newType;
  664. }
  665. },
  666. outputRpt: function() {
  667. let me = rptControlObj;
  668. if (me.currentOutputType === "Excel") {
  669. me.getExcel();
  670. } else if (me.currentOutputType === "PDF") {
  671. me.getPDF();
  672. } else {
  673. //other types if needed.
  674. }
  675. },
  676. getAllInOneBook_bk: function () {
  677. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  678. let me = rptControlObj;
  679. let orgRptName = projectObj.project.projectInfo.name;
  680. let refRptTplIds = [];
  681. for (let node of zTreeOprObj.checkedRptTplNodes) {
  682. refRptTplIds.push(node.refId);
  683. }
  684. let params = {};
  685. params.prj_id = projectObj.project.projectInfo.ID;
  686. params.rpt_ids = refRptTplIds;
  687. params.rptName = orgRptName;
  688. params.pageSize = me.getCurrentPageSize();
  689. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  690. params.custCfg = zTreeOprObj.reportPageCfg;
  691. params.option = "normal";
  692. CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, 120000, true, function(result){
  693. if (result) {
  694. let uuIdUrls = [];
  695. let uuIdUrl = "/report_api/getFileByUUID/" + result.uuid + "/" + stringUtil.replaceAll(result.reportName, "#", "_") + "/xlsx";
  696. uuIdUrls.push(uuIdUrl);
  697. downloadReport(uuIdUrls);
  698. } else {
  699. //
  700. }
  701. }, null, null
  702. );
  703. }
  704. },
  705. getAllInOneBook: function () {
  706. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  707. let me = rptControlObj;
  708. let orgRptName = projectObj.project.projectInfo.name;
  709. let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
  710. for (let node of zTreeOprObj.checkedRptTplNodes) {
  711. if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
  712. if (node['flags']['reportType'] === 'billSummary') {
  713. refBillSumPrjsIds.push(node.refId);
  714. } else if (node['flags']['reportType'] === 'gljSummary') {
  715. refGljSumPrjsIds.push(node.refId);
  716. }
  717. } else {
  718. refRptTplIds.push(node.refId);
  719. }
  720. }
  721. if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
  722. $("#divReqBillSummary")[0].style.display = "none";
  723. $("#divReqGljSummary")[0].style.display = "none";
  724. $("#divReqCommonSummaryExcel")[0].style.display = "";
  725. $("#divReqCommonSummaryMultiExcel")[0].style.display = "none";
  726. $("#divReqCommonSummaryPDF")[0].style.display = "none";
  727. zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
  728. } else if (refRptTplIds.length > 0) {
  729. let params = {};
  730. params.prj_id = projectObj.project.projectInfo.ID;
  731. params.rpt_ids = refRptTplIds;
  732. params.rptName = orgRptName;
  733. params.pageSize = me.getCurrentPageSize();
  734. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  735. params.custCfg = zTreeOprObj.reportPageCfg;
  736. params.option = "normal";
  737. CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, 120000, true, function(result){
  738. if (result) {
  739. let uuIdUrls = [];
  740. let uuIdUrl = "/report_api/getFileByUUID/" + result.uuid + "/" + stringUtil.replaceAll(result.reportName, "#", "_") + "/xlsx";
  741. uuIdUrls.push(uuIdUrl);
  742. downloadReport(uuIdUrls);
  743. } else {
  744. //
  745. }
  746. }, null, null
  747. );
  748. }
  749. }
  750. },
  751. getAllIndividualExcelBook_bk: function () {
  752. let me = rptControlObj;
  753. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  754. let rpt_ids = [], rpt_names = [];
  755. for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
  756. rpt_ids.push(tplNode.refId);
  757. rpt_names.push(tplNode.name)
  758. }
  759. let params = {};
  760. params.prj_id = projectObj.project.projectInfo.ID;
  761. params.rpt_ids = rpt_ids;
  762. params.rpt_names = rpt_names;
  763. params.pageSize = me.getCurrentPageSize();
  764. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  765. params.isOneSheet = true;
  766. params.custCfg = zTreeOprObj.reportPageCfg;
  767. params.option = "normal";
  768. CommonAjax.postEx("report_api/createExcelFiles", params, 120000, true, function(result){
  769. if (result) {
  770. let uuIdUrls = [];
  771. for (let uuIdObj of result) {
  772. let uuIdUrl = "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/xlsx";
  773. uuIdUrls.push(uuIdUrl);
  774. }
  775. downloadReport(uuIdUrls);
  776. } else {
  777. //
  778. }
  779. }, null, null
  780. );
  781. }
  782. },
  783. getAllIndividualExcelBook: function () {
  784. let me = rptControlObj;
  785. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  786. let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [], rpt_names = [];
  787. for (let node of zTreeOprObj.checkedRptTplNodes) {
  788. if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
  789. if (node['flags']['reportType'] === 'billSummary') {
  790. refBillSumPrjsIds.push(node.refId);
  791. } else if (node['flags']['reportType'] === 'gljSummary') {
  792. refGljSumPrjsIds.push(node.refId);
  793. }
  794. } else {
  795. refRptTplIds.push(node.refId);
  796. rpt_names.push(node.name);
  797. }
  798. }
  799. if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
  800. $("#divReqBillSummary")[0].style.display = "none";
  801. $("#divReqGljSummary")[0].style.display = "none";
  802. $("#divReqCommonSummaryExcel")[0].style.display = "none";
  803. $("#divReqCommonSummaryMultiExcel")[0].style.display = "";
  804. $("#divReqCommonSummaryPDF")[0].style.display = "none";
  805. zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
  806. } else if (refRptTplIds.length > 0) {
  807. let params = {};
  808. params.prj_id = projectObj.project.projectInfo.ID;
  809. params.rpt_ids = refRptTplIds;
  810. params.rpt_names = rpt_names;
  811. params.pageSize = me.getCurrentPageSize();
  812. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  813. params.isOneSheet = true;
  814. params.custCfg = zTreeOprObj.reportPageCfg;
  815. params.option = "normal";
  816. CommonAjax.postEx("report_api/createExcelFiles", params, 120000, true, function(result){
  817. if (result) {
  818. let uuIdUrls = [];
  819. for (let uuIdObj of result) {
  820. let uuIdUrl = "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/xlsx";
  821. uuIdUrls.push(uuIdUrl);
  822. }
  823. downloadReport(uuIdUrls);
  824. } else {
  825. //
  826. }
  827. }, null, null
  828. );
  829. }
  830. }
  831. },
  832. checkAndGetExcel: function () {
  833. if (zTreeOprObj.treeObj) {
  834. let chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
  835. if (chkNodes.length > 0) {
  836. $("#show_excel_output_cfg").trigger("click");
  837. } else {
  838. rptControlObj.getAllIndividualExcelBook();
  839. }
  840. }
  841. },
  842. getExcel: function () {
  843. let me = rptControlObj;
  844. if ($("#excelExportType_AllInOneBook").get(0).checked) {
  845. me.getAllInOneBook();
  846. } else if ($("#excelExportType_IndividualBook").get(0).checked) {
  847. me.getAllIndividualExcelBook();
  848. }
  849. },
  850. getPDF_bk: function() {
  851. let me = rptControlObj;
  852. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  853. let rpt_ids = [], rpt_names = [];
  854. for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
  855. rpt_ids.push(tplNode.refId);
  856. rpt_names.push(tplNode.name)
  857. }
  858. let params = {};
  859. params.prj_id = projectObj.project.projectInfo.ID;
  860. params.rpt_ids = rpt_ids;
  861. params.rpt_names = rpt_names;
  862. params.pageSize = me.getCurrentPageSize();
  863. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  864. params.custCfg = zTreeOprObj.reportPageCfg;
  865. params.option = "normal";
  866. CommonAjax.postEx("report_api/createPdfFiles", params, 120000, true, function(result){
  867. if (result) {
  868. let uuIdUrls = [];
  869. for (let uuIdObj of result) {
  870. let uuIdUrl = "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/pdf";
  871. uuIdUrls.push(uuIdUrl);
  872. }
  873. downloadReport(uuIdUrls);
  874. } else {
  875. //
  876. }
  877. }, null, null
  878. );
  879. }
  880. },
  881. getPDF: function () {
  882. let me = rptControlObj;
  883. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  884. let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [], rpt_names = [];
  885. for (let node of zTreeOprObj.checkedRptTplNodes) {
  886. if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
  887. if (node['flags']['reportType'] === 'billSummary') {
  888. refBillSumPrjsIds.push(node.refId);
  889. } else if (node['flags']['reportType'] === 'gljSummary') {
  890. refGljSumPrjsIds.push(node.refId);
  891. }
  892. } else {
  893. refRptTplIds.push(node.refId);
  894. rpt_names.push(node.name);
  895. }
  896. }
  897. if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
  898. $("#divReqBillSummary")[0].style.display = "none";
  899. $("#divReqGljSummary")[0].style.display = "none";
  900. $("#divReqCommonSummaryExcel")[0].style.display = "none";
  901. $("#divReqCommonSummaryMultiExcel")[0].style.display = "none";
  902. $("#divReqCommonSummaryPDF")[0].style.display = "";
  903. zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
  904. } else if (refRptTplIds.length > 0) {
  905. let params = {};
  906. params.prj_id = projectObj.project.projectInfo.ID;
  907. params.rpt_ids = refRptTplIds;
  908. params.rpt_names = rpt_names;
  909. params.pageSize = me.getCurrentPageSize();
  910. params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
  911. params.custCfg = zTreeOprObj.reportPageCfg;
  912. params.option = "normal";
  913. CommonAjax.postEx("report_api/createPdfFiles", params, 120000, true, function(result){
  914. if (result) {
  915. let uuIdUrls = [];
  916. for (let uuIdObj of result) {
  917. let uuIdUrl = "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/pdf";
  918. uuIdUrls.push(uuIdUrl);
  919. }
  920. downloadReport(uuIdUrls);
  921. } else {
  922. //
  923. }
  924. }, null, null
  925. );
  926. }
  927. }
  928. },
  929. firstPage: function(dom) {
  930. let canvas = document.getElementById("rptCanvas");
  931. zTreeOprObj.showPage(1, canvas);
  932. },
  933. prePage: function(dom) {
  934. let canvas = document.getElementById("rptCanvas");
  935. zTreeOprObj.showPage(zTreeOprObj.currentPage - 1, canvas);
  936. },
  937. nextPage: function(dom) {
  938. let canvas = document.getElementById("rptCanvas");
  939. zTreeOprObj.showPage(zTreeOprObj.currentPage + 1, canvas);
  940. },
  941. lastPage: function(dom) {
  942. let me = zTreeOprObj;
  943. let canvas = document.getElementById("rptCanvas");
  944. zTreeOprObj.showPage(me.maxPages, canvas);
  945. },
  946. onKeydown: function (event, dom) {
  947. let me = zTreeOprObj, keyPressed = null;
  948. if (window.event) {
  949. keyPressed = window.event.keyCode; // IE/Chrome
  950. } else {
  951. keyPressed = event.which; // Firefox
  952. }
  953. if (keyPressed === 13) {
  954. let pageNum = 1;
  955. try {
  956. pageNum = parseInt(dom.value);
  957. } catch (e) {
  958. pageNum = 1;
  959. }
  960. let canvas = document.getElementById("rptCanvas");
  961. if (pageNum < 1) {
  962. pageNum = 1;
  963. } else if (pageNum > me.maxPages) {
  964. pageNum = me.maxPages;
  965. }
  966. zTreeOprObj.showPage(pageNum, canvas);
  967. return false;
  968. }
  969. },
  970. changeMargin: function(marginPropStr, marginDom) {
  971. zTreeOprObj.reportPageCfg.margins[marginPropStr] = marginDom.value;
  972. },
  973. changeFontMain: function(CfgDispName, fontProperty, fontDom) {
  974. for (let font of zTreeOprObj.reportPageCfg.fonts) {
  975. if (font["CfgDispName"] === CfgDispName) {
  976. font[fontProperty] = fontDom.value;
  977. break;
  978. }
  979. }
  980. },
  981. changeCfgOption: function (optStr, dom) {
  982. zTreeOprObj.reportPageCfg[optStr] = dom.checked;
  983. },
  984. changeFontAdhoc: function(CfgDispName, fontProperty, fontDom) {
  985. for (let font of zTreeOprObj.reportPageCfg.fonts) {
  986. if (font["CfgDispName"] === CfgDispName) {
  987. if (font[fontProperty] === 'T') {
  988. font[fontProperty] = 'F';
  989. fontDom.className = "btn btn-sm btn-outline-secondary";
  990. } else {
  991. font[fontProperty] = 'T';
  992. fontDom.className = "btn btn-sm btn-outline-secondary active";
  993. }
  994. break;
  995. }
  996. }
  997. },
  998. restoreCustCFG: function () {
  999. let me = this;
  1000. zTreeOprObj.renderRptCfg(zTreeOprObj.defReportPageCfg);
  1001. zTreeOprObj.extractRptCfg(zTreeOprObj.reportPageCfg);
  1002. me.saveCustCfg();
  1003. },
  1004. saveCustCfg: function() {
  1005. let params = {};
  1006. params.custCfg = zTreeOprObj.reportPageCfg;
  1007. CommonAjax.postEx("report_tpl_api/saveCustomerCfg", params, 20000, true, function(result){
  1008. // alert("Save successfully!");
  1009. $("#update_msg_response")[0].style.color = "green";
  1010. $("#update_msg_response")[0].innerHTML = " (保存成功!)";
  1011. setTimeout(function(){
  1012. $("#update_msg_response")[0].innerHTML = "";
  1013. }, 1000);
  1014. }, function (failRst) {
  1015. $("#update_msg_response")[0].style.color = "red";
  1016. $("#update_msg_response")[0].innerHTML = " (保存失败!)";
  1017. setTimeout(function(){
  1018. $("#update_msg_response")[0].innerHTML = "";
  1019. }, 1000);
  1020. }, null
  1021. );
  1022. },
  1023. confirmCfgChange: function() {
  1024. let treeNode = zTreeOprObj.currentNode;
  1025. if (treeNode.nodeType === TPL_TYPE_TEMPLATE && treeNode.refId > 0) {
  1026. let params = {};
  1027. params.pageSize = rptControlObj.getCurrentPageSize();
  1028. params.rpt_tpl_id = treeNode.refId;
  1029. params.prj_id = projectObj.project.projectInfo.ID;
  1030. params.custCfg = zTreeOprObj.reportPageCfg;
  1031. zTreeOprObj.requestReport(params);
  1032. }
  1033. }
  1034. };
  1035. function downloadReport(urls) {
  1036. //考虑到多个报表下载,一些浏览器(如chrome)不允许一下子下载多个文件,得缓缓处理,统一在这处理
  1037. rptControlObj.currentDownloadUrl = null;
  1038. rptControlObj.currentDownloadIdx = 0;
  1039. let private_download = function() {
  1040. if (rptControlObj.currentDownloadIdx >= 0 && rptControlObj.currentDownloadIdx < urls.length) {
  1041. rptControlObj.currentDownloadUrl = urls[rptControlObj.currentDownloadIdx];
  1042. rptControlObj.currentDownloadIdx++;
  1043. window.location = rptControlObj.currentDownloadUrl;
  1044. setTimeout(private_download, 2000);
  1045. }
  1046. }
  1047. private_download();
  1048. }