SmartBI.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.SmartBI = MWF.FCSmartBI = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/SmartBI/smartbi.html"
  9. },
  10. initialize: function (form, options) {
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/SmartBI/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/SmartBI/" + this.options.style + "/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "container";
  16. this.moduleName = "SmartBI";
  17. this.Node = null;
  18. this.form = form;
  19. },
  20. _createMoveNode: function () {
  21. this.moveNode = new Element("div", {
  22. "MWFType": "SmartBI",
  23. "id": this.json.id,
  24. "styles": this.css.moduleNodeMove,
  25. "events": {
  26. "selectstart": function () {
  27. return false;
  28. }
  29. }
  30. }).inject(this.form.container);
  31. },
  32. _setEditStyle: function (name) {
  33. this.BIOptions = {
  34. "showtoolbar": this.json.smartbidisplaytoolbar || false, //showtoolbar对应SmartBI系统中的参数名
  35. "showLeftTree": this.json.smartbidisplaylefttree || false //即席查询是否显示左侧树形
  36. }
  37. if (name == "smartbiresource") {
  38. var value = this.json.smartbiresource || "none";
  39. if (value == "" || value == "none") {
  40. this.setNodeContainer()
  41. } else {
  42. this.createIframeNode(value, this.BIOptions)
  43. }
  44. }
  45. if (name == "smartbidisplaytoolbar") {
  46. if (this.json.smartbiresource && this.json.smartbiresource !== "none") {
  47. this.createIframeNode(this.json.smartbiresource, this.BIOptions)
  48. }
  49. }
  50. if (name == "smartbidisplaylefttree") {
  51. if (this.json.smartbiresource && this.json.smartbiresource !== "none") {
  52. this.createIframeNode(this.json.smartbiresource, this.BIOptions)
  53. }
  54. }
  55. },
  56. _loadNodeStyles: function () {
  57. var _iframe = this.node.getElements("iframe");
  58. if (_iframe.length > 0) {
  59. _iframe[0].setStyles(this.css.iframe)
  60. }
  61. },
  62. createIframeNode: function (id, options) {
  63. var value = id;
  64. var SmartBIAction = o2.Actions.load("x_custom_smartbi_assemble_control");
  65. var addressUri = SmartBIAction.ResourceAction.address;
  66. if(addressUri){
  67. SmartBIAction.ResourceAction.address(value,function(json){
  68. if(json.data.value !==""){
  69. var url = json.data.value;
  70. if (options) {
  71. var paraString = "";
  72. for (var key in options) {
  73. paraString = paraString + "&" + key + "=" + options[key]
  74. }
  75. url = url + paraString
  76. }
  77. url = o2.filterUrl(url);
  78. this.node.empty();
  79. new Element("iframe", {
  80. src: url,
  81. styles: this.css.iframe,
  82. frameborder: "0",
  83. scrolling: "auto"
  84. }).inject(this.node);
  85. }
  86. }.bind(this))
  87. }else{
  88. var address = SmartBIAction.ResourceAction.action.getAddress();
  89. var uri = SmartBIAction.ResourceAction.action.actions.open.uri;
  90. var url = uri.replace("{id}", encodeURIComponent(value));
  91. if(options){
  92. var paraString = "";
  93. for(var key in options){
  94. paraString = paraString + "&" + key + "=" + options[key]
  95. }
  96. url = url + "?"+paraString
  97. }
  98. url = o2.filterUrl(address+url);
  99. this.node.empty();
  100. new Element("iframe",{src:url,styles:this.css.iframe,frameborder:"0",scrolling:"auto"}).inject(this.node);
  101. }
  102. },
  103. _createNode: function () {
  104. this.node = this.moveNode.clone(true, true);
  105. this.node.setStyles(this.css.moduleNode);
  106. this.node.set("id", this.json.id);
  107. this.node.addEvent("selectstart", function () {
  108. return false;
  109. });
  110. },
  111. _resetModuleDomNode: function () {
  112. this.setNodeContainer();
  113. },
  114. setNodeContainer: function () {
  115. this.node.empty();
  116. this.nodeContainer = new Element("div", {
  117. styles: this.css.nodeContainer
  118. }).inject(this.node);
  119. this.nodeIcon = new Element("div", {
  120. "styles": this.css.nodeIcon
  121. }).inject(this.nodeContainer);
  122. if (!layout.serviceAddressList["x_custom_smartbi_assemble_control"]) {
  123. new Element("div", {
  124. styles: this.css.nodeTxt,
  125. text: MWF.APPFD.LP.smartbi.nosetup
  126. }).inject(this.nodeContainer);
  127. } else {
  128. var t = new Element("div", {
  129. styles: this.css.nodeTxt,
  130. text: MWF.APPFD.LP.smartbi.txt
  131. }).inject(this.nodeContainer);
  132. t.setStyles({
  133. "color": "#409EFF"
  134. });
  135. }
  136. }
  137. });