jpc_ex.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. 'use strict';
  2. const JV = require('./jpc_value_define');
  3. const JpcBand = require('./jpc_band');
  4. const JpcFlowTab = require('./jpc_flow_tab');
  5. const JpcBillTab = require('./jpc_bill_tab');
  6. const JpcCrossTab = require('./jpc_cross_tab');
  7. const JpcField = require('./jpc_field');
  8. const JpcParam = require('./jpc_param');
  9. const JpcFunc = require('./jpc_function');
  10. const JpcEvent = require('./jpc_event');
  11. const JpcData = require('./jpc_data');
  12. const JpcCommonHelper = require('./helper/jpc_helper_common');
  13. const $JE = require('./jpc_rte'); // Important: for self-define function execution purpose
  14. const JpcExSrv = function() {};
  15. JpcExSrv.prototype.createNew = function() {
  16. function private_buildDftItems(rptTpl, dftCollection, propArray, nodeName) {
  17. const rst = {};
  18. if (dftCollection) {
  19. for (let i = 0; i < dftCollection.length; i++) {
  20. const item = {};
  21. for (let j = 0; j < propArray.length; j++) {
  22. item[propArray[j]] = dftCollection[i][propArray[j]];
  23. }
  24. rst[dftCollection[i][JV.PROP_ID]] = item;
  25. }
  26. if (rptTpl && rptTpl[nodeName] && rptTpl[nodeName].length > 0) {
  27. for (let i = 0; i < rptTpl[nodeName].length; i++) {
  28. const rptDftItem = rptTpl[nodeName][i];
  29. if (rst[rptDftItem[JV.PROP_ID]] === undefined) {
  30. const item = {};
  31. for (let j = 0; j < propArray.length; j++) {
  32. item[propArray[j]] = rptDftItem[propArray[j]];
  33. }
  34. rst[rptDftItem[JV.PROP_ID]] = item;
  35. }
  36. }
  37. }
  38. }
  39. return rst;
  40. }
  41. function private_buildDftControls(rptTpl, dftControlCollection) {
  42. return private_buildDftItems(rptTpl, dftControlCollection, JV.CONTROL_PROPS, JV.NODE_CONTROL_COLLECTION);
  43. }
  44. function private_buildDftFonts(rptTpl, dftFontCollection) {
  45. return private_buildDftItems(rptTpl, dftFontCollection, JV.FONT_PROPS, JV.NODE_FONT_COLLECTION);
  46. }
  47. function private_buildDftStyles(rptTpl, dftStyleCollection) {
  48. const rst = {};
  49. function private_CopyBorder(destItem, srcItem) {
  50. destItem[JV.PROP_LINE_WEIGHT] = srcItem[JV.PROP_LINE_WEIGHT];
  51. destItem[JV.PROP_DASH_STYLE] = srcItem[JV.PROP_DASH_STYLE];
  52. destItem[JV.PROP_COLOR] = srcItem[JV.PROP_COLOR];
  53. }
  54. if (dftStyleCollection) {
  55. for (let i = 0; i < dftStyleCollection.length; i++) {
  56. const item = {};
  57. if (dftStyleCollection[i][JV.PROP_BORDER_STYLE] && dftStyleCollection[i][JV.PROP_BORDER_STYLE].length > 0) {
  58. for (let j = 0; j < dftStyleCollection[i][JV.PROP_BORDER_STYLE].length; j++) {
  59. const borderItem = {};
  60. private_CopyBorder(borderItem, dftStyleCollection[i][JV.PROP_BORDER_STYLE][j]);
  61. item[dftStyleCollection[i][JV.PROP_BORDER_STYLE][j][JV.PROP_POSITION]] = borderItem;
  62. }
  63. }
  64. rst[dftStyleCollection[i][JV.PROP_ID]] = item;
  65. }
  66. if (rptTpl && rptTpl[JV.NODE_STYLE_COLLECTION] && rptTpl[JV.NODE_STYLE_COLLECTION].length > 0) {
  67. for (let i = 0; i < rptTpl[JV.NODE_STYLE_COLLECTION].length; i++) {
  68. const rptDftItem = rptTpl[JV.NODE_STYLE_COLLECTION][i];
  69. if (rst[rptDftItem[JV.PROP_ID]] === undefined) {
  70. if (rptDftItem[JV.PROP_ID].indexOf('_AutoHeightMerge_Top') > 0) {
  71. const key = rptDftItem[JV.PROP_ID].substr(0, rptDftItem[JV.PROP_ID].indexOf('_AutoHeightMerge_Top'));
  72. if (rst[key]) {
  73. const item = {};
  74. if (rst[key][JV.PROP_LEFT]) {
  75. item[JV.PROP_LEFT] = {};
  76. private_CopyBorder(item[JV.PROP_LEFT], rst[key][JV.PROP_LEFT]);
  77. }
  78. if (rst[key][JV.PROP_RIGHT]) {
  79. item[JV.PROP_RIGHT] = {};
  80. private_CopyBorder(item[JV.PROP_RIGHT], rst[key][JV.PROP_RIGHT]);
  81. }
  82. if (rst[key][JV.PROP_TOP]) {
  83. item[JV.PROP_TOP] = {};
  84. private_CopyBorder(item[JV.PROP_TOP], rst[key][JV.PROP_TOP]);
  85. }
  86. rst[rptDftItem[JV.PROP_ID]] = item;
  87. }
  88. } else if (rptDftItem[JV.PROP_ID].indexOf('_AutoHeightMerge_Middle') > 0) {
  89. const key = rptDftItem[JV.PROP_ID].substr(0, rptDftItem[JV.PROP_ID].indexOf('_AutoHeightMerge_Middle'));
  90. if (rst[key]) {
  91. const item = {};
  92. if (rst[key][JV.PROP_LEFT]) {
  93. item[JV.PROP_LEFT] = {};
  94. private_CopyBorder(item[JV.PROP_LEFT], rst[key][JV.PROP_LEFT]);
  95. }
  96. if (rst[key][JV.PROP_RIGHT]) {
  97. item[JV.PROP_RIGHT] = {};
  98. private_CopyBorder(item[JV.PROP_RIGHT], rst[key][JV.PROP_RIGHT]);
  99. }
  100. rst[rptDftItem[JV.PROP_ID]] = item;
  101. }
  102. } else if (rptDftItem[JV.PROP_ID].indexOf('_AutoHeightMerge_Bottom') > 0) {
  103. const key = rptDftItem[JV.PROP_ID].substr(0, rptDftItem[JV.PROP_ID].indexOf('_AutoHeightMerge_Bottom'));
  104. if (rst[key]) {
  105. const item = {};
  106. if (rst[key][JV.PROP_LEFT]) {
  107. item[JV.PROP_LEFT] = {};
  108. private_CopyBorder(item[JV.PROP_LEFT], rst[key][JV.PROP_LEFT]);
  109. }
  110. if (rst[key][JV.PROP_RIGHT]) {
  111. item[JV.PROP_RIGHT] = {};
  112. private_CopyBorder(item[JV.PROP_RIGHT], rst[key][JV.PROP_RIGHT]);
  113. }
  114. if (rst[key][JV.PROP_BOTTOM]) {
  115. item[JV.PROP_BOTTOM] = {};
  116. private_CopyBorder(item[JV.PROP_BOTTOM], rst[key][JV.PROP_BOTTOM]);
  117. }
  118. rst[rptDftItem[JV.PROP_ID]] = item;
  119. }
  120. } else {
  121. const item = {};
  122. for (let j = 0; j < rptDftItem[JV.PROP_BORDER_STYLE].length; j++) {
  123. const borderItem = {};
  124. private_CopyBorder(borderItem, rptDftItem[JV.PROP_BORDER_STYLE][j]);
  125. item[rptDftItem[JV.PROP_BORDER_STYLE][j][JV.PROP_POSITION]] = borderItem;
  126. }
  127. rst[rptDftItem[JV.PROP_ID]] = item;
  128. }
  129. }
  130. }
  131. }
  132. }
  133. return rst;
  134. }
  135. const JpcResult = {};
  136. JpcResult.initialize = function(rptTpl) {
  137. const me = this;
  138. if (rptTpl[JV.NODE_FLOW_INFO]) {
  139. me.flowTab = JpcFlowTab.createNew();
  140. me.flowTab.initialize(false);
  141. me.isFollowMode = false;
  142. }
  143. if (rptTpl[JV.NODE_FLOW_INFO_EX]) {
  144. me.flowTabEx = JpcFlowTab.createNew();
  145. me.flowTabEx.initialize(true);
  146. if (rptTpl[JV.NODE_FLOW_INFO_EX][JV.PROP_FLOW_EX_DISPLAY_MODE] === JV.DISPLAY_MODE_FOLLOW) {
  147. me.isFollowMode = true;
  148. }
  149. }
  150. if (rptTpl[JV.NODE_BILL_INFO]) {
  151. me.billTab = JpcBillTab.createNew();
  152. me.billTab.initialize();
  153. }
  154. if (rptTpl[JV.NODE_CROSS_INFO]) {
  155. me.crossTab = JpcCrossTab.createNew();
  156. me.crossTab.initialize();
  157. }
  158. me.totalPages = 0;
  159. me.exTotalPages = 0;
  160. me.runTimePageData = {};
  161. me.fields = JpcField.createNew(rptTpl);
  162. me.params = JpcParam.createNew(rptTpl);
  163. // console.log('params:');
  164. // console.log(me.params);
  165. me.formulas = JpcFunc.createNew(rptTpl);
  166. me.events = JpcEvent.createNew(rptTpl);
  167. };
  168. JpcResult.analyzeData = function($CTX_HELPER, rptTpl, dataObj, defProperties, option, outputType, $CUSTOM_DEFINE) {
  169. const me = this;
  170. const dftPagingOption = option || JV.PAGING_OPTION_NORMAL;
  171. // 1. data object
  172. let dataHelper = JpcData.createNew();
  173. // console.log(JSON.stringify(rptTpl));
  174. me.executeFormulas($CTX_HELPER, JV.RUN_TYPE_BEFORE_ANALYZING, rptTpl, dataObj, me, $CUSTOM_DEFINE, defProperties); // 在分析前运行,主要是增加灵活性,比如:重新编排数据的主从关系
  175. // console.log(JSON.stringify(rptTpl));
  176. if (me.crossTab) {
  177. me.executeFormulas($CTX_HELPER, JV.RUN_TYPE_BEFORE_PAGING, rptTpl, dataObj, me, $CUSTOM_DEFINE, defProperties);
  178. dataHelper.analyzeData(rptTpl, dataObj);
  179. me.crossTab.sorting(rptTpl, dataObj, dataHelper.dataSeq.slice(0), me);
  180. } else {
  181. dataHelper.analyzeData(rptTpl, dataObj);
  182. // 2. tab object
  183. // pre-condition: the data should be sorted in SQL/NoSQL level!
  184. // let dt1 = new Date();
  185. if (me.flowTab) {
  186. me.flowTab.sorting(rptTpl, dataObj, dataHelper.dataSeq.slice(0), me);
  187. if (me.flowTabEx) {
  188. me.flowTabEx.sorting(rptTpl, dataObj, dataHelper.exDataSeq.slice(0), me);
  189. }
  190. }
  191. if (me.billTab) {
  192. me.billTab.sorting(rptTpl, dataObj, dataHelper.dataSeq.slice(0), me);
  193. }
  194. // let dt2 = new Date();
  195. // alert(dt2 - dt1);
  196. // 3. formulas
  197. me.executeFormulas($CTX_HELPER, JV.RUN_TYPE_BEFORE_PAGING, rptTpl, dataObj, me, $CUSTOM_DEFINE, defProperties);
  198. }
  199. // 4. paging
  200. me.paging(rptTpl, dataObj, defProperties, dftPagingOption, outputType);
  201. // alert('analyzeData was completed!');
  202. // for garbage collection:
  203. dataHelper = null;
  204. };
  205. JpcResult.paging = function(rptTpl, dataObj, defProperties, option, outputType) {
  206. const me = this;
  207. const dftPagingOption = option || JV.PAGING_OPTION_NORMAL;
  208. if (me.flowTab) {
  209. if (me.isFollowMode) {
  210. me.totalPages = me.flowTab.preSetupPages(rptTpl, dataObj, defProperties, dftPagingOption, me, me.flowTabEx, outputType);
  211. } else {
  212. me.totalPages = me.flowTab.preSetupPages(rptTpl, dataObj, defProperties, dftPagingOption, me, null, outputType);
  213. if (me.flowTabEx) {
  214. me.exTotalPages = me.flowTabEx.preSetupPages(rptTpl, dataObj, defProperties, dftPagingOption, me, null, outputType);
  215. // console.log('ad-hoc flow pages: ' + me.exTotalPages);
  216. }
  217. me.totalPages += me.exTotalPages;
  218. }
  219. } else if (me.crossTab) {
  220. // me.totalPages = me.crossTab.preSetupPages(rptTpl, defProperties, dftPagingOption);
  221. me.totalPages = me.crossTab.preSetupPages(rptTpl, defProperties, JV.PAGING_OPTION_NORMAL); // infinity对交叉表来说无意义
  222. } else if (me.billTab) {
  223. me.totalPages = me.billTab.paging(rptTpl, dataObj);
  224. }
  225. };
  226. JpcResult.getDftRowsPerPage = function(rptTpl, defProperties) {
  227. const me = this;
  228. let rst = 1;
  229. if (me.flowTab) {
  230. rst = me.flowTab.getDftRowsPerPage(rptTpl, defProperties, me);
  231. } else if (me.crossTab) {
  232. // 实际业务可以暂时不提供
  233. } else if (me.billTab) {
  234. // 实际业务可以暂时不提供
  235. }
  236. return rst;
  237. };
  238. JpcResult.executeFormulas = function($CTX_HELPER, runType, $CURRENT_TEMPLATE, $CURRENT_DATA, $CURRENT_RPT, $CUSTOM_DEFINE, $PAGE_PROPERTIES) {
  239. const execFmlMe = this;
  240. for (let execFmlIdx = 0; execFmlIdx < execFmlMe.formulas.length; execFmlIdx++) {
  241. // remark: 搞这么复杂的变量名是为了防止与表达式起冲突(如循环变量i,j,k,容易造成变量冲突且不容易看出问题)
  242. // console.log('execFmlMe.formulas[execFmlIdx][JV.PROP_RUN_TYPE]: ' + execFmlMe.formulas[execFmlIdx][JV.PROP_RUN_TYPE]);
  243. // console.log('runType: ' + runType);
  244. if (execFmlMe.formulas[execFmlIdx][JV.PROP_RUN_TYPE] === runType) {
  245. const expression = execFmlMe.formulas[execFmlIdx][JV.PROP_EXPRESSION];
  246. if (expression) {
  247. const $ME = execFmlMe.formulas[execFmlIdx];
  248. // console.log('current expression idx: ' + execFmlIdx);
  249. // console.log(expression);
  250. try {
  251. eval(expression);
  252. } catch (ex) {
  253. console.log('current expression idx: ' + execFmlIdx);
  254. console.log(expression);
  255. console.log(ex);
  256. }
  257. }
  258. }
  259. }
  260. };
  261. JpcResult.outputAsPreviewPage = function(rptTpl, defProperties) {
  262. const me = this;
  263. const rst = {};
  264. rst[JV.NODE_CONTROL_COLLECTION] = private_buildDftControls(rptTpl, (defProperties === null) ? null : defProperties.ctrls);
  265. rst[JV.NODE_STYLE_COLLECTION] = private_buildDftStyles(rptTpl, (defProperties === null) ? null : defProperties.styles);
  266. rst[JV.NODE_FONT_COLLECTION] = private_buildDftFonts(rptTpl, (defProperties === null) ? null : defProperties.fonts);
  267. rst[JV.NODE_PAGE_INFO] = {};
  268. rst[JV.NODE_PAGE_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME];
  269. rst[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE] = JpcCommonHelper.getPageSize(rptTpl);
  270. rst[JV.NODE_PAGE_INFO][JV.NODE_MARGINS] = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS];
  271. rst.items = [];
  272. let bands = JpcBand.createNew(rptTpl, defProperties);
  273. function getPageMergeBorder() {
  274. let mergeRst = null;
  275. if (bands[JV.BAND_PROP_MERGE_BAND]) {
  276. const mergedBand = bands[JV.BAND_PROP_MERGE_BAND];
  277. mergeRst = {};
  278. mergeRst[JV.PROP_LEFT] = parseInt(mergedBand[JV.PROP_LEFT].toFixed(0));
  279. mergeRst[JV.PROP_RIGHT] = parseInt(mergedBand[JV.PROP_RIGHT].toFixed(0));
  280. mergeRst[JV.PROP_TOP] = parseInt(mergedBand[JV.PROP_TOP].toFixed(0));
  281. mergeRst[JV.PROP_BOTTOM] = parseInt(mergedBand[JV.PROP_BOTTOM].toFixed(0));
  282. }
  283. return mergeRst;
  284. }
  285. try {
  286. // 1.
  287. const rstPage = {};
  288. rstPage[JV.PROP_PAGE_SEQ] = 1;
  289. if (me.flowTab) {
  290. rstPage[JV.PROP_CELLS] = me.flowTab.outputAsPreviewPage(rptTpl, bands, rst[JV.NODE_CONTROL_COLLECTION], me);
  291. } else if (me.crossTab) {
  292. rstPage[JV.PROP_CELLS] = me.crossTab.outputAsPreviewPage(rptTpl, bands, rst[JV.NODE_CONTROL_COLLECTION], me);
  293. } else if (me.billTab) {
  294. rstPage[JV.PROP_CELLS] = me.billTab.outputAsPreviewPage(rptTpl, bands, rst[JV.NODE_CONTROL_COLLECTION], me);
  295. }
  296. const pageMergeBorder = getPageMergeBorder();
  297. if (pageMergeBorder) {
  298. rstPage[JV.PROP_PAGE_MERGE_BORDER] = pageMergeBorder;
  299. }
  300. rstPage[JV.PROP_SIGNATURE_CELLS] = [];
  301. rstPage[JV.PROP_SIGNATURE_DATE_CELLS] = [];
  302. rstPage[JV.PROP_SIGNATURE_AUDIT_CELLS] = [];
  303. rst.items.push(rstPage);
  304. // 2.
  305. if (bands[JV.BAND_PROP_MERGE_BAND]) {
  306. const mergedBand = {};
  307. const band = bands[JV.BAND_PROP_MERGE_BAND];
  308. mergedBand[JV.PROP_LEFT] = parseInt(band[JV.PROP_LEFT].toFixed(0));
  309. mergedBand[JV.PROP_RIGHT] = parseInt(band[JV.PROP_RIGHT].toFixed(0));
  310. mergedBand[JV.PROP_TOP] = parseInt(band[JV.PROP_TOP].toFixed(0));
  311. mergedBand[JV.PROP_BOTTOM] = parseInt(band[JV.PROP_BOTTOM].toFixed(0));
  312. mergedBand[JV.BAND_PROP_STYLE] = band[JV.BAND_PROP_STYLE];
  313. rst[JV.BAND_PROP_MERGE_BAND] = mergedBand;
  314. }
  315. } catch (exception) {
  316. console.log(exception);
  317. } finally {
  318. bands = null;
  319. }
  320. return rst;
  321. };
  322. JpcResult.outputAsSimpleJSONPageArray = function($CTX_HELPER, rptTpl, dataObj, startPage, endPage, defProperties, customizeCfg, $CUSTOM_DEFINE) {
  323. const me = this;
  324. const rst = {};
  325. if ((startPage > 0) && (startPage <= endPage) && (endPage <= me.totalPages)) {
  326. rst[JV.NODE_CONTROL_COLLECTION] = private_buildDftControls(rptTpl, (defProperties === null) ? null : defProperties.ctrls);
  327. // console.log('controls: ');
  328. // console.log(rst[JV.NODE_CONTROL_COLLECTION]);
  329. rst[JV.NODE_STYLE_COLLECTION] = private_buildDftStyles(rptTpl, (defProperties === null) ? null : defProperties.styles);
  330. rst[JV.NODE_FONT_COLLECTION] = private_buildDftFonts(rptTpl, (defProperties === null) ? null : defProperties.fonts);
  331. rst[JV.NODE_PAGE_INFO] = {};
  332. rst[JV.NODE_PAGE_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME];
  333. rst[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE] = JpcCommonHelper.getPageSize(rptTpl);
  334. rst[JV.NODE_PAGE_INFO][JV.NODE_MARGINS] = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS];
  335. rst.items = [];
  336. let bands = JpcBand.createNew(rptTpl, defProperties);
  337. try {
  338. for (let page = startPage; page <= endPage; page++) {
  339. me.runTimePageData.currentPage = page;
  340. me.executeFormulas($CTX_HELPER, JV.RUN_TYPE_BEFORE_OUTPUT, rptTpl, dataObj, me, $CUSTOM_DEFINE, defProperties);
  341. rst.items.push(me.outputAsSimpleJSONPage(rptTpl, dataObj, bands, page, rst[JV.NODE_CONTROL_COLLECTION], rst[JV.NODE_FONT_COLLECTION], customizeCfg));
  342. }
  343. if (bands[JV.BAND_PROP_MERGE_BAND]) {
  344. const mergedBand = {};
  345. const band = bands[JV.BAND_PROP_MERGE_BAND];
  346. mergedBand[JV.PROP_LEFT] = parseInt(band[JV.PROP_LEFT].toFixed(0));
  347. mergedBand[JV.PROP_RIGHT] = parseInt(band[JV.PROP_RIGHT].toFixed(0));
  348. mergedBand[JV.PROP_TOP] = parseInt(band[JV.PROP_TOP].toFixed(0));
  349. mergedBand[JV.PROP_BOTTOM] = parseInt(band[JV.PROP_BOTTOM].toFixed(0));
  350. mergedBand[JV.BAND_PROP_STYLE] = band[JV.BAND_PROP_STYLE];
  351. rst[JV.BAND_PROP_MERGE_BAND] = mergedBand;
  352. }
  353. } catch (exception) {
  354. console.log(exception);
  355. } finally {
  356. bands = null;
  357. }
  358. }
  359. return rst;
  360. };
  361. JpcResult.outputAsSimpleJSONPage = function(rptTpl, dataObj, bands, page, controls, fonts, customizeCfg) {
  362. const me = this;
  363. let rst = null;
  364. function getPageMergeBorder() {
  365. let mergeRst = null;
  366. if (bands[JV.BAND_PROP_MERGE_BAND]) {
  367. const mergedBand = bands[JV.BAND_PROP_MERGE_BAND];
  368. mergeRst = {};
  369. mergeRst[JV.PROP_LEFT] = parseInt(mergedBand[JV.PROP_LEFT].toFixed(0));
  370. mergeRst[JV.PROP_RIGHT] = parseInt(mergedBand[JV.PROP_RIGHT].toFixed(0));
  371. mergeRst[JV.PROP_TOP] = parseInt(mergedBand[JV.PROP_TOP].toFixed(0));
  372. mergeRst[JV.PROP_BOTTOM] = parseInt(mergedBand[JV.PROP_BOTTOM].toFixed(0));
  373. }
  374. return mergeRst;
  375. }
  376. if (me.totalPages >= page) {
  377. rst = {};
  378. rst[JV.PROP_PAGE_SEQ] = page;
  379. // rst.cells = [];
  380. let adHocMergePos = null;
  381. if (me.flowTab) {
  382. // console.log('page_seg_map:');
  383. // console.log(me.flowTab.page_seg_map);
  384. if (me.totalPages - me.exTotalPages >= page) {
  385. if (me.flowTab.paging_option === JV.PAGING_OPTION_INFINITY) {
  386. adHocMergePos = {};
  387. }
  388. rst[JV.PROP_CELLS] = me.flowTab.outputAsSimpleJSONPage(rptTpl, dataObj, page, bands, controls, fonts, adHocMergePos, me, customizeCfg);
  389. rst[JV.PROP_SIGNATURE_CELLS] = me.flowTab.signatureRst;
  390. rst[JV.PROP_SIGNATURE_DATE_CELLS] = me.flowTab.signatureDateRst;
  391. rst[JV.PROP_SIGNATURE_AUDIT_CELLS] = me.flowTab.signatureAuditRst;
  392. if (adHocMergePos) {
  393. adHocMergePos[JV.NODE_PAGE_SIZE] = JpcCommonHelper.getPageSize(rptTpl);
  394. rst[JV.PAGE_SPECIAL_MERGE_POS] = adHocMergePos;
  395. }
  396. } else {
  397. if (!me.isFollowMode) {
  398. rst[JV.PROP_CELLS] = me.flowTabEx.outputAsSimpleJSONPage(rptTpl, dataObj, page - (me.totalPages - me.exTotalPages), bands, controls, fonts, adHocMergePos, me, customizeCfg);
  399. rst[JV.PROP_SIGNATURE_CELLS] = me.flowTabEx.signatureRst;
  400. rst[JV.PROP_SIGNATURE_DATE_CELLS] = me.flowTabEx.signatureDateRst;
  401. rst[JV.PROP_SIGNATURE_AUDIT_CELLS] = me.flowTabEx.signatureAuditRst;
  402. }
  403. }
  404. } else if (me.crossTab) {
  405. rst[JV.PROP_CELLS] = me.crossTab.outputAsSimpleJSONPage(rptTpl, dataObj, page, bands, controls, fonts, me, customizeCfg);
  406. rst[JV.PROP_SIGNATURE_CELLS] = me.crossTab.signatureRst;
  407. rst[JV.PROP_SIGNATURE_DATE_CELLS] = me.crossTab.signatureDateRst;
  408. rst[JV.PROP_SIGNATURE_AUDIT_CELLS] = me.crossTab.signatureAuditRst;
  409. } else if (me.billTab) {
  410. rst[JV.PROP_CELLS] = me.billTab.outputAsSimpleJSONPage(rptTpl, dataObj, page, bands, controls, fonts, me, customizeCfg);
  411. rst[JV.PROP_SIGNATURE_CELLS] = me.billTab.signatureRst;
  412. rst[JV.PROP_SIGNATURE_DATE_CELLS] = me.billTab.signatureDateRst;
  413. rst[JV.PROP_SIGNATURE_AUDIT_CELLS] = me.billTab.signatureAuditRst;
  414. }
  415. if (!(me.flowTab && me.flowTab.paging_option === JV.PAGING_OPTION_INFINITY)) {
  416. const pageMergeBorder = getPageMergeBorder();
  417. if (pageMergeBorder) {
  418. rst[JV.PROP_PAGE_MERGE_BORDER] = pageMergeBorder;
  419. }
  420. }
  421. } else {
  422. console.log('no page result was found!');
  423. }
  424. return rst;
  425. };
  426. // JpcEx.rte.currentRptObj = JpcResult;
  427. return JpcResult;
  428. };
  429. module.exports = new JpcExSrv();