Main.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. MWF.xApplication.portal.Portal.options.multitask = true;
  2. MWF.xApplication.portal.Portal.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "name": "portal.Portal",
  8. "icon": "icon.png",
  9. "width": "1200",
  10. "height": "800",
  11. "title": MWF.xApplication.portal.Portal.LP.title,
  12. "portalId": "",
  13. "pageId": "",
  14. "isControl": false,
  15. "taskObject": null,
  16. "parameters": "",
  17. "readonly": false
  18. },
  19. onQueryLoad: function(){
  20. this.lp = MWF.xApplication.portal.Portal.LP;
  21. if (this.status){
  22. this.options.portalId = this.status.portalId;
  23. this.options.pageId = this.status.pageId;
  24. }
  25. },
  26. loadApplication: function(callback){
  27. this.node = new Element("div", {"styles": this.css.content}).inject(this.content);
  28. //MWF.require("MWF.widget.Mask", function(){
  29. //this.mask = new MWF.widget.Mask({"style": "desktop"});
  30. this.formNode = new Element("div", {"styles": {"min-height": "100%", "font-size": "14px"}}).inject(this.node);
  31. this.action = MWF.Actions.get("x_portal_assemble_surface");
  32. //MWF.xDesktop.requireApp("portal.Portal", "Actions.RestActions", function(){
  33. // this.action = new MWF.xApplication.portal.Portal.Actions.RestActions();
  34. if (!this.options.isRefresh){
  35. this.maxSize(function(){
  36. //this.mask.loadNode(this.content);
  37. this.loadPortal(this.options.parameters, callback);
  38. }.bind(this));
  39. }else {
  40. //this.mask.loadNode(this.content);
  41. this.loadPortal(this.options.parameters, callback);
  42. }
  43. if (callback) callback();
  44. //}.bind(this));
  45. //}.bind(this));
  46. },
  47. //reload: function(data){
  48. // if (this.form){
  49. // this.formNode.empty();
  50. // MWF.release(this.form);
  51. // this.form = null;
  52. // }
  53. // //this.parseData(data);
  54. // this.openPortal();
  55. //},
  56. toPortal: function(portal, page, par){
  57. this.options.portalId = portal;
  58. this.options.pageId = page;
  59. if (this.appForm) this.appForm.fireEvent("beforeClose");
  60. Object.keys(this.$events).each(function(k){
  61. this.removeEvents(k);
  62. }.bind(this));
  63. MWF.release(this.appForm);
  64. this.appForm = null;
  65. this.formNode.empty();
  66. this.loadPortal(par);
  67. },
  68. toPage: function(name, par){
  69. if (name){
  70. var m = (layout.mobile) ? "getPageByNameMobile" : "getPageByName";
  71. this.action[m](name, this.portal.id, function(json){
  72. this.pageInfor = json.data;
  73. this.setTitle(this.portal.name+"-"+json.data.name);
  74. var page = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  75. if (page){
  76. this.options.pageId = json.data.id;
  77. if (this.appForm) this.appForm.fireEvent("beforeClose");
  78. Object.keys(this.$events).each(function(k){
  79. this.removeEvents(k);
  80. }.bind(this));
  81. MWF.release(this.appForm);
  82. this.appForm = null;
  83. this.formNode.empty();
  84. this.page = page;
  85. this.openPortal(par);
  86. }
  87. }.bind(this));
  88. }else{
  89. if (this.options.pageId){
  90. var m = (layout.mobile) ? "getPageByNameMobile" : "getPageByName";
  91. this.action[m](this.options.pageId, this.portal.id, function(json){
  92. this.pageInfor = json.data;
  93. this.setTitle(this.portal.name+"-"+json.data.name);
  94. var page = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  95. if (page){
  96. this.options.pageId = json.data.id;
  97. if (this.appForm) this.appForm.fireEvent("beforeClose");
  98. Object.keys(this.$events).each(function(k){
  99. this.removeEvents(k);
  100. }.bind(this));
  101. MWF.release(this.appForm);
  102. this.appForm = null;
  103. this.formNode.empty();
  104. this.page = page;
  105. this.openPortal(par);
  106. }
  107. }.bind(this));
  108. }
  109. }
  110. },
  111. loadPortal: function(par, callback){
  112. this.action.getApplication(this.options.portalId, function(json){
  113. this.portal = json.data;
  114. this.setTitle(this.portal.name);
  115. if (!this.options.pageId) this.options.pageId = this.portal.firstPage;
  116. if (this.portal.icon){
  117. if (this.taskitem){
  118. this.taskitem.iconNode.setStyles({
  119. "background-image": "url(data:image/png;base64,"+this.portal.icon+")",
  120. "background-size": "24px 24px"
  121. });
  122. }
  123. }
  124. var m = (layout.mobile) ? "getPageByNameMobile" : "getPageByName";
  125. this.action[m](this.options.pageId, this.options.portalId, function(json){
  126. // if (layout.mobile) {
  127. // this.page = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
  128. // if (!this.page || !this.page.json.moduleList.length){
  129. // this.page = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  130. // }
  131. // }else{
  132. this.setTitle(this.portal.name+"-"+json.data.name);
  133. this.page = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  134. this.pageInfor = json.data;
  135. // }
  136. this.openPortal(par, callback);
  137. }.bind(this));
  138. }.bind(this));
  139. },
  140. openPortal: function(par, callback){
  141. if (this.page){
  142. MWF.xDesktop.requireApp("process.Xform", "Form", function(){
  143. this.appForm = new MWF.APPForm(this.formNode, this.page, {
  144. "macro": "PageContext",
  145. "parameters": par
  146. });
  147. this.appForm.businessData = {
  148. "control": {
  149. "allowSave": true
  150. },
  151. "pageInfor": this.pageInfor,
  152. "data": {}
  153. };
  154. this.appForm.workAction = this.action;
  155. this.appForm.app = this;
  156. this.appForm.load();
  157. if (callback) callback();
  158. if (this.mask) this.mask.hide();
  159. }.bind(this));
  160. }
  161. },
  162. recordStatus: function(){
  163. return {"portalId": this.options.portalId, "pageId": this.options.pageId};
  164. },
  165. onPostClose: function(){
  166. if (this.appForm){
  167. this.appForm.modules.each(function(module){
  168. MWF.release(module);
  169. });
  170. MWF.release(this.appForm);
  171. }
  172. }
  173. });