Log.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.Log = MWF.FCLog = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Log/log.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Log/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Log/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "log";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. load : function(json, node, parent){
  22. this.json = json;
  23. this.node= node;
  24. this.node.store("module", this);
  25. //this.node.empty();
  26. this.node.setStyles(this.css.moduleNode);
  27. this.node.set("data-mwf-el-type", "MWFFormDesignerLog");
  28. this._loadNodeStyles();
  29. this._initModule();
  30. this._loadTreeNode(parent);
  31. this.setCustomStyles();
  32. this.parentContainer = this.treeNode.parentNode.module;
  33. this._setEditStyle_custom("id");
  34. this.parseModules();
  35. this.json.moduleName = this.moduleName;
  36. },
  37. clearTemplateStyles: function(styles){
  38. if (this.json.templateType) {
  39. if (styles) {
  40. if (styles[this.json.templateType]){
  41. if (styles[this.json.templateType].styles) this.removeStyles(styles[this.json.templateType].styles, "styles");
  42. if (styles[this.json.templateType].properties) this.removeStyles(styles[this.json.templateType].properties, "properties");
  43. }
  44. }
  45. }
  46. },
  47. setTemplateStyles: function(styles){
  48. if (this.json.templateType){
  49. if (styles[this.json.templateType]){
  50. var t = styles[this.json.templateType];
  51. if (t.styles) this.copyStyles(t.styles, "styles");
  52. if (t.properties) this.copyStyles(t.properties, "properties");
  53. if (t.textStyle) this.json.textStyle = t.textStyle;
  54. if (t.textTaskStyle) this.json.textTaskStyle = t.textTaskStyle;
  55. if (t.mode) this.json.mode = t.mode;
  56. }
  57. }
  58. },
  59. _createMoveNode: function(){
  60. this.moveNode = new Element("div", {
  61. "MWFType": "log",
  62. "id": this.json.id,
  63. "styles": this.css.moduleNodeMove,
  64. "events": {
  65. "selectstart": function(){
  66. return false;
  67. }
  68. }
  69. }).inject(this.form.container);
  70. },
  71. _createNode: function(){
  72. this.node = this.moveNode.clone(true, true);
  73. this.node.setStyles(this.css.moduleNode);
  74. this.node.set("id", this.json.id);
  75. this.node.set("data-mwf-el-type", "MWFFormDesignerLog");
  76. this.node.addEvent("selectstart", function(){
  77. return false;
  78. });
  79. this._createIcon();
  80. },
  81. _createIcon: function(){
  82. this.iconNode = new Element("div", {
  83. "styles": this.css.iconNode
  84. }).inject(this.node);
  85. new Element("div", {
  86. "styles": this.css.iconNodeIcon
  87. }).inject(this.iconNode);
  88. new Element("div", {
  89. "styles": this.css.iconNodeText,
  90. "text": "LOG"
  91. }).inject(this.iconNode);
  92. },
  93. _loadNodeStyles: function(){
  94. this.iconNode = this.node.getElement("div").setStyles(this.css.iconNode);
  95. this.iconNode.getFirst("div").setStyles(this.css.iconNodeIcon);
  96. this.iconNode.getLast("div").setStyles(this.css.iconNodeText);
  97. },
  98. // _preprocessingModuleData: function(){
  99. // this.node.clearStyles();
  100. // this.json.recoveryStyles = Object.clone(this.json.styles);
  101. // if (this.json.recoveryStyles) Object.each(this.json.recoveryStyles, function(value, key){
  102. // if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  103. // //需要运行时处理
  104. // }else{
  105. // this.node.setStyle(key, value);
  106. // delete this.json.styles[key];
  107. // }
  108. // }.bind(this));
  109. // this.node.empty();
  110. // this.json.preprocessing = "y";
  111. // },
  112. // _recoveryModuleData: function(){
  113. // if (this.json.recoveryStyles) this.json.styles = this.json.recoveryStyles;
  114. // this.json.recoveryStyles = null;
  115. // this._createIcon();
  116. // }
  117. _setEditStyle_custom: function(name, obj, oldValue){
  118. if (name=="templateType"){
  119. if (this.form.templateStyles){
  120. var moduleStyles = this.form.templateStyles[this.moduleName];
  121. if (moduleStyles) {
  122. if (oldValue){
  123. if (moduleStyles[oldValue]){
  124. this.removeStyles(moduleStyles[oldValue].styles, "styles");
  125. this.removeStyles(moduleStyles[oldValue].styles, "properties");
  126. }
  127. }
  128. if (moduleStyles[this.json.templateType]){
  129. var t = moduleStyles[this.json.templateType];
  130. if (t.styles) this.copyStyles(t.styles, "styles");
  131. if (t.styles) this.copyStyles(t.properties, "properties");
  132. if (t.textStyle) this.json.textStyle = t.textStyle;
  133. if (t.textTaskStyle) this.json.textTaskStyle = t.textTaskStyle;
  134. if (t.mode) this.json.mode = t.mode;
  135. this._setHtmlAreaValue("textStyle");
  136. this._setHtmlAreaValue("textTaskStyle");
  137. var node = this.property.propertyContent.querySelector("input[name$='mode'][value='"+this.json.mode+"']");
  138. if (node){
  139. node.checked = true;
  140. }
  141. }
  142. this.setPropertiesOrStyles("styles");
  143. this.setPropertiesOrStyles("properties");
  144. this.reloadMaplist();
  145. }
  146. }
  147. }
  148. },
  149. _setHtmlAreaValue: function(name){
  150. var node = this.property.propertyContent.querySelector(".MWFHtmlEditorArea[name='"+name+"']");
  151. if (node.htmlArea.jsEditor){
  152. node.htmlArea.jsEditor.setValue(this.json.textStyle);
  153. }else{
  154. node.htmlArea.htmlContentData.code = this.json.textStyle;
  155. }
  156. }
  157. });