12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- let JV = require('./jpc_value_define');
- let JpcCommonHelper = require('./helper/jpc_helper_common');
- let JpcBandHelper = require('./helper/jpc_helper_band');
- let JpcBand = {
- createNew: function(rptTpl, defProperties) {
- let me = this;
- let JpcBandResult = {};
- if (rptTpl[JV.NODE_BAND_COLLECTION]) {
- for (let i = 0; i < rptTpl[JV.NODE_BAND_COLLECTION].length; i++) {
- me.createSingle(rptTpl[JV.NODE_BAND_COLLECTION][i], JpcBandResult, rptTpl, defProperties);
- }
- }
- return JpcBandResult;
- },
- createSingle: function(bandNode, parentObj, rptTpl, defProperties) {
- let me = this;
- if (bandNode && bandNode[JV.BAND_PROP_NAME]) {
- let item = {Left:0, Right:0, Top:0, Bottom:0};
- item[JV.BAND_PROP_STYLE] = JpcCommonHelper.getStyle(bandNode[JV.BAND_PROP_STYLE], defProperties.styles, null);
- item[JV.BAND_PROP_CONTROL] = JpcCommonHelper.getControl(bandNode[JV.BAND_PROP_CONTROL], defProperties.ctrls, null);
- if (bandNode[JV.BAND_PROP_HEIGHT]) {
- item[JV.BAND_PROP_HEIGHT] = 1.0 * bandNode[JV.BAND_PROP_HEIGHT];
- } else {
- item[JV.BAND_PROP_HEIGHT] = 0.0;
- }
- if (bandNode[JV.BAND_PROP_WIDTH]) {
- item[JV.BAND_PROP_WIDTH] = 1.0 * bandNode[JV.BAND_PROP_WIDTH];
- } else {
- item[JV.BAND_PROP_WIDTH] = 0.0;
- }
- item[JV.BAND_PROP_DISPLAY_TYPE] = JpcBandHelper.getBandTypeValByString(bandNode[JV.BAND_PROP_DISPLAY_TYPE]);
- item[JV.BAND_PROP_ALIGNMENT] = JpcCommonHelper.getLayoutAlignment(bandNode[JV.BAND_PROP_ALIGNMENT]);
- item[JV.PROP_CALCULATION] = JpcCommonHelper.getPosCalculationType(bandNode[JV.PROP_CALCULATION]);
- if (bandNode.hasOwnProperty(JV.PROP_BAND_NORMAL_ONLY)) {
- item[JV.PROP_BAND_NORMAL_ONLY] = JpcCommonHelper.getBoolean(bandNode[JV.PROP_BAND_NORMAL_ONLY]);
- }
- if (bandNode.hasOwnProperty(JV.PROP_BAND_EX_ONLY)) {
- item[JV.PROP_BAND_EX_ONLY] = JpcCommonHelper.getBoolean(bandNode[JV.PROP_BAND_EX_ONLY]);
- }
- if (bandNode[JV.BAND_PROP_MERGE_BORDER]) {
- item[JV.BAND_PROP_MERGE_BORDER] = bandNode[JV.BAND_PROP_MERGE_BORDER];
- }
- if (bandNode[JV.BAND_PROP_SUB_BANDS]) {
- for (let i = 0; i < bandNode[JV.BAND_PROP_SUB_BANDS].length; i++) {
- me.createSingle(bandNode[JV.BAND_PROP_SUB_BANDS][i], parentObj, rptTpl, defProperties);
- }
- }
- parentObj[bandNode[JV.BAND_PROP_NAME]] = item;
- if (item[JV.BAND_PROP_MERGE_BORDER] !== null && item[JV.BAND_PROP_MERGE_BORDER] !== undefined && item[JV.BAND_PROP_MERGE_BORDER] === 'T') {
- parentObj[JV.BAND_PROP_MERGE_BAND] = item;
- }
- }
- }
- };
- module.exports = JpcBand;
|