Main.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. MWF.xDesktop.requireApp("process.ViewDesigner", "", null, false);
  2. MWF.APPSTD = MWF.xApplication.process.StatDesigner;
  3. MWF.APPSTD.options = {
  4. "multitask": true,
  5. "executable": false
  6. };
  7. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", null, false);
  8. MWF.xDesktop.requireApp("process.StatDesigner", "Stat", null, false);
  9. MWF.xApplication.process.StatDesigner.Main = new Class({
  10. Extends: MWF.xApplication.process.ViewDesigner.Main,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "name": "process.StatDesigner",
  15. "icon": "icon.png",
  16. "title": MWF.APPSTD.LP.title,
  17. "appTitle": MWF.APPSTD.LP.title,
  18. "id": "",
  19. "tooltip": {
  20. "unCategory": MWF.APPSTD.LP.unCategory
  21. },
  22. "actions": null,
  23. "category": null,
  24. "processData": null
  25. },
  26. onQueryLoad: function(){
  27. this.shortcut = true;
  28. if (this.status){
  29. this.options.application = this.status.applicationId;
  30. this.application = this.status.application;
  31. this.options.id = this.status.id;
  32. }
  33. if (!this.options.id){
  34. this.options.desktopReload = false;
  35. this.options.title = this.options.title + "-"+MWF.APPSTD.LP.newStat;
  36. }
  37. if (!this.actions) this.actions = MWF.Actions.get("x_processplatform_assemble_designer");
  38. //if (!this.actions) this.actions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  39. this.lp = MWF.xApplication.process.StatDesigner.LP;
  40. this.addEvent("queryClose", function(e){
  41. if (this.explorer){
  42. this.explorer.reload();
  43. }
  44. }.bind(this));
  45. this.addEvent("postLoadWindowMax", function(e){
  46. this.loadWindowOk = true;
  47. if (this.loadApplicationOk && this.loadWindowOk) this.view.setViewWidth();
  48. }.bind(this));
  49. this.addEvent("postLoadApplication", function(e){
  50. this.loadApplicationOk = true;
  51. if (this.loadApplicationOk && this.loadWindowOk) this.view.setViewWidth();
  52. }.bind(this));
  53. },
  54. loadViewList: function(){
  55. this.actions.listStat(this.application.id, function (json) {
  56. json.data.each(function(view){
  57. this.createListViewItem(view);
  58. }.bind(this));
  59. }.bind(this), null, false);
  60. },
  61. //列示所有视图列表
  62. createListViewItem: function(view, isNew){
  63. var _self = this;
  64. var listViewItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  65. var listViewItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listViewItem);
  66. var listViewItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (view.name) ? view.name+" ("+view.alias+")" : this.lp.newStat}).inject(listViewItem);
  67. listViewItem.store("view", view);
  68. listViewItem.addEvents({
  69. "dblclick": function(e){_self.loadViewByData(this, e);},
  70. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  71. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  72. });
  73. },
  74. //打开视图
  75. loadViewByData: function(node, e){
  76. var view = node.retrieve("view");
  77. if (openNew){
  78. var _self = this;
  79. var options = {
  80. "onQueryLoad": function(){
  81. this.actions = _self.actions;
  82. this.category = _self;
  83. this.options.id = view.id;
  84. this.application = _self.application;
  85. this.explorer = _self.explorer;
  86. }
  87. };
  88. this.desktop.openApplication(e, "process.StatDesigner", options);
  89. }
  90. },
  91. //loadView------------------------------------------
  92. loadView: function(){
  93. this.getViewData(this.options.id, function(vdata){
  94. this.setTitle(this.options.appTitle + "-"+vdata.name);
  95. this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  96. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  97. this.view = new MWF.xApplication.process.StatDesigner.Stat(this, vdata);
  98. this.view.load();
  99. }.bind(this));
  100. },
  101. loadNewViewData: function(callback){
  102. var url = "/x_component_process_StatDesigner/$Stat/stat.json";
  103. MWF.getJSON(url, {
  104. "onSuccess": function(obj){
  105. this.actions.getUUID(function(id){
  106. obj.id=id;
  107. obj.isNewView = true;
  108. obj.application = this.application.id;
  109. this.createListViewItem(obj, true);
  110. if (callback) callback(obj);
  111. }.bind(this));
  112. }.bind(this),
  113. "onerror": function(text){
  114. this.notice(text, "error");
  115. }.bind(this),
  116. "onRequestFailure": function(xhr){
  117. this.notice(xhr.responseText, "error");
  118. }.bind(this)
  119. });
  120. },
  121. loadViewData: function(id, callback){
  122. this.actions.getStat(id, function(json){
  123. if (json){
  124. var data = json.data;
  125. var dataJson = JSON.decode(data.data);
  126. data.data = dataJson;
  127. if (!this.application){
  128. this.actions.getApplication(data.application, function(json){
  129. this.application = {"name": json.data.name, "id": json.data.id};
  130. if (callback) callback(data);
  131. }.bind(this));
  132. }else{
  133. if (callback) callback(data);
  134. }
  135. }
  136. }.bind(this));
  137. },
  138. saveView: function(){
  139. this.view.save(function(){
  140. var name = this.view.data.name;
  141. this.setTitle(MWF.APPSTD.LP.title + "-"+name);
  142. this.options.desktopReload = true;
  143. this.options.id = this.view.data.id;
  144. }.bind(this));
  145. },
  146. saveDictionaryAs: function(){
  147. this.view.saveAs();
  148. },
  149. dictionaryExplode: function(){
  150. this.view.explode();
  151. },
  152. dictionaryImplode: function(){
  153. this.view.implode();
  154. }
  155. //recordStatus: function(){
  156. // return {"id": this.options.id};
  157. //},
  158. });