jpc_helper_flow_tab.js 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. 'use strict';
  2. const JV = require('../jpc_value_define');
  3. const JpcCommonHelper = require('./jpc_helper_common');
  4. const JpcFlowTabHelper = {
  5. getRowHeight(bands, rptTpl, isEx) {
  6. let rst = 0;
  7. const FLOW_INFO_STR = (!isEx) ? JV.NODE_FLOW_INFO : JV.NODE_FLOW_INFO_EX;
  8. const tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT];
  9. const band = bands[tab[JV.PROP_BAND_NAME]];
  10. if (band) {
  11. let maxFieldMeasure = 1.0;
  12. if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) {
  13. const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
  14. maxFieldMeasure = 1.0 * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
  15. } else {
  16. maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT;
  17. }
  18. rst = maxFieldMeasure;
  19. }
  20. return rst;
  21. },
  22. getMaxRowsPerPage(bands, rptTpl, isEx) {
  23. let rst = 1;
  24. const FLOW_INFO_STR = (!isEx) ? JV.NODE_FLOW_INFO : JV.NODE_FLOW_INFO_EX;
  25. const tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT];
  26. const band = bands[tab[JV.PROP_BAND_NAME]];
  27. if (band) {
  28. let maxFieldMeasure = 1.0;
  29. if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) {
  30. const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
  31. maxFieldMeasure = 1.0 * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
  32. } else {
  33. maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT;
  34. }
  35. rst = Math.floor((band.Bottom - band.Top) / maxFieldMeasure);
  36. }
  37. return rst;
  38. },
  39. getActualContentAreaHeight(bands, rptTpl, segments, rowAmt, page, isEx) {
  40. let rst = 1;
  41. const FLOW_INFO_STR = (!isEx) ? JV.NODE_FLOW_INFO : JV.NODE_FLOW_INFO_EX;
  42. const tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT];
  43. const band = bands[tab[JV.PROP_BAND_NAME]];
  44. if (band) {
  45. let maxFieldMeasure = 1.0;
  46. if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) {
  47. const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
  48. maxFieldMeasure = 1.0 * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
  49. } else {
  50. maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT;
  51. }
  52. if (segments.length >= page) {
  53. rst = rowAmt * maxFieldMeasure;
  54. }
  55. }
  56. return rst;
  57. },
  58. chkSegEnd(bands, rptTpl, segmentLength, preRec, pageRecAmt, isEx) {
  59. let me = this,
  60. rst = false;
  61. const remainAmt = preRec + pageRecAmt - segmentLength;
  62. rst = me.hasEnoughSpace(rptTpl, bands, remainAmt, isEx);
  63. return rst;
  64. },
  65. hasEnoughSpace(rptTpl, bands, remainAmt, isEx) {
  66. if (remainAmt < 0) return false;
  67. let rst = true,
  68. measurement = 1.0,
  69. douDiffForCompare = 0.00001;
  70. const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
  71. const FLOW_INFO_STR = (!isEx) ? JV.NODE_FLOW_INFO : JV.NODE_FLOW_INFO_EX;
  72. const tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT];
  73. const band = bands[tab[JV.PROP_BAND_NAME]];
  74. if (band !== null && band !== undefined) {
  75. measurement = 1.0 * tab[JV.PROP_CMN_HEIGHT] * unitFactor;
  76. const spareHeight = measurement * remainAmt;
  77. const douH = band.Bottom - band.Top;
  78. rst = ((spareHeight >= douH) || ((spareHeight - douH) <= douDiffForCompare));
  79. }
  80. return rst;
  81. },
  82. };
  83. module.exports = JpcFlowTabHelper;