jpc_helper_flow_tab.js 2.9 KB

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