Main.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. debugger;
  21. this.lp = MWF.xApplication.portal.Portal.LP;
  22. if (this.status){
  23. this.options.portalId = this.status.portalId;
  24. this.options.pageId = this.status.pageId;
  25. }
  26. },
  27. loadApplication: function(callback){
  28. this.node = new Element("div", {"styles": this.css.content}).inject(this.content);
  29. //MWF.require("MWF.widget.Mask", function(){
  30. //this.mask = new MWF.widget.Mask({"style": "desktop"});
  31. this.formNode = new Element("div", {"styles": {"min-height": "100%", "font-size": "14px"}}).inject(this.node);
  32. this.action = MWF.Actions.get("x_portal_assemble_surface");
  33. //MWF.xDesktop.requireApp("portal.Portal", "Actions.RestActions", function(){
  34. // this.action = new MWF.xApplication.portal.Portal.Actions.RestActions();
  35. if (!this.options.isRefresh){
  36. this.maxSize(function(){
  37. //this.mask.loadNode(this.content);
  38. this.loadPortal(this.options.parameters);
  39. }.bind(this));
  40. }else{
  41. //this.mask.loadNode(this.content);
  42. this.loadPortal(this.options.parameters);
  43. }
  44. if (callback) callback();
  45. //}.bind(this));
  46. //}.bind(this));
  47. },
  48. //reload: function(data){
  49. // if (this.form){
  50. // this.formNode.empty();
  51. // MWF.release(this.form);
  52. // this.form = null;
  53. // }
  54. // //this.parseData(data);
  55. // this.openPortal();
  56. //},
  57. toPortal: function(portal, page, par){
  58. this.options.portalId = portal;
  59. this.options.pageId = page;
  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. var page = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  73. if (page){
  74. this.options.pageId = json.data.id;
  75. MWF.release(this.appForm);
  76. this.appForm = null;
  77. this.formNode.empty();
  78. this.page = page;
  79. this.openPortal(par);
  80. }
  81. }.bind(this));
  82. }else{
  83. if (this.options.pageId){
  84. var m = (layout.mobile) ? "getPageByNameMobile" : "getPageByName";
  85. this.action[m](this.options.pageId, this.portal.id, function(json){
  86. var page = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  87. if (page){
  88. this.options.pageId = json.data.id;
  89. MWF.release(this.appForm);
  90. this.appForm = null;
  91. this.formNode.empty();
  92. this.page = page;
  93. this.openPortal(par);
  94. }
  95. }.bind(this));
  96. }
  97. }
  98. },
  99. loadPortal: function(par){
  100. this.action.getApplication(this.options.portalId, function(json){
  101. this.portal = json.data;
  102. this.setTitle(this.portal.name);
  103. if (!this.options.pageId) this.options.pageId = this.portal.firstPage;
  104. if (this.portal.icon){
  105. if (this.taskitem){
  106. this.taskitem.iconNode.setStyles({
  107. "background-image": "url(data:image/png;base64,"+this.portal.icon+")",
  108. "background-size": "24px 24px"
  109. });
  110. }
  111. }
  112. var m = (layout.mobile) ? "getPageByNameMobile" : "getPageByName";
  113. this.action[m](this.options.pageId, this.options.portalId, function(json){
  114. // if (layout.mobile) {
  115. // this.page = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
  116. // if (!this.page || !this.page.json.moduleList.length){
  117. // this.page = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  118. // }
  119. // }else{
  120. this.page = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  121. // }
  122. this.openPortal(par);
  123. }.bind(this));
  124. }.bind(this));
  125. },
  126. openPortal: function(par){
  127. debugger;
  128. if (this.page){
  129. MWF.xDesktop.requireApp("process.Xform", "Form", function(){
  130. this.appForm = new MWF.APPForm(this.formNode, this.page, {
  131. "macro": "PageContext",
  132. "parameters": par
  133. });
  134. this.appForm.businessData = {
  135. "control": {
  136. "allowSave": true
  137. },
  138. "data": {}
  139. };
  140. this.appForm.workAction = this.action;
  141. this.appForm.app = this;
  142. this.appForm.load();
  143. if (this.mask) this.mask.hide();
  144. }.bind(this));
  145. }
  146. },
  147. recordStatus: function(){
  148. return {"portalId": this.options.portalId, "pageId": this.options.pageId};
  149. },
  150. onPostClose: function(){
  151. if (this.appForm){
  152. this.appForm.modules.each(function(module){
  153. MWF.release(module);
  154. });
  155. MWF.release(this.appForm);
  156. }
  157. }
  158. });