let JV = require('../jpc_value_define'); let JpcCommonHelper = require('./jpc_helper_common'); let JpcFlowTabHelper = { getMaxRowsPerPage: function(bands, rptTpl) { let rst = 1; let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT]; let band = bands[tab[JV.PROP_BAND_NAME]]; if (band) { let maxFieldMeasure = 1.0; if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) { let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl); maxFieldMeasure = 1.0 * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor; } else { maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT; } rst = Math.floor((band.Bottom - band.Top) / maxFieldMeasure); } return rst; }, getActualContentAreaHeight: function(bands, rptTpl, segments, page) { let rst = 1; let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT]; let band = bands[tab[JV.PROP_BAND_NAME]]; if (band) { let maxFieldMeasure = 1.0; if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) { let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl); maxFieldMeasure = 1.0 * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor; } else { maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT; } //rst = Math.floor((band.Bottom - band.Top) / maxFieldMeasure); if (segments.length >= page) { rst = segments[page - 1].length * maxFieldMeasure; } } return rst; }, chkSegEnd: function (bands, rptTpl, sortedSequence, segIdx, preRec, nextRec) { let me = this, rst = true; let remainAmt = preRec + nextRec - sortedSequence[segIdx].length; rst = me.hasEnoughSpace(rptTpl, bands, remainAmt); return rst; }, hasEnoughSpace: function (rptTpl, bands, remainAmt) { if (remainAmt < 0) return false; let rst = true, measurement = 1.0, douDiffForCompare = 0.00001; let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl); let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT]; let band = bands[tab[JV.PROP_BAND_NAME]]; if (band !== null && band !== undefined) { measurement = 1.0 * tab[JV.PROP_CMN_HEIGHT] * unitFactor; let spareHeight = measurement * remainAmt; let douH = band.Bottom - band.Top; rst = (spareHeight >= douH) || (spareHeight - douH <= douDiffForCompare); } return rst; } }; module.exports = JpcFlowTabHelper;