Documenteditor.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.Documenteditor = MWF.FCDocumenteditor = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Documenteditor/documenteditor.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Documenteditor/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Documenteditor/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "documenteditor";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "documenteditor",
  24. "id": this.json.id,
  25. "styles": this.css.moduleNodeMove,
  26. "events": {
  27. "selectstart": function(){
  28. return false;
  29. }
  30. }
  31. }).inject(this.form.container);
  32. },
  33. _createNode: function(){
  34. this.node = this.moveNode.clone(true, true);
  35. this.node.setStyles(this.css.moduleNode);
  36. this.node.set("id", this.json.id);
  37. this.node.addEvent("selectstart", function(e){
  38. e.preventDefault();
  39. });
  40. },
  41. _setEditStyle_custom: function(name, obj, oldValue){
  42. if (name=="documentTempleteType"){
  43. if (this.json.documentTempleteType!=oldValue){
  44. this._resetContent();
  45. }
  46. }
  47. if (name=="documentTempleteUrl"){
  48. if (this.json.documentTempleteUrl!=oldValue){
  49. this._resetContent();
  50. }
  51. }
  52. if (name=="documentTempleteName"){
  53. if (this.json.documentTempleteName!=oldValue){
  54. this._resetContent();
  55. }
  56. }
  57. },
  58. // _setEditStyle_custom: function(name){
  59. // },
  60. _resetContent: function(){
  61. if (!this.json.documentTempleteType) this.json.documentTempleteType = "sys";
  62. if (!this.json.documentTempleteName) this.json.documentTempleteName = "standard";
  63. this.node.empty();
  64. var pageNode = new Element("div.doc_layout_page", {"styles": this.css.doc_page}).inject(this.node);
  65. var pageContentNode = new Element("div.doc_layout_page_content", {"styles": this.css.doc_layout_page_content}).inject(pageNode);
  66. if (this.json.documentTempleteType=="cus" && this.json.documentTempleteUrl){
  67. pageContentNode.loadHtml(o2.filterUrl(this.json.documentTempleteUrl), function(){
  68. // if (this.attachmentTemplete){
  69. // var attNode = pageContentNode.getElement(".doc_layout_attachment_content");
  70. // if (attNode) attNode.empty();
  71. // }
  72. // if (callback) callback(control);
  73. }.bind(this));
  74. }else{
  75. o2.getJSON(o2.filterUrl("../x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json"), function(json){
  76. var o = json[this.json.documentTempleteName];
  77. if (o){
  78. pageContentNode.loadHtml(o2.filterUrl("../x_component_process_FormDesigner/Module/Documenteditor/templete/"+o.file), function(){
  79. // if (this.attachmentTemplete){
  80. // var attNode = pageContentNode.getElement(".doc_layout_attachment_content");
  81. // if (attNode) attNode.empty();
  82. // }
  83. // if (callback) callback(control);
  84. }.bind(this));
  85. }
  86. }.bind(this));
  87. }
  88. },
  89. _initModule: function(){
  90. this._resetContent();
  91. var templateJson = this.form.dataTemplate["Documenteditor"];
  92. if (!templateJson){
  93. var templateUrl = o2.filterUrl("../x_component_process_FormDesigner/Module/Documenteditor/template.json");
  94. templateJson = MWF.getJSON(templateUrl, null, false);
  95. }
  96. if (templateJson) this.json.defaultValue = Object.merge(templateJson.defaultValue, this.json.defaultValue);
  97. this._setNodeProperty();
  98. if (!this.form.isSubform) this._createIconAction() ;
  99. this._setNodeEvent();
  100. },
  101. _preprocessingModuleData: function(){
  102. this.node.clearStyles();
  103. this.json.recoveryStyles = Object.clone(this.json.styles);
  104. if (this.json.recoveryStyles) Object.each(this.json.recoveryStyles, function(value, key){
  105. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  106. //需要运行时处理
  107. }else{
  108. this.node.setStyle(key, value);
  109. delete this.json.styles[key];
  110. }
  111. }.bind(this));
  112. // var size = this.node.getSize();
  113. this.node.empty();
  114. //this.node.getFirst().getFirst().empty();
  115. //this.node.setStyles(this.css.documentEditorNode);
  116. this.json.preprocessing = "y";
  117. },
  118. _recoveryModuleData: function(){
  119. if (this.json.recoveryStyles) this.json.styles = this.json.recoveryStyles;
  120. this.json.recoveryStyles = null;
  121. this.node.empty();
  122. this._resetContent();
  123. }
  124. });