rpt_main.js 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524
  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. const WAIT_TIME_EXPORT = 300000;
  10. let fontSuffixMapObj = {"表标题": "title", "列标题": "column", "正文内容": "content", "合计": "summary", "表眉/表脚": "header_footer"};
  11. let rptTplObj = {
  12. hasInitialized: false,
  13. pdfFont: {'SmartSimsun': [], 'simhei': [], 'simkai': []},
  14. iniPage: function() {
  15. let me = this;
  16. if (!me.hasInitialized) {
  17. zTreeOprObj.getReportTemplateTree();
  18. zTreeOprObj.selectedPrjIDs = [];
  19. me.hasInitialized = true;
  20. zTreeOprObj.canvas = document.getElementById("rptCanvas");
  21. zTreeOprObj.canvas.onclick = canvasOprObj.canvasOnClick;
  22. zTreeOprObj.canvas.onmousemove = canvasOprObj.canvasOnMouseMove;
  23. dynamicLoadJs('/public/jspdf/Arial Narrow-normal.js');
  24. dynamicLoadJs('/public/jspdf/Arial Narrow-bold.js');
  25. dynamicLoadJs('/public/jspdf/Arial Narrow-italic.js');
  26. dynamicLoadJs('/public/jspdf/Arial Narrow-bolditalic.js');
  27. rptControlObj.loadPDFFonts();
  28. indexDbOprObj.iniDb('tmpForPDF', 2);
  29. // dynamicLoadJs('/public/jspdf/SmartSimsun-normal.js');
  30. // dynamicLoadJs('/public/jspdf/SmartSimsun-normal2.js');
  31. // dynamicLoadJs('/public/jspdf/SmartSimsun-bold.js', me.pdfFontSimsunCallBack);
  32. }
  33. },
  34. pdfFontSimsunCallBack: function() {
  35. rptTplObj.pdfFont['SmartSimsun'].push('normal');
  36. rptTplObj.pdfFont['SmartSimsun'].push('bold');
  37. },
  38. pdfFontSimkaiCallBack: function() {
  39. rptTplObj.pdfFont['simkai'].push('normal');
  40. rptTplObj.pdfFont['simkai'].push('bold');
  41. },
  42. pdfFontSimheiCallBack: function() {
  43. rptTplObj.pdfFont['simhei'].push('normal');
  44. rptTplObj.pdfFont['simhei'].push('bold');
  45. }
  46. }
  47. let zTreeOprObj = {
  48. treeObj: null,
  49. prjFolderTreeObj: null,
  50. currentNode: null,
  51. checkedRptTplNodes: null,
  52. currentRptPageRst: null,
  53. defReportPageCfg: null,
  54. currentPage: 1,
  55. maxPages: 0,
  56. canvas: null,
  57. selectedPrjIDs: [],
  58. countChkedRptTpl: function () {
  59. let me = zTreeOprObj;
  60. if (me.treeObj) {
  61. me.checkedRptTplNodes = [];
  62. let chkNodes = me.treeObj.getCheckedNodes(true), cnt = 0, hasCurrentNode = false;
  63. for (let node of chkNodes) {
  64. if (node.nodeType === TPL_TYPE_TEMPLATE) {
  65. cnt++;
  66. me.checkedRptTplNodes.push(node);
  67. if (me.currentNode === node) hasCurrentNode = true;
  68. }
  69. }
  70. if (!hasCurrentNode && cnt === 0 && me.currentNode !== null) {
  71. //这里根据实际需求再做处理
  72. cnt++;
  73. me.checkedRptTplNodes.push(me.currentNode);
  74. }
  75. $("#print_div").find("span").each(function(cIdx,elementSpan){
  76. elementSpan.innerText = cnt;
  77. });
  78. $("#export_div").find("span").each(function(cIdx,elementSpan){
  79. elementSpan.innerText = cnt;
  80. });
  81. // if (cnt) {
  82. // $('#btnBatchArchiveRpt').removeAttr('disabled');
  83. // } else {
  84. // $('#btnBatchArchiveRpt').attr('disabled', '');
  85. // }
  86. }
  87. },
  88. getReportTemplateTree: function() {
  89. let me = zTreeOprObj;
  90. const _chkIfShouldFilter = function(rptItem, currentRptType = 'normal') {
  91. let rst = (!(rptItem.released) && rptItem.nodeType === 2 || rptItem.hidden); //未发布判断 或 故意隐藏
  92. if (!rst) {
  93. // 根据当前业务类型判断及检测其他非同类报表,如动态决算类型、支付审批类型
  94. switch(currentRptType) {
  95. case 'normal':
  96. if (rptItem.flags && (rptItem.flags.dynamicType || rptItem.flags.payAuditType)) {
  97. if (rptItem.flags.dynamicType && rptItem.flags.dynamicType !== 'N/A') {
  98. rst = true;
  99. break;
  100. }
  101. if (rptItem.flags.payAuditType && rptItem.flags.payAuditType !== 'N/A') {
  102. rst = true;
  103. break;
  104. }
  105. }
  106. break;
  107. case 'juesuan':
  108. break;
  109. case 'zhifushenpi':
  110. break;
  111. default:
  112. break;
  113. }
  114. }
  115. return rst;
  116. };
  117. const private_remove_hide_item = function (items, nlv) {
  118. if (items && items.length > 0) {
  119. for (let i = items.length - 1; i >= 0; i--) {
  120. if (_chkIfShouldFilter(items[i])) {
  121. items.splice(i, 1);
  122. } else {
  123. if (items[i].items && items[i].items.length > 0) {
  124. private_remove_hide_item(items[i].items, nlv + 1);
  125. if (items[i].items.length === 0 && nlv > 0) {
  126. items.splice(i, 1);
  127. }
  128. }
  129. }
  130. }
  131. }
  132. };
  133. const _changeSourceType = function(items, newType = 1) {4
  134. if (items && items.length > 0) {
  135. for (let i = items.length - 1; i >= 0; i--) {
  136. items[i].source_type = newType;
  137. if (items[i].items && items[i].items.length > 0) {
  138. _changeSourceType(items[i].items);
  139. }
  140. }
  141. }
  142. };
  143. let nodeLv = 0;
  144. private_remove_hide_item(TOP_TREE_NODES, nodeLv);
  145. if (STAGE_ID === -300) {
  146. // -300是变更令报表用,在此情况下,经过测试,是走的tender路线,所以把source_type调整为‘标段&期’的模式(未来如有变化,可能需要调整回来)
  147. // _changeSourceType(TOP_TREE_NODES);
  148. // SOURCE_TYPE = 1;
  149. }
  150. zTreeHelper.createTreeDirectly(TOP_TREE_NODES, rpt_tpl_setting, "rptTplTree", me);
  151. me.treeObj.expandAll(true);
  152. // let topNodes = me.treeObj.getNodes();
  153. // for (let topLvItem of topNodes) {
  154. // me.treeObj.expandNode(topLvItem, true, false, false);
  155. // if (topLvItem.items && topLvItem.items.length > 0) {
  156. // for (let secTopLvItem of topLvItem.items) {
  157. // me.treeObj.expandNode(secTopLvItem, true, false, false);
  158. // }
  159. // }
  160. // }
  161. me.refreshNodes();
  162. },
  163. getCustomerCfg: function() {
  164. let me = zTreeOprObj;
  165. me.defReportPageCfg = {};
  166. Object.assign(me.defReportPageCfg, CUST_CFG);
  167. me.defReportPageCfg.margins = {};
  168. Object.assign(me.defReportPageCfg.margins, CUST_CFG.margins);
  169. me.defReportPageCfg.fonts = [];
  170. for (let fi = 0; fi < CUST_CFG.fonts.length; fi++) {
  171. me.defReportPageCfg.fonts.push({});
  172. Object.assign(me.defReportPageCfg.fonts[fi], CUST_CFG.fonts[fi]);
  173. }
  174. },
  175. iniFontCfgDom: function (cfg) {
  176. for (let font of cfg.fonts) {
  177. let domArrs = [];
  178. let fontPropSuffix = fontSuffixMapObj[font.CfgDispName];
  179. domArrs.push("<div class='row mb-1'>");
  180. //1. label
  181. domArrs.push("<div class='col-3'>" + font.CfgDispName + "</div>");
  182. //2. font name
  183. domArrs.push("<div class='col-3'>");
  184. domArrs.push("<select class='form-control input-sm' id='fontName_" + fontPropSuffix + "' onchange='rptControlObj.changeFontMain(\"" + font.CfgDispName + "\", \"Name\", this)'>");
  185. domArrs.push("<option>宋体</option>");
  186. // <option>楷体</option><option>黑体</option> // 因导出PDF调整到前端输出,字体文件大,支持的字体要谨慎些,不轻易多加字体
  187. domArrs.push("</select>");
  188. domArrs.push("</div>");
  189. //3. font height
  190. domArrs.push("<div class='col-3'>");
  191. domArrs.push("<input class='form-control input-sm' id='fontHeight_" + fontPropSuffix + "' type='number' value='30' step='1' min='6' max='66' " +
  192. "onchange='rptControlObj.changeFontMain(\"" + font.CfgDispName + "\", \"FontHeight\", this)' " +
  193. "onkeyup='rptControlObj.changeFontMain(\"" + font.CfgDispName + "\", \"FontHeight\", this)'>");
  194. domArrs.push("</div>");
  195. //4. font bold italic underline
  196. domArrs.push("<div class='col-3'>");
  197. 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>");
  198. 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>");
  199. 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>");
  200. domArrs.push("</div>");
  201. //
  202. domArrs.push("</div>");
  203. $(domArrs.join("")).insertBefore($("#font_cfg_blank_flag"));
  204. }
  205. },
  206. renderRptCfg: function (cfg) {
  207. this.renderMargin(cfg);
  208. this.renderFormat(cfg);
  209. },
  210. renderMargin: function (cfg) {
  211. $("#elementMargin_Left")[0].value = cfg.margins.Left;
  212. $("#elementMargin_Right")[0].value = cfg.margins.Right;
  213. $("#elementMargin_Top")[0].value = cfg.margins.Top;
  214. $("#elementMargin_Bottom")[0].value = cfg.margins.Bottom;
  215. },
  216. renderFormat: function (cfg) {
  217. for (let font of cfg.fonts) {
  218. let fontPropSuffix = fontSuffixMapObj[font.CfgDispName];
  219. document.getElementById("fontName_" + fontPropSuffix).value = font.Name;
  220. document.getElementById("fontHeight_" + fontPropSuffix).value = font.FontHeight;
  221. document.getElementById("font_bold_" + fontPropSuffix).className = (font.FontBold === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  222. document.getElementById("font_italic_" + fontPropSuffix).className = (font.FontItalic === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  223. document.getElementById("font_underline_" + fontPropSuffix).className = (font.FontUnderline === "T")?"btn btn-sm btn-outline-secondary active":"btn btn-sm btn-outline-secondary";
  224. }
  225. document.getElementById("cfg_border_thick").value = cfg.borderThick;
  226. document.getElementById("cfg_rpt_vertical_line").checked = cfg.showVerticalLine;
  227. document.getElementById("cfg_rpt_fill_zero").checked = cfg.fillZero;
  228. document.getElementById("cfg_rpt_narrow").checked = cfg.isNarrow;
  229. document.getElementById("cfg_rpt_close_warter_mark").checked = cfg.closeWarterMark;
  230. if (PAGE_SHOW['closeWatermark'] === 0) {
  231. $("#cfg_rpt_close_warter_mark_div")[0].style.display = '';
  232. } else {
  233. $("#cfg_rpt_close_warter_mark_div")[0].style.display = 'none';
  234. }
  235. document.getElementById("cfg_rpt_continuous").checked = cfg.continuousOutput;
  236. },
  237. extractRptCfg: function (cfg) {
  238. cfg.margins.Left = $("#elementMargin_Left")[0].value;
  239. cfg.margins.Right = $("#elementMargin_Right")[0].value;
  240. cfg.margins.Top = $("#elementMargin_Top")[0].value;
  241. cfg.margins.Bottom = $("#elementMargin_Bottom")[0].value;
  242. for (let font of cfg.fonts) {
  243. let fontPropSuffix = fontSuffixMapObj[font.CfgDispName];
  244. font.Name = document.getElementById("fontName_" + fontPropSuffix).value;
  245. font.FontHeight = document.getElementById("fontHeight_" + fontPropSuffix).value;
  246. font.FontBold = (document.getElementById("font_bold_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  247. font.FontItalic = (document.getElementById("font_italic_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  248. font.FontUnderline = (document.getElementById("font_underline_" + fontPropSuffix).className === "btn btn-sm btn-outline-secondary active")?"T":"F";
  249. }
  250. cfg.showVerticalLine = document.getElementById("cfg_rpt_vertical_line").checked;
  251. cfg.isNarrow = document.getElementById("cfg_rpt_narrow").checked;
  252. cfg.fillZero = document.getElementById("cfg_rpt_fill_zero").checked;
  253. cfg.borderThick = document.getElementById("cfg_border_thick").value;
  254. },
  255. refreshNodes: function() {
  256. let me = this;
  257. const _set_archive_icon = function (tplNode) {
  258. let hasArchive = false;
  259. if (PAGE_SHOW['showArchive']) {
  260. for (let aItem of ARCHIVE_LIST) {
  261. if (parseInt(aItem.rpt_id) === parseInt(tplNode.refId)) {
  262. hasArchive = true;
  263. tplNode.icon = "/public/css/ztree/img/diy/10.png";
  264. break;
  265. }
  266. }
  267. }
  268. if (!hasArchive) {
  269. if (!tplNode.isParent) {
  270. tplNode.icon = null;
  271. tplNode.className = "button ico_docu";
  272. }
  273. }
  274. };
  275. let private_setupIsParent = function(node){
  276. node.isParent = (node.nodeType === RT.NodeType.NODE || node.level === 0);
  277. _set_archive_icon(node);
  278. if (node.items && node.items.length) {
  279. for (let i = 0; i < node.items.length; i++) {
  280. private_setupIsParent(node.items[i]);
  281. }
  282. }
  283. };
  284. let topNodes = me.treeObj.getNodes();
  285. for (let i = 0; i < topNodes.length; i++) {
  286. private_setupIsParent(topNodes[i]);
  287. }
  288. me.treeObj.refresh();
  289. },
  290. onCheck: function(event, treeId, treeNode) {
  291. zTreeOprObj.countChkedRptTpl();
  292. rptCustomObj.showMaterialSelect();
  293. if (treeNode.isParent) {
  294. zTreeOprObj.treeObj.expandNode(treeNode, true, true, false);
  295. }
  296. },
  297. onClick: async function(event,treeId,treeNode) {
  298. let me = zTreeOprObj;
  299. if (treeNode && treeNode.nodeType === TPL_TYPE_TEMPLATE && treeNode.refId > 0) {
  300. window.history.pushState({},0, window.location.pathname + `?rpt_id=${treeNode.refId}`);
  301. me.currentNode = treeNode;
  302. let params = {};
  303. rptControlObj.getRptRequestCommonParam(params);
  304. params.rpt_tpl_id = treeNode.refId;
  305. _getSplitAmendmentParam(params, treeNode);
  306. rptArchiveObj.toggleBtn(false);
  307. if (customSelects) {
  308. const gather_select = customSelects.gather_select.find(function (x) {
  309. return x.id === treeNode.refId;
  310. });
  311. if (gather_select) {
  312. rptCustomObj.init(gather_select.custom_define, customSelects.stageFlow, gather_select);
  313. return;
  314. }
  315. const stage_select = customSelects.stage_select.find(function (x) {
  316. return x.id === treeNode.refId;
  317. });
  318. if (stage_select) {
  319. rptCustomObj.init(stage_select.custom_define, customSelects.stageFlow, stage_select);
  320. return;
  321. }
  322. const material_sum_select = customSelects.material_sum_select.find(function (x) {
  323. return x.id === treeNode.refId;
  324. });
  325. if (material_sum_select) {
  326. rptCustomObj.init(material_sum_select.custom_define, customSelects.stageFlow, material_sum_select);
  327. return;
  328. }
  329. const change_select = customSelects.change_select.find(function (x) {
  330. return x.id === treeNode.refId;
  331. });
  332. if (change_select) {
  333. rptCustomObj.init(change_select.custom_define, customSelects.stageFlow, change_select);
  334. return;
  335. }
  336. }
  337. rptArchiveObj.toggleBtn(true);
  338. delete params.orientation;
  339. await me.requestNormalReport(params);
  340. me.countChkedRptTpl();
  341. rptCustomObj.showMaterialSelect();
  342. }
  343. },
  344. changePageSize: function(dom) {
  345. let me = zTreeOprObj,
  346. targetDom = document.getElementById("btnRptPageSize");
  347. let tmpStr = targetDom.innerHTML.trim();
  348. targetDom.innerHTML = dom.innerHTML.trim();
  349. dom.innerHTML = tmpStr;
  350. me.changeCfg();
  351. },
  352. changeOrientation: function(dom) {
  353. let me = zTreeOprObj,
  354. targetDom = document.getElementById("btnRptOrientation");
  355. let tmpStr = targetDom.innerHTML.trim();
  356. targetDom.innerHTML = dom.innerHTML.trim();
  357. dom.innerHTML = tmpStr;
  358. me.changeCfg();
  359. },
  360. changeCfg: async function(preCb = null) {
  361. let me = zTreeOprObj;
  362. if (preCb) {
  363. preCb();
  364. }
  365. if (me.currentNode) {
  366. CUST_CFG_ORG = JSON.parse(JSON.stringify(CUST_CFG));
  367. let params = {};
  368. rptControlObj.getRptRequestCommonParam(params);
  369. params.rpt_tpl_id = me.currentNode.refId;
  370. _getSplitAmendmentParam(params, me.currentNode);
  371. localStorage[CUST_NAME + '_custCfg'] = JSON.stringify(CUST_CFG);
  372. if (customSelects) {
  373. const gather_select = customSelects.gather_select.find(function (x) {
  374. return x.id === me.currentNode.refId;
  375. });
  376. if (gather_select) {
  377. rptCustomObj.init(gather_select.custom_define, customSelects.stageFlow, gather_select);
  378. return;
  379. }
  380. const stage_select = customSelects.stage_select.find(function (x) {
  381. return x.id === me.currentNode.refId;
  382. });
  383. if (stage_select) {
  384. rptCustomObj.init(stage_select.custom_define, customSelects.stageFlow, stage_select);
  385. return;
  386. }
  387. const material_sum_select = customSelects.material_sum_select.find(function (x) {
  388. return x.id === me.currentNode.refId;
  389. });
  390. if (material_sum_select) {
  391. rptCustomObj.init(material_sum_select.custom_define, customSelects.stageFlow, material_sum_select);
  392. return;
  393. }
  394. const change_select = customSelects.change_select.find(function (x) {
  395. return x.id === me.currentNode.refId;
  396. });
  397. if (change_select) {
  398. rptCustomObj.init(change_select.custom_define, customSelects.stageFlow, change_select);
  399. return;
  400. }
  401. }
  402. await me.requestNormalReport(params);
  403. me.countChkedRptTpl();
  404. rptCustomObj.showMaterialSelect();
  405. }
  406. },
  407. resetAfter: function (pageRst) {
  408. let size = pageRst[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE].slice(0);
  409. if (size[0] > size[1]) {
  410. document.getElementById("btnRptOrientation").innerHTML = "横向";
  411. document.getElementById("hrefRptOrientation").innerHTML = "纵向";
  412. } else {
  413. document.getElementById("btnRptOrientation").innerHTML = "纵向";
  414. document.getElementById("hrefRptOrientation").innerHTML = "横向";
  415. }
  416. },
  417. _parseRoleRelList: function(org_rel_content) {
  418. const rst = JSON.parse(org_rel_content);
  419. for (const role_rel of rst) {
  420. if (role_rel.sign_date !== null && role_rel.sign_date !== undefined && role_rel.sign_date.length >= 8) {
  421. role_rel.sign_date = new Date(role_rel.sign_date);
  422. }
  423. }
  424. return rst;
  425. },
  426. _setupArchive: function() {
  427. //
  428. },
  429. _chkPrePayStatus: function() {
  430. let rst = -1;
  431. let me = zTreeOprObj;
  432. if (me.currentNode && me.currentNode.hasOwnProperty('flags') && me.currentNode.flags.hasOwnProperty('rptTplType')) {
  433. let prePayArr = PRE_PAY;
  434. // 返回一个数组,得自己判断,有2种type,0:开工预付款,1:材料预付款; status与stage的status对应(3表示审核通过);order表示顺序(以同类型的最大选择顺序为判断基准),selected表示是否选择(0,1)
  435. let ppType = -1;
  436. if (me.currentNode['flags']['rptTplType'] === 'tplType_prePay1') {
  437. // 开工预付款
  438. ppType = 0;
  439. } else if (me.currentNode['flags']['rptTplType'] === 'tplType_prePay2') {
  440. // 材料预付款
  441. ppType = 1;
  442. }
  443. for (let ppItem of prePayArr) {
  444. if (ppItem.type === ppType) {
  445. if (current_stage_id > 0 && ppItem.selected || current_stage_id === -1) {
  446. rst = ppItem.status;
  447. }
  448. }
  449. // if (ppItem.type === ppType && ppItem.selected) {
  450. // rst = ppItem.status;
  451. // break;
  452. // }
  453. }
  454. }
  455. return rst;
  456. },
  457. requestNormalReport: async function (params) {
  458. let me = zTreeOprObj;
  459. if (COMMON_WATER_MARK_PIC_DATA === null || COMMON_WATER_MARK_PIC_DATA === '') {
  460. params.needWaterMark = true;
  461. } else {
  462. params.needWaterMark = false;
  463. }
  464. $.bootstrapLoading.start();
  465. CommonAjax.postXsrfEx("/tender/report_api/getReport", params, 300000, true, getCookie('csrfToken_j'),
  466. async function(result){
  467. $.bootstrapLoading.end();
  468. let pageRst = result.data;
  469. if (params.needWaterMark) COMMON_WATER_MARK_PIC_DATA = result.waterMarkStr;
  470. STAGE_AUDIT = result.stageAudit || [];
  471. STAGE_AUDIT_ORG = result.stageAuditOrg || [];
  472. STAGE_FLOW = result.stageFlow;
  473. //stageAuditOrg
  474. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  475. CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  476. ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  477. rptSignatureHelper.originalRoleRelList = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  478. rptSignatureHelper.mergeSignDate(pageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
  479. rptSignatureHelper.mergeSignature(pageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
  480. await rptSignatureHelper.resetDummySignature(pageRst, ROLE_REL_LIST, getStageStatus() !== 3); // 这里重新整理签章坐标信息(因签章大小在后台暂时获取不到,挪到前端处理)
  481. rptSignatureHelper.mergeSignAudit(pageRst, ROLE_REL_LIST, STAGE_AUDIT, getStageStatus() !== 3);
  482. if (PAGE_SHOW.isTextSignature) {
  483. resetTextSignature(pageRst, getStageStatus() !== 3);
  484. }
  485. } else {
  486. CURRENT_ROLE_REL_ID = -1;
  487. ROLE_REL_LIST = [];
  488. }
  489. // if (ROLE_REL_LIST)
  490. let canvas = zTreeOprObj.canvas;
  491. if (pageRst && pageRst.items && pageRst.items.length > 0) {
  492. me.resetAfter(pageRst);
  493. me.currentRptPageRst = pageRst;
  494. me.maxPages = pageRst.items.length;
  495. me.currentPage = 1;
  496. me.displayPageValue();
  497. let size = JpcCanvasOutput.getReportSizeInPixel(me.currentRptPageRst, getScreenDPI());
  498. canvas.width = size[0] * JpcCanvasOutput.scaleFactor + 20;
  499. if (size[1] > size[0]) {
  500. canvas.height = size[1] * JpcCanvasOutput.scaleFactor + 100;
  501. } else {
  502. canvas.height = size[1] * JpcCanvasOutput.scaleFactor + 50;
  503. }
  504. // zTreeOprObj.resetESignature(zTreeOprObj.currentRptPageRst);
  505. rptSignatureHelper.buildSelectableAccount();
  506. rptSignatureHelper.buildSelectableAccountUsed();
  507. rptSignatureHelper.buildRoleDom(ROLE_LIST);
  508. // if (PAGE_SHOW.isTextSignature) {
  509. // resetTextSignature(zTreeOprObj.currentRptPageRst, current_stage_status !== 3);
  510. // }
  511. me.showPage(1, canvas);
  512. if (PAGE_SHOW.showArchive) {
  513. rptArchiveObj.showArchivedItem(me.currentNode);
  514. }
  515. } else {
  516. //返回了无数据表
  517. JpcCanvasOutput.cleanCanvas(canvas);
  518. JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
  519. }
  520. rptCustomObj.init(result.customDefine, result.stageFlow, result.customSelect);
  521. try {
  522. if (is_debug && result.debugInfo) {
  523. console.log('含有key的debug信息:');
  524. for (const k in result.debugInfo.key) {
  525. console.log(k + ':', ...result.debugInfo.key[k]);
  526. }
  527. //console.log(result.debugInfo.key);
  528. console.log('其他debug信息:');
  529. for (const di of result.debugInfo.other) {
  530. console.log(...di);
  531. }
  532. }
  533. } catch(err) {
  534. }
  535. }, function(err){
  536. if (me.currentRptPageRst === null) rptArchiveObj.toggleBtn(false);
  537. $.bootstrapLoading.end();
  538. }, function(ex){
  539. if (me.currentRptPageRst === null) rptArchiveObj.toggleBtn(false);
  540. $.bootstrapLoading.end();
  541. }
  542. );
  543. },
  544. scaleReport: function (accScale) {
  545. let me = zTreeOprObj;
  546. let canvas = zTreeOprObj.canvas;
  547. if (accScale !== 0) {
  548. JpcCanvasOutput.scaleFactor += accScale;
  549. if (JpcCanvasOutput.scaleFactor < 0.5) JpcCanvasOutput.scaleFactor = 0.5;
  550. if (JpcCanvasOutput.scaleFactor > 1.5) JpcCanvasOutput.scaleFactor = 1.5;
  551. } else {
  552. JpcCanvasOutput.scaleFactor = 1;
  553. }
  554. document.getElementById("btnNormalScale").innerText = (JpcCanvasOutput.scaleFactor * 100) + '%';
  555. me.showPage(me.currentPage, canvas);
  556. },
  557. requestPrjFolderCommon: function () {
  558. //
  559. },
  560. changePreviewScale: function(newScale = 1) {
  561. const me = zTreeOprObj;
  562. JpcCanvasOutput.scaleFactor = newScale;
  563. const canvas = me.canvas;
  564. const size = JpcCanvasOutput.getReportSizeInPixel(me.currentRptPageRst, getScreenDPI());
  565. canvas.width = size[0] * newScale + 20;
  566. if (size[1] > size[0]) {
  567. canvas.height = size[1] * newScale + 100;
  568. } else {
  569. canvas.height = size[1] * newScale + 50;
  570. }
  571. me.showPage(me.currentPage, canvas);
  572. },
  573. showPage: function (pageNum, canvas) {
  574. let me = zTreeOprObj;
  575. if (pageNum >= 1 && pageNum <= me.maxPages) {
  576. me.currentPage = pageNum;
  577. JpcCanvasOutput.cleanCanvas(canvas);
  578. JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
  579. // JpcCanvasOutput.highlightConflictArea(me.currentRptPageRst, pageNum);
  580. JpcCanvasOutput.drawToCanvas(me.currentRptPageRst, canvas, me.currentPage);
  581. //测试:
  582. // JpcFigureOutput.offsetX = JpcCanvasOutput.offsetX;
  583. // JpcFigureOutput.offsetY = JpcCanvasOutput.offsetY;
  584. // JpcFigureOutput.drawToCanvas(canvas, page);
  585. // let invisibleCanvas = document.getElementById("invisibleCanvas");
  586. // JpcFigureOutput.toImageData(canvas, me.currentRptPageRst);
  587. }
  588. me.displayPageValue();
  589. },
  590. displayPageValue: function() {
  591. let me = zTreeOprObj;
  592. $("#rpt_page_num")[0].value = me.currentPage + "/" + me.maxPages;
  593. $("#rpt_fullscreen_page_num")[0].value = me.currentPage + "/" + me.maxPages;
  594. }
  595. };
  596. let canvasOprObj = {
  597. canvasOnMouseMove: function (event) {
  598. if (zTreeOprObj.currentNode) {
  599. let x = event.offsetX - JpcCanvasOutput.offsetX, canvas = event.originalTarget;
  600. if (!(canvas)) canvas = event.target; //chrome浏览器不认event.originalTarget,只认event.target或event.currentTarget
  601. if (x < PRE_PAGE_OFFSET) {
  602. canvas.style.cursor = "url(/public/images/PreviousPage.cur), auto";
  603. } else if ((canvas.width - x) < NEXT_PAGE_OFFSET) {
  604. canvas.style.cursor = "url(/public/images/NextPage.cur), auto";
  605. } else {
  606. canvas.style.cursor = "";
  607. }
  608. }
  609. },
  610. canvasOnClick: function(event){
  611. if (zTreeOprObj.currentNode) {
  612. let x = event.offsetX - JpcCanvasOutput.offsetX, canvas = event.originalTarget;
  613. if (!(canvas)) canvas = event.target; //chrome浏览器不认event.originalTarget,只认event.target或event.currentTarget
  614. if (x < PRE_PAGE_OFFSET) {
  615. zTreeOprObj.showPage(zTreeOprObj.currentPage - 1, canvas);
  616. } else if ((canvas.width - x) < NEXT_PAGE_OFFSET) {
  617. zTreeOprObj.showPage(zTreeOprObj.currentPage + 1, canvas);
  618. }
  619. }
  620. },
  621. showFullSreen: function () {
  622. if (zTreeOprObj.currentRptPageRst) {
  623. let orgH = zTreeOprObj.canvas.height;
  624. let orgW = zTreeOprObj.canvas.width;
  625. zTreeOprObj.canvas = document.getElementById("fullScrCanvas");
  626. // zTreeOprObj.canvas.height = orgH;
  627. // zTreeOprObj.canvas.width = orgW;
  628. // zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  629. // zTreeOprObj.changePreviewScale(1);
  630. this.fullScreenChangeScale(0);
  631. $("#btn_show_full_screen").trigger("click");
  632. $('#fullscreen').on('hide.bs.modal', function () {
  633. zTreeOprObj.canvas = document.getElementById("rptCanvas");
  634. // zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  635. zTreeOprObj.changePreviewScale(1);
  636. });
  637. }
  638. },
  639. fullScreenChangeScale: function(newScaleFactor, dom) {
  640. let rstScale = JpcCanvasOutput.scaleFactor + newScaleFactor;
  641. let scaleBtn = document.getElementById("fullScreenScaleBtn");;
  642. if (newScaleFactor === 0) {
  643. rstScale = 1;
  644. } else if (rstScale < 1) {
  645. rstScale = 1;
  646. } else if (rstScale > 2){
  647. rstScale = 2;
  648. }
  649. scaleBtn.innerHTML = `${(rstScale * 100).toFixed(0)}%`;
  650. zTreeOprObj.changePreviewScale(rstScale);
  651. }
  652. };
  653. let rptControlObj = {
  654. currentOutputType: "Excel",
  655. currentDownloadUrl: null,
  656. currentDownloadIdx: 0,
  657. isLoading: false,
  658. getCurrentPageSize: function() {
  659. // let rst = "A4";
  660. let rst = document.getElementById("btnRptPageSize").innerHTML.trim();
  661. //btnRptPageSize
  662. return rst;
  663. },
  664. getCurrentOrientation: function() {
  665. // let rst = "横向";
  666. let rst = document.getElementById("btnRptOrientation").innerHTML.trim();
  667. return rst;
  668. },
  669. changeType: function(newType) {
  670. let me = rptControlObj;
  671. let excelDom = document.getElementById("EXCEL_TYPE");
  672. let pdfDom = document.getElementById("PDF_TYPE");
  673. if (newType === "Excel") {
  674. excelDom.className = "btn btn-block btn-primary";
  675. pdfDom.className = "btn btn-block btn-outline-secondary";
  676. me.currentOutputType = newType;
  677. } else if (newType === "PDF") {
  678. excelDom.className = "btn btn-block btn-outline-secondary";
  679. pdfDom.className = "btn btn-block btn-primary";
  680. me.currentOutputType = newType;
  681. } else {
  682. //me.currentOutputType = newType;
  683. }
  684. },
  685. getTplIdsCommon: function (refRptTplIds, rpt_names, splitArchives = []) {
  686. for (let node of zTreeOprObj.checkedRptTplNodes) {
  687. refRptTplIds.push(node.refId);
  688. if (rpt_names) rpt_names.push(node.name);
  689. if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
  690. // 未来可能会有额外处理,目前空着
  691. }
  692. if (node.flags && node.flags.amendmentType === 'splitArchive') {
  693. // splitArchives.push(node.refId);
  694. splitArchives.push({rpt_id: node.refId, split_field_id: parseInt(node.flags.splitArchiveField)});
  695. } else {
  696. splitArchives.push(null);
  697. }
  698. }
  699. },
  700. getRptRequestCommonParam: function(params) {
  701. if (params) {
  702. params.pageSize = rptControlObj.getCurrentPageSize();
  703. params.orientation = rptControlObj.getCurrentOrientation();
  704. params.custCfg = CUST_CFG;
  705. params.project_id = PROJECT_ID;
  706. params.tender_id = TENDER_ID;
  707. params.budget_id = BUDGET_ID;
  708. params.sp_id = SP_ID;
  709. params.source_type = SOURCE_TYPE;
  710. params.stage_id = getStageId();
  711. params.stage_status = getStageStatus();
  712. params.stage_order = getStageOrder();
  713. params.stage_times = getStageTimes();
  714. params.material_order = getMaterialOrder();
  715. params.closeWatermark = getCloseWatermark();
  716. params.isTextSignature = getTxtSignature();
  717. params.detail_id = DETAIL_ID;
  718. params.change_id = CHANGE_ID;
  719. params.business_id = BUSINESS_ID;
  720. params.change_plan_id = CHNAGE_PLAN_ID;
  721. params.change_project_id = CHNAGE_PROJECT_ID;
  722. params.change_apply_id = CHNAGE_APPLY_ID;
  723. params.change_times = CHANGE_TIMES;
  724. params.change_plan_times = CHNAGE_PLAN_TIMES;
  725. params.change_project_times = CHNAGE_PROJECT_TIMES;
  726. params.change_apply_times = CHNAGE_APPLY_TIMES;
  727. params.advance_id = current_advance_id;
  728. params.material_id = current_material_id;
  729. }
  730. },
  731. creatCommonExportParam: function (refRptTplIds) {
  732. let rst = {};
  733. rptControlObj.getRptRequestCommonParam(rst);
  734. rst.rpt_ids = refRptTplIds;
  735. rst.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:rptControlObj.getCurrentOrientation());
  736. rst.closeArchiveSignature = getCloseArchiveSignature();
  737. return rst;
  738. },
  739. getAllInOneBook: async function () {
  740. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  741. let me = rptControlObj;
  742. let refRptTplIds = [], rpt_sheet_names = [], splitArchives = [];
  743. rptControlObj.getTplIdsCommon(refRptTplIds, rpt_sheet_names, splitArchives);
  744. let params = rptControlObj.creatCommonExportParam(refRptTplIds);
  745. params.closeWatermark = getCloseWatermarkForExcel();
  746. if (current_stage_id > 0) {
  747. await rptCustomObj.getCustomSelect(params);
  748. }
  749. params.rpt_names = rpt_sheet_names;
  750. params.rptName = TENDER_NAME;
  751. params.option = getExcelOutputOption();
  752. params.splitArchives = splitArchives;
  753. let chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
  754. if (chkNodes.length > 0) {
  755. delete params.orientation; // 打印时有勾选的话,不需要提供方向
  756. }
  757. $.bootstrapLoading.start();
  758. CommonAjax.postXsrfEx("/tender/report_api/createExcelFilesInOneBook", params, WAIT_TIME_EXPORT, true, getCookie('csrfToken_j'), function(result){
  759. $.bootstrapLoading.end();
  760. if (result) {
  761. let uuIdUrls = [];
  762. let uuIdUrl = "/getFileByUUID/" + result.data[0].uuid + "/" + stringUtil.replaceAll(result.data[0].reportName, "#", "_") + "/xlsx";
  763. uuIdUrls.push(uuIdUrl);
  764. downloadReport(uuIdUrls);
  765. } else {
  766. //
  767. }
  768. },
  769. function(failRst){
  770. // closeWaitingView();
  771. $.bootstrapLoading.end();
  772. console.log(failRst);
  773. },
  774. function(exceptionRst){
  775. // closeWaitingView();
  776. $.bootstrapLoading.end();
  777. console.log(exceptionRst);
  778. }
  779. );
  780. }
  781. },
  782. getAllIndividualExcelBook: async function () {
  783. let me = rptControlObj;
  784. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
  785. let refRptTplIds = [];
  786. let rpt_names = [], splitArchives = [];
  787. rptControlObj.getTplIdsCommon(refRptTplIds, rpt_names, splitArchives);
  788. let params = rptControlObj.creatCommonExportParam(refRptTplIds);
  789. params.closeWatermark = getCloseWatermarkForExcel();
  790. if (current_stage_id > 0) {
  791. await rptCustomObj.getCustomSelect(params);
  792. }
  793. params.isOneSheet = true;
  794. params.rpt_names = rpt_names;
  795. params.rptName = 'All';
  796. params.splitArchives = splitArchives;
  797. // 测试连续输出
  798. params.option = getExcelOutputOption();
  799. let chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
  800. if (chkNodes.length > 0) {
  801. delete params.orientation; // 打印时有勾选的话,不需要提供方向
  802. }
  803. $.bootstrapLoading.start();
  804. CommonAjax.postXsrfEx("/tender/report_api/createExcelFiles", params, WAIT_TIME_EXPORT, true, getCookie('csrfToken_j'), function(result){
  805. $.bootstrapLoading.end();
  806. if (result) {
  807. let uuIdUrls = [];
  808. for (let uuIdObj of result.data) {
  809. let uuIdUrl = "/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/xlsx";
  810. uuIdUrls.push(uuIdUrl);
  811. }
  812. downloadReport(uuIdUrls);
  813. } else {
  814. //
  815. }
  816. },
  817. function(failRst){
  818. // closeWaitingView();
  819. $.bootstrapLoading.end();
  820. console.log(failRst);
  821. },
  822. function(exceptionRst){
  823. // closeWaitingView();
  824. $.bootstrapLoading.end();
  825. console.log(exceptionRst);
  826. }
  827. );
  828. }
  829. },
  830. downloadExcelReport: async function(pageDataArr, pageSize, rpt_names, signatureRelArr) {
  831. const MAX_BRK_PAGE = 300;
  832. const __sleep = (n) => {
  833. var start = new Date().getTime();
  834. while(true) if(new Date().getTime()-start > n) break;
  835. }
  836. const private_download = async function(currentIndex) {
  837. if (currentIndex < pageDataArr.length) {
  838. //这里的数据应该在调用前己处理
  839. const rptName = rpt_names[currentIndex];
  840. const singlePage = true;
  841. let role_rel_list = signatureRelArr[currentIndex];
  842. // await excelExportUtil.exportExcel(pageDataArr[currentIndex], pageSize, rptName, singlePage, null, null, ROLE_REL_LIST, null);
  843. const dtlSignCells = [];
  844. filterSignCells(pageDataArr[currentIndex], dtlSignCells, null, null, PAGE_SHOW.isTextSignature, false);
  845. await excelExportUtil.exportExcel(pageDataArr[currentIndex], pageSize, rptName, singlePage, null, null, role_rel_list, null, getStageStatus() !== 3);
  846. restoreSignCells(pageDataArr[currentIndex], dtlSignCells, null, null, PAGE_SHOW.isTextSignature, false);
  847. }
  848. };
  849. const _splitDownload = async (currentIndex) => {
  850. if (currentIndex < pageDataArr.length) {
  851. const rptName = rpt_names[currentIndex];
  852. const ttlPages = pageDataArr[currentIndex].items.length;
  853. const splitAmt = Math.ceil(ttlPages / MAX_BRK_PAGE);
  854. const singlePage = true;
  855. let role_rel_list = signatureRelArr[currentIndex];
  856. const bkItems = [].concat(pageDataArr[currentIndex].items);
  857. for (let sIdx = 0; sIdx < splitAmt; sIdx++) {
  858. let dlItems = bkItems.slice(sIdx * MAX_BRK_PAGE, (sIdx + 1) * MAX_BRK_PAGE);
  859. pageDataArr[currentIndex].items = dlItems;
  860. await excelExportUtil.exportExcel(pageDataArr[currentIndex], pageSize, `${rptName}${sIdx}`, singlePage, null, null, role_rel_list, null, getStageStatus() !== 3);
  861. if (sIdx < splitAmt - 1) __sleep(10000);
  862. }
  863. }
  864. };
  865. for (let idx = 0; idx < pageDataArr.length; idx++) {
  866. if (pageDataArr[idx].items.length > MAX_BRK_PAGE) {
  867. await private_download(idx); // 应该用_splitDownload方法,只是目前的判断条件还不够理想,需要在qa上再仔细调整,在外网需要临时debug来分批导出
  868. } else {
  869. await private_download(idx);
  870. }
  871. }
  872. },
  873. downloadExcelReportInOneBook: async function(pageDataArr, pageSize, signatureRelArr, rpt_names) {
  874. let rptRoleRelArr = [];
  875. let ttlRoleAmt = 0;
  876. const reAssignSignatureName = function(pageData, roleRel, rpt_name_key) {
  877. const keyMap = {};
  878. for (const pageItem of pageData.items) {
  879. for (const signCell of pageItem[JV.PROP_SIGNATURE_CELLS]) {
  880. if (!keyMap.hasOwnProperty(signCell.signature_name)) {
  881. keyMap[signCell.signature_name] = rpt_name_key + '_' + signCell.signature_name;
  882. }
  883. }
  884. //水印也要reAssign
  885. for (const watermarkCell of pageItem[JV.PROP_WATERMARK_CELLS]) {
  886. if (!keyMap.hasOwnProperty(watermarkCell.signature_name)) {
  887. keyMap[watermarkCell.signature_name] = rpt_name_key + '_' + watermarkCell.signature_name;
  888. }
  889. }
  890. }
  891. for (const pageItem of pageData.items) {
  892. for (const signCell of pageItem[JV.PROP_SIGNATURE_CELLS]) {
  893. if (keyMap.hasOwnProperty(signCell.signature_name)) {
  894. signCell.signature_name = keyMap[signCell.signature_name];
  895. }
  896. }
  897. for (const watermarkCell of pageItem[JV.PROP_WATERMARK_CELLS]) {
  898. if (keyMap.hasOwnProperty(watermarkCell.signature_name)) {
  899. watermarkCell.signature_name = keyMap[watermarkCell.signature_name];
  900. }
  901. }
  902. }
  903. for (const roleSign of roleRel) {
  904. if (keyMap.hasOwnProperty(roleSign.signature_name)) {
  905. roleSign.signature_name = keyMap[roleSign.signature_name];
  906. }
  907. }
  908. };
  909. const ttlDtlSignCells = [];
  910. for (let idx = 0; idx < pageDataArr.length; idx++) {
  911. const dtlSignCells = [];
  912. ttlDtlSignCells.push(dtlSignCells);
  913. filterSignCells(pageDataArr[idx], dtlSignCells, null, null, PAGE_SHOW.isTextSignature, false);
  914. let roleRel = signatureRelArr[idx];
  915. ttlRoleAmt += roleRel.length;
  916. pageDataArr[idx][JV.NODE_PAGE_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = rpt_names[idx];
  917. // 这里要做些电子签名的signature_name转换,以防重名
  918. if (roleRel.length > 0) {
  919. reAssignSignatureName(pageDataArr[idx], roleRel, rpt_names[idx]);
  920. rptRoleRelArr = rptRoleRelArr.concat(roleRel);
  921. }
  922. let hasWaterMark = false;
  923. if (pageDataArr[idx].items[0][JV.PROP_WATERMARK_CELLS] && pageDataArr[idx].items[0][JV.PROP_WATERMARK_CELLS].length > 0) {
  924. hasWaterMark = true;
  925. }
  926. if (ttlRoleAmt < 1 && hasWaterMark) {
  927. reAssignSignatureName(pageDataArr[idx], [], rpt_names[idx]);
  928. rptRoleRelArr = rptRoleRelArr.concat([pageDataArr[idx].items[0][JV.PROP_WATERMARK_CELLS][0].signature_name]);
  929. }
  930. }
  931. await excelExportUtil.exportExcelInOneBook(pageDataArr, pageSize, TENDER_NAME, rptRoleRelArr, null, getStageStatus() !== 3);
  932. for (let idx = 0; idx < pageDataArr.length; idx++) {
  933. restoreSignCells(pageDataArr[idx], ttlDtlSignCells[idx], null, null, PAGE_SHOW.isTextSignature, false);
  934. }
  935. },
  936. getExcel_New: async function (isOneBook) {
  937. let me = rptControlObj;
  938. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0 && PAGE_SHOW['closeExportExcel'] !== 1) {
  939. let refRptTplIds = [];
  940. let rpt_names = [], splitArchives = [];
  941. rptControlObj.getTplIdsCommon(refRptTplIds, rpt_names, splitArchives);
  942. const signatureRelArr = [];
  943. if (refRptTplIds.length === 0) {
  944. if (zTreeOprObj.currentNode) {
  945. //在复杂情况下会影响到原有数据(文本签名 + 签章),为减少麻烦,还是当勾选处理
  946. refRptTplIds.push(zTreeOprObj.currentNode.refId);
  947. rpt_names.push(zTreeOprObj.currentNode.name);
  948. }
  949. }
  950. if (refRptTplIds.length > 0) {
  951. let params = rptControlObj.creatCommonExportParam(refRptTplIds);
  952. params.option = getExcelOutputOption();
  953. params.splitArchives = splitArchives;
  954. // params.getPicFlag = true; //专门针对草图项,只有此项为true,才需要把草图信息带过来,预览及打印动态加载草图 // 纠结:但这样还是解决不了效率问题,得另外想交互方式
  955. if (current_stage_id > 0) {
  956. await rptCustomObj.getCustomSelect(params);
  957. }
  958. delete params.orientation; // 打印时有勾选的话,不需要提供方向
  959. $.bootstrapLoading.start();
  960. if (COMMON_WATER_MARK_PIC_DATA === null || COMMON_WATER_MARK_PIC_DATA === '') {
  961. params.needWaterMark = true;
  962. } else {
  963. params.needWaterMark = false;
  964. }
  965. params.outputType = 'Excel';
  966. CommonAjax.postXsrfEx("/tender/report_api/getMultiReports", params, WAIT_TIME_EXPORT, true, getCookie('csrfToken_j'),
  967. function(result){
  968. $.bootstrapLoading.end();
  969. if (params.needWaterMark) COMMON_WATER_MARK_PIC_DATA = result.waterMarkStr;
  970. STAGE_AUDIT = result.stageAudit || [];
  971. let pageSize = rptControlObj.getCurrentPageSize();
  972. let pageDataArr = result.data;
  973. let signatureRelInfo = result.signatureRelInfo;
  974. for (let pageObj of pageDataArr) {
  975. let tmpRel = [];
  976. for (const signatureRel of signatureRelInfo) {
  977. if (signatureRel.rpt_id === pageObj.id) {
  978. tmpRel = JSON.parse(signatureRel.rel_content);
  979. break;
  980. }
  981. }
  982. signatureRelArr.push(tmpRel);
  983. }
  984. // 统一安排merge(除草图外)
  985. for (let idx = 0; idx < pageDataArr.length; idx++) {
  986. const pageObj = pageDataArr[idx];
  987. let singleSignatureRelArr = signatureRelArr[idx];
  988. if (signatureRelInfo && signatureRelInfo.length > 0) {
  989. rptSignatureHelper.mergeSignDate(pageObj, singleSignatureRelArr, false, getStageStatus() !== 3);
  990. // rptSignatureHelper.mergeSignature(pageObj, singleSignatureRelArr); // 这里merge的意义不大
  991. rptSignatureHelper.mergeSignAudit(pageObj, singleSignatureRelArr, STAGE_AUDIT, getStageStatus() !== 3);
  992. if (PAGE_SHOW.isTextSignature) {
  993. resetTextSignature(pageObj, getStageStatus() !== 3);
  994. }
  995. }
  996. }
  997. // if (getStageStatus() === 3) {
  998. // }
  999. if (isOneBook) {
  1000. me.downloadExcelReportInOneBook(pageDataArr, pageSize, signatureRelArr, rpt_names);
  1001. } else {
  1002. me.downloadExcelReport(pageDataArr, pageSize, rpt_names, signatureRelArr);
  1003. }
  1004. },
  1005. function(failRst){
  1006. $.bootstrapLoading.end();
  1007. console.log(failRst);
  1008. },
  1009. function(exceptionRst){
  1010. $.bootstrapLoading.end();
  1011. console.log(exceptionRst);
  1012. }
  1013. );
  1014. } else {
  1015. // 这个分支本来是为了减少请求,用户已经点过的表,又没有勾选,那么就直接导出EXCEL
  1016. // 但:发现在复杂情况下会影响到原有数据(文本签名 + 签章),为减少麻烦,在前面处理,保证不会走到这分支!
  1017. }
  1018. }
  1019. },
  1020. checkAndGetExcel: function () {
  1021. if (zTreeOprObj.treeObj) {
  1022. let chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
  1023. if (chkNodes.length > 0) {
  1024. $("#show_excel_output_cfg").trigger("click");
  1025. } else {
  1026. rptControlObj.getExcel_New(false);
  1027. }
  1028. }
  1029. },
  1030. getExcel: function () {
  1031. let me = rptControlObj;
  1032. if ($("#excelExportType_AllInOneBook")[0].checked) {
  1033. // me.getAllInOneBook();
  1034. rptControlObj.getExcel_New(true);
  1035. } else if ($("#excelExportType_IndividualBook")[0].checked) {
  1036. // me.getAllIndividualExcelBook();
  1037. rptControlObj.getExcel_New(false);
  1038. }
  1039. },
  1040. getPdfFontCallbackLight: function(fontProperty) {
  1041. rptTplObj.pdfFont['SmartSimsun'].push(fontProperty);
  1042. if (rptTplObj.pdfFont['SmartSimsun'].length === 2) {
  1043. rptControlObj.isLoading = false;
  1044. }
  1045. },
  1046. getPdfFontCallback: function(fontProperty) {
  1047. let me = rptControlObj;
  1048. if (rptTplObj.pdfFont['SmartSimsun'].indexOf(fontProperty) < 0) {
  1049. rptTplObj.pdfFont['SmartSimsun'].push(fontProperty);
  1050. }
  1051. if (rptTplObj.pdfFont['SmartSimsun'].length === 2) {
  1052. $.bootstrapLoading.end();
  1053. me.getPDFEx();
  1054. }
  1055. },
  1056. loadPDFFonts: function () {
  1057. //这里尝试下异步加载字体文件
  1058. let me = rptControlObj;
  1059. me.isLoading = true;
  1060. // dynamicLoadJs('/public/jspdf/SmartSimsun-normal.js', 'normal', me.getPdfFontCallbackLight);
  1061. // dynamicLoadJs('/public/jspdf/SmartSimsun-normal2.js', 'normal', me.getPdfFontCallbackLight);
  1062. // dynamicLoadJs('/public/jspdf/SmartSimsun-bold.js', 'bold', me.getPdfFontCallbackLight);
  1063. // dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-normal.js', 'normal', me.getPdfFontCallbackLight);
  1064. dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-normal2.js', 'normal', me.getPdfFontCallbackLight);
  1065. dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-bold.js', 'bold', me.getPdfFontCallbackLight);
  1066. },
  1067. getPDFPre: function () {
  1068. let me = rptControlObj;
  1069. if (me.isLoading) {
  1070. $.bootstrapLoading.start();
  1071. console.log('fonts are loading...');
  1072. setTimeout(me.getPDFPre, 3000); //延时3秒
  1073. } else {
  1074. $.bootstrapLoading.end(); //根据测试,需要先做一次清理,防止在极端情况下出现阻塞
  1075. if (rptTplObj.pdfFont['SmartSimsun'].length === 2) {
  1076. me.getPDFEx();
  1077. } else {
  1078. $.bootstrapLoading.start();
  1079. // dynamicLoadJs('/public/jspdf/SmartSimsun-normal.js',"normal", me.getPdfFontCallback);
  1080. // dynamicLoadJs('/public/jspdf/SmartSimsun-normal2.js',"normal", me.getPdfFontCallback);
  1081. // dynamicLoadJs('/public/jspdf/SmartSimsun-bold.js',"bold", me.getPdfFontCallback);
  1082. // dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-normal.js', 'normal', me.getPdfFontCallback);
  1083. dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-normal2.js', 'normal', me.getPdfFontCallback);
  1084. dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-bold.js', 'bold', me.getPdfFontCallback);
  1085. }
  1086. }
  1087. },
  1088. getTestPDFPre: function() {
  1089. const params = {};
  1090. $.bootstrapLoading.start();
  1091. CommonAjax.postXsrfEx("/tender/report_api/getTestReport", params, WAIT_TIME_EXPORT, true, getCookie('csrfToken_j'),
  1092. async function(result){
  1093. const pageSize = 'A4';
  1094. const rpt_names = ['测试PDF格式'];
  1095. $.bootstrapLoading.end();
  1096. downloadPDFReport([result.data], pageSize, rpt_names, [], [], [], STAGE_AUDIT);
  1097. },
  1098. function(failRst){
  1099. $.bootstrapLoading.end();
  1100. console.log(failRst);
  1101. },
  1102. function(exceptionRst){
  1103. $.bootstrapLoading.end();
  1104. console.log(exceptionRst);
  1105. }
  1106. );
  1107. },
  1108. getPDFEx: async function () {
  1109. let me = rptControlObj;
  1110. if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0 && PAGE_SHOW['closeExportPdf'] !== 1) {
  1111. let refRptTplIds = [];
  1112. let rpt_names = [], splitArchives = [];
  1113. rptControlObj.getTplIdsCommon(refRptTplIds, rpt_names, splitArchives);
  1114. const signatureRelArr = [];
  1115. if (refRptTplIds.length > 0) {
  1116. let params = rptControlObj.creatCommonExportParam(refRptTplIds);
  1117. params.splitArchives = splitArchives;
  1118. // params.getPicFlag = true; //专门针对草图项,只有此项为true,才需要把草图信息带过来,预览及打印动态加载草图 // 纠结:但这样还是解决不了效率问题,得另外想交互方式
  1119. if (current_stage_id > 0) {
  1120. await rptCustomObj.getCustomSelect(params);
  1121. }
  1122. delete params.orientation; // 打印时有勾选的话,不需要提供方向
  1123. $.bootstrapLoading.start();
  1124. if (COMMON_WATER_MARK_PIC_DATA === null || COMMON_WATER_MARK_PIC_DATA === '') {
  1125. params.needWaterMark = true;
  1126. } else {
  1127. params.needWaterMark = false;
  1128. }
  1129. params.outputType = 'PDF';
  1130. CommonAjax.postXsrfEx("/tender/report_api/getMultiReports", params, WAIT_TIME_EXPORT, true, getCookie('csrfToken_j'),
  1131. async function(result){
  1132. // closeWaitingView();
  1133. $.bootstrapLoading.end();
  1134. if (params.needWaterMark) COMMON_WATER_MARK_PIC_DATA = result.waterMarkStr;
  1135. STAGE_AUDIT = result.stageAudit || [];
  1136. let pageSize = rptControlObj.getCurrentPageSize();
  1137. let pageDataArr = result.data;
  1138. let signatureRelInfo = result.signatureRelInfo;
  1139. for (let pageObj of pageDataArr) {
  1140. let tmpRel = [];
  1141. for (const signatureRel of signatureRelInfo) {
  1142. if (signatureRel.rpt_id === pageObj.id) {
  1143. tmpRel = JSON.parse(signatureRel.rel_content);
  1144. break;
  1145. }
  1146. }
  1147. signatureRelArr.push(tmpRel);
  1148. }
  1149. for (const pageData of result.data) {
  1150. await rptSignatureHelper.resetDummySignature(pageData, null); //
  1151. }
  1152. downloadPDFReport(result.data, pageSize, rpt_names, signatureRelArr, result.signatureRelInfo, refRptTplIds, STAGE_AUDIT);
  1153. },
  1154. function(failRst){
  1155. // closeWaitingView();
  1156. $.bootstrapLoading.end();
  1157. console.log(failRst);
  1158. },
  1159. function(exceptionRst){
  1160. // closeWaitingView();
  1161. $.bootstrapLoading.end();
  1162. console.log(exceptionRst);
  1163. }
  1164. );
  1165. } else {
  1166. //这个分支是为了减少请求,用户已经点过的表,又没有勾选,那么就直接导出成PDF
  1167. let pageSize = rptControlObj.getCurrentPageSize();
  1168. let pageData = zTreeOprObj.currentRptPageRst;
  1169. signatureRelArr.push(ROLE_REL_LIST);
  1170. // closeWaitingView();
  1171. $.bootstrapLoading.end();
  1172. JpcJsPDFHelper.outputAsPdf(pageData, pageSize, rpt_names[0], signatureRelArr, STAGE_AUDIT, false, zTreeOprObj._chkPrePayStatus());
  1173. }
  1174. }
  1175. },
  1176. firstPage: function(dom) {
  1177. zTreeOprObj.showPage(1, zTreeOprObj.canvas);
  1178. },
  1179. prePage: function(dom) {
  1180. zTreeOprObj.showPage(zTreeOprObj.currentPage - 1, zTreeOprObj.canvas);
  1181. },
  1182. nextPage: function(dom) {
  1183. zTreeOprObj.showPage(zTreeOprObj.currentPage + 1, zTreeOprObj.canvas);
  1184. },
  1185. lastPage: function(dom) {
  1186. let me = zTreeOprObj;
  1187. zTreeOprObj.showPage(me.maxPages, zTreeOprObj.canvas);
  1188. },
  1189. onKeydown: function (event, dom) {
  1190. let me = zTreeOprObj, keyPressed = null;
  1191. if (window.event) {
  1192. keyPressed = window.event.keyCode; // IE/Chrome
  1193. } else {
  1194. keyPressed = event.which; // Firefox
  1195. }
  1196. if (keyPressed === 13) {
  1197. let pageNum = 1;
  1198. try {
  1199. pageNum = parseInt(dom.value);
  1200. } catch (e) {
  1201. pageNum = 1;
  1202. }
  1203. if (pageNum < 1) {
  1204. pageNum = 1;
  1205. } else if (pageNum > me.maxPages) {
  1206. pageNum = me.maxPages;
  1207. }
  1208. zTreeOprObj.showPage(pageNum, zTreeOprObj.canvas);
  1209. return false;
  1210. }
  1211. },
  1212. changeMargin: function(marginPropStr, marginDom) {
  1213. CUST_CFG.margins[marginPropStr] = marginDom.value;
  1214. },
  1215. changeFontMain: function(CfgDispName, fontProperty, fontDom) {
  1216. for (let font of CUST_CFG.fonts) {
  1217. if (font["CfgDispName"] === CfgDispName) {
  1218. font[fontProperty] = fontDom.value;
  1219. break;
  1220. }
  1221. }
  1222. },
  1223. changeBorderWeight: function (dom) {
  1224. CUST_CFG.borderThick = dom.value;
  1225. },
  1226. changeCfgOption: function (optStr, dom) {
  1227. CUST_CFG[optStr] = dom.checked;
  1228. },
  1229. changeFontAdhoc: function(CfgDispName, fontProperty, fontDom) {
  1230. for (let font of CUST_CFG.fonts) {
  1231. if (font["CfgDispName"] === CfgDispName) {
  1232. if (font[fontProperty] === 'T') {
  1233. font[fontProperty] = 'F';
  1234. fontDom.className = "btn btn-sm btn-outline-secondary";
  1235. } else {
  1236. font[fontProperty] = 'T';
  1237. fontDom.className = "btn btn-sm btn-outline-secondary active";
  1238. }
  1239. break;
  1240. }
  1241. }
  1242. },
  1243. restoreMargine: function () {
  1244. zTreeOprObj.renderMargin(zTreeOprObj.defReportPageCfg);
  1245. zTreeOprObj.extractRptCfg(CUST_CFG);
  1246. },
  1247. restoreFormat: function () {
  1248. zTreeOprObj.renderFormat(zTreeOprObj.defReportPageCfg);
  1249. zTreeOprObj.extractRptCfg(CUST_CFG);
  1250. },
  1251. restoreCustCFG: function () {
  1252. let me = this;
  1253. zTreeOprObj.renderRptCfg(zTreeOprObj.defReportPageCfg);
  1254. zTreeOprObj.extractRptCfg(CUST_CFG);
  1255. // me.saveCustCfg();
  1256. },
  1257. saveCustCfg: function() {
  1258. let params = {};
  1259. params.custCfg = CUST_CFG;
  1260. CommonAjax.postEx("report_tpl_api/saveCustomerCfg", params, 20000, true, function(result){
  1261. // alert("Save successfully!");
  1262. $("#update_msg_response")[0].style.color = "green";
  1263. $("#update_msg_response")[0].innerHTML = " (保存成功!)";
  1264. setTimeout(function(){
  1265. $("#update_msg_response")[0].innerHTML = "";
  1266. }, 1000);
  1267. }, function (failRst) {
  1268. $("#update_msg_response")[0].style.color = "red";
  1269. $("#update_msg_response")[0].innerHTML = " (保存失败!)";
  1270. setTimeout(function(){
  1271. $("#update_msg_response")[0].innerHTML = "";
  1272. }, 1000);
  1273. }, null
  1274. );
  1275. },
  1276. confirmCfgChange: function() {
  1277. zTreeOprObj.changeCfg();
  1278. },
  1279. cancelCfgChange: function() {
  1280. CUST_CFG = JSON.parse(JSON.stringify(CUST_CFG_ORG));
  1281. }
  1282. };
  1283. function downloadPDFReport(pageDataArr, pageSize, rpt_names, signatureRelArr, signatureRelInfo, refRptTplIds, STAGE_AUDIT) {
  1284. const ttlDtlSignCells = [];
  1285. rptControlObj.currentDownloadIdx = 0;
  1286. const private_download = function(newPageDataArr, new_rpt_names) {
  1287. if (rptControlObj.currentDownloadIdx < newPageDataArr.length) {
  1288. let singleSignatureRelArr = [];
  1289. for (let rIdx = 0; rIdx < signatureRelInfo.length; rIdx++) {
  1290. let rptId = refRptTplIds[rptControlObj.currentDownloadIdx];
  1291. if (signatureRelInfo[rIdx].rpt_id === rptId) {
  1292. singleSignatureRelArr = signatureRelArr[rIdx]; // 有些报表可能没有签名
  1293. break;
  1294. }
  1295. }
  1296. let pageData = newPageDataArr[rptControlObj.currentDownloadIdx];
  1297. let rptName = new_rpt_names[rptControlObj.currentDownloadIdx];
  1298. rptControlObj.currentDownloadIdx++;
  1299. JpcJsPDFHelper.outputAsPdf(pageData, pageSize, rptName, singleSignatureRelArr, STAGE_AUDIT, false, zTreeOprObj._chkPrePayStatus()); // 精确控制签名
  1300. if (pageData.splitArcPages) {
  1301. // 新方式的splitArcPages数据有所不同(主要是为了考虑流水式表处理方便),splitArcPages记录的是每一段的起始页
  1302. // 比如: [1,3,4,6],这里表示总共分4段,第一段起始页是1,总页数是第二段的起始页-第一段的起始页(即:3-1)
  1303. // 最后一段的总页数是:ttlPages - 本段的起始页 + 1
  1304. /*
  1305. let rptNameIdx = 0;
  1306. const ttlPages = pageData.items.length;
  1307. const orgItems = [].concat(pageData.items);
  1308. for (let pIdx = 0; pIdx < pageData.splitArcPages.length; pIdx++) {
  1309. const startPage = pageData.splitArcPages[pIdx];
  1310. let endPage = ttlPages;
  1311. if (pIdx < pageData.splitArcPages.length - 1) {
  1312. endPage = pageData.splitArcPages[pIdx + 1] - 1;
  1313. }
  1314. const indPages = [];
  1315. for (let spIdx = startPage; spIdx <= endPage; spIdx++) {
  1316. indPages.push(orgItems[spIdx - 1]);
  1317. }
  1318. pageData.items = indPages;
  1319. JpcJsPDFHelper.outputAsPdf(pageData, pageSize, `${rptName}_${rptNameIdx}`, singleSignatureRelArr, STAGE_AUDIT);
  1320. rptNameIdx++;
  1321. }
  1322. pageData.items = orgItems;
  1323. //*/
  1324. // 已验证拆分ok
  1325. }
  1326. restoreSignCells(newPageDataArr[rptControlObj.currentDownloadIdx - 1], ttlDtlSignCells[rptControlObj.currentDownloadIdx - 1], null, null, PAGE_SHOW.isTextSignature, false);
  1327. if (rptControlObj.currentDownloadIdx < newPageDataArr.length) setTimeout(private_download(newPageDataArr, new_rpt_names), 2000);
  1328. }
  1329. };
  1330. // 导出PDF真实优化代码
  1331. let picPaths = [], dummyPicAmt = 0, dummyCells = [], dupPicPath = [], dupPicCell = [];
  1332. // 1. 先找有没有dummy
  1333. pageDataArr.forEach((pageData, pgIdx) => {
  1334. const dtlSignCells = [];
  1335. ttlDtlSignCells.push(dtlSignCells);
  1336. filterSignCells(pageData, dtlSignCells, null, null, PAGE_SHOW.isTextSignature, false);
  1337. for (let page of pageData.items) {
  1338. for (let dCell of page.signature_cells) {
  1339. if (dCell.signature_name.indexOf('dummy_pic') >= 0) {
  1340. let picIdx = picPaths.indexOf(dCell.path);
  1341. if (picIdx < 0) {
  1342. picPaths.push(dCell.path);
  1343. dummyCells.push(dCell);
  1344. dummyPicAmt++;
  1345. } else {
  1346. let dPicIdx = dupPicPath.indexOf(dCell.path);
  1347. if (dPicIdx < 0) {
  1348. dupPicPath.push(dCell.path);
  1349. dupPicCell.push([]);
  1350. dPicIdx = dupPicPath.length - 1;
  1351. }
  1352. dupPicCell[dPicIdx].push(dCell);
  1353. }
  1354. }
  1355. }
  1356. }
  1357. });
  1358. if (dummyPicAmt > 0) {
  1359. // 2. 有则一个个请求下载图片,下载完后统一导出PDF
  1360. $.bootstrapLoading.start();
  1361. let handledAmt = 0, exceptionAmt = 0;
  1362. for (let pIdx = 0; pIdx < dummyCells.length; pIdx++) {
  1363. let dCell = dummyCells[pIdx];
  1364. getBlobPublic(dCell.path).then(blob => {
  1365. if (blob === 'not found!') {
  1366. exceptionAmt++;
  1367. if ((handledAmt + exceptionAmt) === dummyPicAmt) {
  1368. $.bootstrapLoading.end();
  1369. private_download(pageDataArr, rpt_names);
  1370. }
  1371. } else {
  1372. let oFileReader = new FileReader();
  1373. oFileReader.onloadend = function (e) {
  1374. let base64 = e.target.result;
  1375. dCell.pic = base64;
  1376. handledAmt++;
  1377. let pPathIdx = dupPicPath.indexOf(dCell.path);
  1378. if (pPathIdx >= 0) {
  1379. for (let dupCell of dupPicCell[pPathIdx]) {
  1380. dupCell.pic = base64;
  1381. }
  1382. }
  1383. // console.log(`已处理草图: ${handledAmt}`);
  1384. if ((handledAmt + exceptionAmt) === dummyPicAmt) {
  1385. $.bootstrapLoading.end();
  1386. private_download(pageDataArr, rpt_names);
  1387. }
  1388. };
  1389. oFileReader.readAsDataURL(blob);
  1390. }
  1391. });
  1392. }
  1393. } else {
  1394. // 3. 无则普通导出
  1395. private_download(pageDataArr, rpt_names);
  1396. }
  1397. //*/
  1398. }
  1399. function downloadReport(urls) {
  1400. //考虑到多个报表下载,一些浏览器(如chrome)不允许一下子下载多个文件,得缓缓处理,统一在这处理
  1401. rptControlObj.currentDownloadUrl = null;
  1402. rptControlObj.currentDownloadIdx = 0;
  1403. const private_download = function() {
  1404. if (rptControlObj.currentDownloadIdx >= 0 && rptControlObj.currentDownloadIdx < urls.length) {
  1405. rptControlObj.currentDownloadUrl = urls[rptControlObj.currentDownloadIdx];
  1406. rptControlObj.currentDownloadIdx++;
  1407. window.location = rptControlObj.currentDownloadUrl;
  1408. if (rptControlObj.currentDownloadIdx < urls.length) setTimeout(private_download, 2000);
  1409. }
  1410. }
  1411. private_download();
  1412. }
  1413. function getStageStatus() {
  1414. if (current_advance_id > -1 || current_material_id > 0) {
  1415. return 3;
  1416. } else if (current_stage_id > 0 || current_stage_id === -1) {
  1417. let ppStatus = zTreeOprObj._chkPrePayStatus();
  1418. if (ppStatus === 3) {
  1419. return ppStatus
  1420. } else return current_stage_status;
  1421. } else {
  1422. if ([-100, -200].includes(current_stage_id)) {
  1423. return 3
  1424. } else if ([-300, -301, -302, -303].includes(current_stage_id)) {
  1425. // return 3; // 临时的
  1426. return BGL_OBJ?.status || -1;
  1427. }
  1428. }
  1429. return -1;
  1430. }
  1431. function getStageId() {
  1432. return current_stage_id;
  1433. }
  1434. function getStageOrder() {
  1435. return CUR_ORDER;
  1436. }
  1437. function getMaterialOrder() {
  1438. return parseInt($('#material-select').attr('m-order'));
  1439. }
  1440. function getStageTimes() {
  1441. return current_stage_times;
  1442. }
  1443. function getCloseWatermark() {
  1444. return PAGE_SHOW['closeWatermark'];
  1445. }
  1446. function getTxtSignature() {
  1447. return PAGE_SHOW['isTextSignature'];
  1448. }
  1449. function getCloseArchiveSignature() {
  1450. return PAGE_SHOW['closeArchiveSignature'];
  1451. }
  1452. function getCloseWatermarkForExcel() {
  1453. if (PAGE_SHOW['closeWatermark'] === 1 || CUST_CFG.closeWarterMark) {
  1454. return 1;
  1455. } else {
  1456. return 0;
  1457. }
  1458. }
  1459. function getExcelOutputOption() {
  1460. if (CUST_CFG.continuousOutput) {
  1461. return 'infinity'; // 连续输出方式
  1462. } else {
  1463. return 'normal'; // 目前是普通方式
  1464. }
  1465. }
  1466. function _getSplitAmendmentParam(params, tplNode) {
  1467. if (params.amendmentType === undefined || params.amendmentType === null) {
  1468. params.splitArchives = [];
  1469. }
  1470. if (tplNode.flags && tplNode.flags.amendmentType === 'splitArchive') {
  1471. let hasSplit = false;
  1472. for (let spl of params.splitArchives) {
  1473. if (spl.split_field_id == tplNode.splitArchiveField) {
  1474. hasSplit = true;
  1475. break;
  1476. }
  1477. }
  1478. if (!hasSplit) params.splitArchives.push({rpt_id: tplNode.refId, split_field_id: parseInt(tplNode.flags.splitArchiveField)});
  1479. }
  1480. }