jpc_band.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. let JV = require('./jpc_value_define');
  2. let JpcCommonHelper = require('./helper/jpc_helper_common');
  3. let JpcBandHelper = require('./helper/jpc_helper_band');
  4. let JpcBand = {
  5. createNew: function(rptTpl, defProperties) {
  6. let me = this;
  7. let JpcBandResult = {};
  8. if (rptTpl[JV.NODE_BAND_COLLECTION]) {
  9. for (let i = 0; i < rptTpl[JV.NODE_BAND_COLLECTION].length; i++) {
  10. me.createSingle(rptTpl[JV.NODE_BAND_COLLECTION][i], JpcBandResult, rptTpl, defProperties);
  11. }
  12. }
  13. return JpcBandResult;
  14. },
  15. createSingle: function(bandNode, parentObj, rptTpl, defProperties) {
  16. let me = this;
  17. if (bandNode && bandNode[JV.BAND_PROP_NAME]) {
  18. let item = {Left:0, Right:0, Top:0, Bottom:0};
  19. item[JV.BAND_PROP_STYLE] = JpcCommonHelper.getStyle(bandNode[JV.BAND_PROP_STYLE], defProperties.styles, null);
  20. item[JV.BAND_PROP_CONTROL] = JpcCommonHelper.getControl(bandNode[JV.BAND_PROP_CONTROL], defProperties.ctrls, null);
  21. if (bandNode[JV.BAND_PROP_HEIGHT]) {
  22. item[JV.BAND_PROP_HEIGHT] = 1.0 * bandNode[JV.BAND_PROP_HEIGHT];
  23. } else {
  24. item[JV.BAND_PROP_HEIGHT] = 0.0;
  25. }
  26. if (bandNode[JV.BAND_PROP_WIDTH]) {
  27. item[JV.BAND_PROP_WIDTH] = 1.0 * bandNode[JV.BAND_PROP_WIDTH];
  28. } else {
  29. item[JV.BAND_PROP_WIDTH] = 0.0;
  30. }
  31. item[JV.BAND_PROP_DISPLAY_TYPE] = JpcBandHelper.getBandTypeValByString(bandNode[JV.BAND_PROP_DISPLAY_TYPE]);
  32. item[JV.BAND_PROP_ALIGNMENT] = JpcCommonHelper.getLayoutAlignment(bandNode[JV.BAND_PROP_ALIGNMENT]);
  33. item[JV.PROP_CALCULATION] = JpcCommonHelper.getPosCalculationType(bandNode[JV.PROP_CALCULATION]);
  34. if (bandNode.hasOwnProperty(JV.PROP_BAND_NORMAL_ONLY)) {
  35. item[JV.PROP_BAND_NORMAL_ONLY] = JpcCommonHelper.getBoolean(bandNode[JV.PROP_BAND_NORMAL_ONLY]);
  36. }
  37. if (bandNode.hasOwnProperty(JV.PROP_BAND_EX_ONLY)) {
  38. item[JV.PROP_BAND_EX_ONLY] = JpcCommonHelper.getBoolean(bandNode[JV.PROP_BAND_EX_ONLY]);
  39. }
  40. if (bandNode[JV.BAND_PROP_MERGE_BORDER]) {
  41. item[JV.BAND_PROP_MERGE_BORDER] = bandNode[JV.BAND_PROP_MERGE_BORDER];
  42. }
  43. if (bandNode[JV.BAND_PROP_SUB_BANDS]) {
  44. for (let i = 0; i < bandNode[JV.BAND_PROP_SUB_BANDS].length; i++) {
  45. me.createSingle(bandNode[JV.BAND_PROP_SUB_BANDS][i], parentObj, rptTpl, defProperties);
  46. }
  47. }
  48. parentObj[bandNode[JV.BAND_PROP_NAME]] = item;
  49. if (item[JV.BAND_PROP_MERGE_BORDER] !== null && item[JV.BAND_PROP_MERGE_BORDER] !== undefined && item[JV.BAND_PROP_MERGE_BORDER] === 'T') {
  50. parentObj[JV.BAND_PROP_MERGE_BAND] = item;
  51. }
  52. }
  53. }
  54. };
  55. module.exports = JpcBand;