| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 | 
							- 'use strict';
 
- const JV = require('../jpc_value_define');
 
- const JpcCommonHelper = require('./jpc_helper_common');
 
- const JpcBandHelper = {
 
-     getBandTypeValByString: function(bandType) {
 
-         let rst = JV.PAGE_STATUS.indexOf(bandType);
 
-         if (rst < 0) rst = JV.STATUS_NORMAL;
 
-         return rst;
 
-     },
 
-     setBandArea: function(bands, rptTpl, pageStatus, isOnlyNormalStatus, isOnlyExStatus) {
 
-         const me = this;
 
-         if (rptTpl[JV.NODE_BAND_COLLECTION]) {
 
-             isOnlyNormalStatus = isOnlyNormalStatus || false;
 
-             isOnlyExStatus = isOnlyExStatus || false;
 
-             const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
 
-             const orgArea = JpcCommonHelper.getReportArea(rptTpl, unitFactor);
 
-             for (let i = 0; i < rptTpl[JV.NODE_BAND_COLLECTION].length; i++) {
 
-                 me.setBandPos(bands, rptTpl[JV.NODE_BAND_COLLECTION][i], orgArea, unitFactor, pageStatus, isOnlyNormalStatus, isOnlyExStatus);
 
-             }
 
-         }
 
-     },
 
-     setBandPos: function(bands, bandNode, orgArea, unitFactor, pageStatus, isOnlyNormalStatus, isOnlyExStatus) {
 
-         const me = this;
 
-         const band = bands[bandNode[JV.BAND_PROP_NAME]];
 
-         // 0. for multi flow purpose
 
-         if (isOnlyNormalStatus) {
 
-             if (bandNode.hasOwnProperty(JV.PROP_BAND_EX_ONLY) && JpcCommonHelper.getBoolean(bandNode[JV.PROP_BAND_EX_ONLY])) {
 
-                 return;
 
-             }
 
-         }
 
-         if (isOnlyExStatus) {
 
-             if (bandNode.hasOwnProperty(JV.PROP_BAND_NORMAL_ONLY) && !(JpcCommonHelper.getBoolean(bandNode[JV.PROP_BAND_NORMAL_ONLY]))) {
 
-                 return;
 
-             }
 
-         }
 
-         // 1. initialize
 
-         band[JV.PROP_LEFT] = orgArea[JV.IDX_LEFT];
 
-         band[JV.PROP_TOP] = orgArea[JV.IDX_TOP];
 
-         band[JV.PROP_RIGHT] = orgArea[JV.IDX_RIGHT];
 
-         band[JV.PROP_BOTTOM] = orgArea[JV.IDX_BOTTOM];
 
-         // 2. set this band
 
-         if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]]) {
 
-             switch (band[JV.BAND_PROP_ALIGNMENT]) {
 
-                 case JV.LAYOUT_TOP:
 
-                     if (band[JV.PROP_CALCULATION] === JV.CAL_TYPE_ABSTRACT) {
 
-                         band.Bottom = band.Top + unitFactor * band[JV.BAND_PROP_HEIGHT];
 
-                     } else {
 
-                         band.Bottom = band.Top + (band.Bottom - band.Top) * band[JV.BAND_PROP_HEIGHT] / 100;
 
-                     }
 
-                     orgArea[JV.IDX_TOP] = band.Bottom;
 
-                     break;
 
-                 case JV.LAYOUT_BOTTOM:
 
-                     if (band[JV.PROP_CALCULATION] === JV.CAL_TYPE_ABSTRACT) {
 
-                         band.Top = band.Bottom - unitFactor * band[JV.BAND_PROP_HEIGHT];
 
-                     } else {
 
-                         band.Top = band.Bottom - (band.Bottom - band.Top) * band[JV.BAND_PROP_HEIGHT] / 100;
 
-                     }
 
-                     orgArea[JV.IDX_BOTTOM] = band.Top;
 
-                     break;
 
-                 case JV.LAYOUT_LEFT:
 
-                     if (band[JV.PROP_CALCULATION] === JV.CAL_TYPE_ABSTRACT) {
 
-                         band.Right = band.Left + unitFactor * band[JV.BAND_PROP_WIDTH];
 
-                     } else {
 
-                         band.Right = band.Left + (band.Right - band.Left) * band[JV.BAND_PROP_WIDTH] / 100;
 
-                     }
 
-                     orgArea[JV.IDX_LEFT] = band.Right;
 
-                     break;
 
-                 case JV.LAYOUT_RIGHT:
 
-                     if (band[JV.PROP_CALCULATION] === JV.CAL_TYPE_ABSTRACT) {
 
-                         band.Left = band.Right - unitFactor * band[JV.BAND_PROP_WIDTH];
 
-                     } else {
 
-                         band.Left = band.Right - (band.Right - band.Left) * band[JV.BAND_PROP_WIDTH] / 100;
 
-                     }
 
-                     orgArea[JV.IDX_RIGHT] = band.Left;
 
-                     break;
 
-                 default:
 
-                     break;
 
-             }
 
-             // 3. set sub-bands
 
-             if (bandNode[JV.BAND_PROP_SUB_BANDS]) {
 
-                 const bandArea = [band.Left, band.Top, band.Right, band.Bottom];
 
-                 for (let i = 0; i < bandNode[JV.BAND_PROP_SUB_BANDS].length; i++) {
 
-                     me.setBandPos(bands, bandNode[JV.BAND_PROP_SUB_BANDS][i], bandArea, unitFactor, pageStatus, isOnlyNormalStatus, isOnlyExStatus);
 
-                 }
 
-             }
 
-         }
 
-     },
 
-     resetBandPos: function(bandCollection, bands, contentBand, offsetX, offsetY) {
 
-         const orgX = contentBand.Right;
 
-         const orgY = contentBand.Bottom;
 
-         function chkAndResetPos(targetBand) {
 
-             const band = bands[targetBand.Name];
 
-             if (band) {
 
-                 if (band === contentBand) {
 
-                     band.Bottom += offsetY;
 
-                     band.Right += offsetX;
 
-                 } else {
 
-                     if (band.Top >= orgY) {
 
-                         band.Top += offsetY;
 
-                         band.Bottom += offsetY;
 
-                     } else if (band.Bottom >= orgY && band.Top < orgY) {
 
-                         band.Bottom += offsetY;
 
-                     }
 
-                     if (band.Left >= orgX) {
 
-                         band.Left += offsetX;
 
-                         band.Right += offsetX;
 
-                     } else if (band.Right >= orgX && band.Le < orgX) {
 
-                         band.Right += offsetX;
 
-                     }
 
-                 }
 
-                 if (targetBand[JV.BAND_PROP_SUB_BANDS]) {
 
-                     for (let i = 0; i < targetBand[JV.BAND_PROP_SUB_BANDS].length; i++) {
 
-                         chkAndResetPos(targetBand[JV.BAND_PROP_SUB_BANDS][i]);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         for (let i = 0; i < bandCollection.length; i++) {
 
-             chkAndResetPos(bandCollection[i]);
 
-         }
 
-     },
 
- };
 
- module.exports = JpcBandHelper;
 
 
  |