jpc_helper_flow_tab.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. let JV = require('../jpc_value_define');
  2. let JpcCommonHelper = require('./jpc_helper_common');
  3. let JpcFlowTabHelper = {
  4. getMaxRowsPerPage: function(bands, rptTpl) {
  5. let me = this, 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. chkSegEnd: function (bands, rptTpl, sortedSequence, segIdx, preRec, nextRec) {
  21. let me = this, rst = true;
  22. let remainAmt = preRec + nextRec - sortedSequence[segIdx].length;
  23. rst = me.hasEnoughSpace(rptTpl, bands, remainAmt);
  24. return rst;
  25. },
  26. hasEnoughSpace: function (rptTpl, bands, remainAmt) {
  27. if (remainAmt < 0) return false;
  28. let rst = true, measurement = 1.0, douDiffForCompare = 0.00001;
  29. let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
  30. let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
  31. let band = bands[tab[JV.PROP_BAND_NAME]];
  32. if (band != null && band != undefined) {
  33. measurement = 1.0 * tab[JV.PROP_CMN_HEIGHT] * unitFactor;
  34. let spareHeight = measurement * remainAmt;
  35. let douH = 1.0 * (band.Bottom - band.Top);
  36. rst = (spareHeight >= douH) || (spareHeight - douH <= douDiffForCompare);
  37. }
  38. return rst;
  39. }
  40. };
  41. module.exports = JpcFlowTabHelper;