jpc_helper_flow_tab.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. let JV = require('../jpc_value_define');
  2. let JpcCommonHelper = require('./jpc_helper_common');
  3. let JpcFlowTabHelper = {
  4. getMaxRowsPerPage: function(bands, rptTpl, isEx) {
  5. let rst = 1;
  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 = Math.floor((band.Bottom - band.Top) / maxFieldMeasure);
  18. }
  19. return rst;
  20. },
  21. getActualContentAreaHeight: function(bands, rptTpl, segments, page, 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. if (segments.length >= page) {
  35. rst = segments[page - 1].length * maxFieldMeasure;
  36. }
  37. }
  38. return rst;
  39. },
  40. chkSegEnd: function (bands, rptTpl, segmentLength, preRec, pageRecAmt, isEx) {
  41. let me = this, rst = false;
  42. let remainAmt = preRec + pageRecAmt - segmentLength;
  43. rst = me.hasEnoughSpace(rptTpl, bands, remainAmt, isEx);
  44. return rst;
  45. },
  46. hasEnoughSpace: function (rptTpl, bands, remainAmt, isEx) {
  47. if (remainAmt < 0) return false;
  48. let rst = true, measurement = 1.0, douDiffForCompare = 0.00001;
  49. let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
  50. let FLOW_INFO_STR = (!isEx)?JV.NODE_FLOW_INFO:JV.NODE_FLOW_INFO_EX;
  51. let tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT];
  52. let band = bands[tab[JV.PROP_BAND_NAME]];
  53. if (band !== null && band !== undefined) {
  54. measurement = 1.0 * tab[JV.PROP_CMN_HEIGHT] * unitFactor;
  55. let spareHeight = measurement * remainAmt;
  56. let douH = band.Bottom - band.Top;
  57. rst = ((spareHeight >= douH) || ((spareHeight - douH) <= douDiffForCompare));
  58. }
  59. return rst;
  60. }
  61. };
  62. module.exports = JpcFlowTabHelper;