jpc_helper_flow_tab.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. if (segments.length >= page) {
  33. rst = segments[page - 1].length * maxFieldMeasure;
  34. }
  35. }
  36. return rst;
  37. },
  38. chkSegEnd: function (bands, rptTpl, sortedSequence, segIdx, preRec, nextRec) {
  39. let me = this, rst = true;
  40. let remainAmt = preRec + nextRec - sortedSequence[segIdx].length;
  41. rst = me.hasEnoughSpace(rptTpl, bands, remainAmt);
  42. return rst;
  43. },
  44. hasEnoughSpace: function (rptTpl, bands, remainAmt) {
  45. if (remainAmt < 0) return false;
  46. let rst = true, measurement = 1.0, douDiffForCompare = 0.00001;
  47. let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
  48. let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
  49. let band = bands[tab[JV.PROP_BAND_NAME]];
  50. if (band !== null && band !== undefined) {
  51. measurement = 1.0 * tab[JV.PROP_CMN_HEIGHT] * unitFactor;
  52. let spareHeight = measurement * remainAmt;
  53. let douH = band.Bottom - band.Top;
  54. rst = (spareHeight >= douH) || (spareHeight - douH <= douDiffForCompare);
  55. }
  56. return rst;
  57. }
  58. };
  59. module.exports = JpcFlowTabHelper;