Main.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  38. this.lp = MWF.xApplication.process.StatDesigner.LP;
  39. this.addEvent("queryClose", function(e){
  40. if (this.explorer){
  41. this.explorer.reload();
  42. }
  43. }.bind(this));
  44. this.addEvent("postLoadWindowMax", function(e){
  45. this.loadWindowOk = true;
  46. if (this.loadApplicationOk && this.loadWindowOk) this.view.setViewWidth();
  47. }.bind(this));
  48. this.addEvent("postLoadApplication", function(e){
  49. this.loadApplicationOk = true;
  50. if (this.loadApplicationOk && this.loadWindowOk) this.view.setViewWidth();
  51. }.bind(this));
  52. },
  53. loadViewList: function(){
  54. this.actions.listStat(this.application.id, function (json) {
  55. json.data.each(function(view){
  56. this.createListViewItem(view);
  57. }.bind(this));
  58. }.bind(this), null, false);
  59. },
  60. //列示所有视图列表
  61. createListViewItem: function(view, isNew){
  62. var _self = this;
  63. var listViewItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  64. var listViewItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listViewItem);
  65. var listViewItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (view.name) ? view.name+" ("+view.alias+")" : this.lp.newStat}).inject(listViewItem);
  66. listViewItem.store("view", view);
  67. listViewItem.addEvents({
  68. "dblclick": function(e){_self.loadViewByData(this, e);},
  69. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  70. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  71. });
  72. },
  73. //打开视图
  74. loadViewByData: function(node, e){
  75. var view = node.retrieve("view");
  76. if (openNew){
  77. var _self = this;
  78. var options = {
  79. "onQueryLoad": function(){
  80. this.actions = _self.actions;
  81. this.category = _self;
  82. this.options.id = view.id;
  83. this.application = _self.application;
  84. this.explorer = _self.explorer;
  85. }
  86. };
  87. this.desktop.openApplication(e, "process.StatDesigner", options);
  88. }
  89. },
  90. //loadView------------------------------------------
  91. loadView: function(){
  92. this.getViewData(this.options.id, function(vdata){
  93. this.setTitle(this.options.appTitle + "-"+vdata.name);
  94. this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  95. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  96. this.view = new MWF.xApplication.process.StatDesigner.Stat(this, vdata);
  97. this.view.load();
  98. }.bind(this));
  99. },
  100. loadNewViewData: function(callback){
  101. var url = "/x_component_process_StatDesigner/$Stat/stat.json";
  102. MWF.getJSON(url, {
  103. "onSuccess": function(obj){
  104. this.actions.getUUID(function(id){
  105. obj.id=id;
  106. obj.isNewView = true;
  107. obj.application = this.application.id;
  108. this.createListViewItem(obj, true);
  109. if (callback) callback(obj);
  110. }.bind(this));
  111. }.bind(this),
  112. "onerror": function(text){
  113. this.notice(text, "error");
  114. }.bind(this),
  115. "onRequestFailure": function(xhr){
  116. this.notice(xhr.responseText, "error");
  117. }.bind(this)
  118. });
  119. },
  120. loadViewData: function(id, callback){
  121. this.actions.getStat(id, function(json){
  122. if (json){
  123. var data = json.data;
  124. var dataJson = JSON.decode(data.data);
  125. data.data = dataJson;
  126. if (!this.application){
  127. this.actions.getApplication(data.application, function(json){
  128. this.application = {"name": json.data.name, "id": json.data.id};
  129. if (callback) callback(data);
  130. }.bind(this));
  131. }else{
  132. if (callback) callback(data);
  133. }
  134. }
  135. }.bind(this));
  136. },
  137. saveView: function(){
  138. this.view.save(function(){
  139. var name = this.view.data.name;
  140. this.setTitle(MWF.APPSTD.LP.title + "-"+name);
  141. this.options.desktopReload = true;
  142. this.options.id = this.view.data.id;
  143. }.bind(this));
  144. },
  145. saveDictionaryAs: function(){
  146. this.view.saveAs();
  147. },
  148. dictionaryExplode: function(){
  149. this.view.explode();
  150. },
  151. dictionaryImplode: function(){
  152. this.view.implode();
  153. }
  154. //recordStatus: function(){
  155. // return {"id": this.options.id};
  156. //},
  157. });