jpc_helper_flow_tab.js 3.9 KB

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