jpc_band.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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(
  11. rptTpl[JV.NODE_BAND_COLLECTION][i],
  12. JpcBandResult,
  13. rptTpl,
  14. defProperties
  15. );
  16. }
  17. }
  18. return JpcBandResult;
  19. },
  20. createSingle: function (bandNode, parentObj, rptTpl, defProperties) {
  21. let me = this;
  22. if (bandNode && bandNode[JV.BAND_PROP_NAME]) {
  23. let item = { Left: 0, Right: 0, Top: 0, Bottom: 0 };
  24. item[JV.BAND_PROP_STYLE] = JpcCommonHelper.getStyle(
  25. bandNode[JV.BAND_PROP_STYLE],
  26. defProperties.styles,
  27. null
  28. );
  29. item[JV.BAND_PROP_CONTROL] = JpcCommonHelper.getControl(
  30. bandNode[JV.BAND_PROP_CONTROL],
  31. defProperties.ctrls,
  32. null
  33. );
  34. if (bandNode[JV.BAND_PROP_HEIGHT]) {
  35. item[JV.BAND_PROP_HEIGHT] = 1.0 * bandNode[JV.BAND_PROP_HEIGHT];
  36. } else {
  37. item[JV.BAND_PROP_HEIGHT] = 0.0;
  38. }
  39. if (bandNode[JV.BAND_PROP_WIDTH]) {
  40. item[JV.BAND_PROP_WIDTH] = 1.0 * bandNode[JV.BAND_PROP_WIDTH];
  41. } else {
  42. item[JV.BAND_PROP_WIDTH] = 0.0;
  43. }
  44. item[JV.BAND_PROP_DISPLAY_TYPE] = JpcBandHelper.getBandTypeValByString(
  45. bandNode[JV.BAND_PROP_DISPLAY_TYPE]
  46. );
  47. item[JV.BAND_PROP_ALIGNMENT] = JpcCommonHelper.getLayoutAlignment(
  48. bandNode[JV.BAND_PROP_ALIGNMENT]
  49. );
  50. item[JV.PROP_CALCULATION] = JpcCommonHelper.getPosCalculationType(
  51. bandNode[JV.PROP_CALCULATION]
  52. );
  53. if (bandNode.hasOwnProperty(JV.PROP_BAND_NORMAL_ONLY)) {
  54. item[JV.PROP_BAND_NORMAL_ONLY] = JpcCommonHelper.getBoolean(
  55. bandNode[JV.PROP_BAND_NORMAL_ONLY]
  56. );
  57. }
  58. if (bandNode.hasOwnProperty(JV.PROP_BAND_EX_ONLY)) {
  59. item[JV.PROP_BAND_EX_ONLY] = JpcCommonHelper.getBoolean(
  60. bandNode[JV.PROP_BAND_EX_ONLY]
  61. );
  62. }
  63. if (bandNode[JV.BAND_PROP_MERGE_BORDER]) {
  64. item[JV.BAND_PROP_MERGE_BORDER] = bandNode[JV.BAND_PROP_MERGE_BORDER];
  65. }
  66. if (bandNode[JV.BAND_PROP_SUB_BANDS]) {
  67. for (let i = 0; i < bandNode[JV.BAND_PROP_SUB_BANDS].length; i++) {
  68. me.createSingle(
  69. bandNode[JV.BAND_PROP_SUB_BANDS][i],
  70. parentObj,
  71. rptTpl,
  72. defProperties
  73. );
  74. }
  75. }
  76. parentObj[bandNode[JV.BAND_PROP_NAME]] = item;
  77. if (
  78. item[JV.BAND_PROP_MERGE_BORDER] !== null &&
  79. item[JV.BAND_PROP_MERGE_BORDER] !== undefined &&
  80. item[JV.BAND_PROP_MERGE_BORDER] === "T"
  81. ) {
  82. parentObj[JV.BAND_PROP_MERGE_BAND] = item;
  83. }
  84. }
  85. },
  86. };
  87. module.exports = JpcBand;