Main.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. MWF.xApplication.query = MWF.xApplication.query || {};
  2. MWF.xApplication.query.QueryExplorer = MWF.xApplication.query.QueryExplorer || {};
  3. MWF.xDesktop.requireApp("process.ApplicationExplorer", "", null, false);
  4. MWF.xApplication.query.QueryExplorer.Main = new Class({
  5. Extends: MWF.xApplication.process.ApplicationExplorer.Main,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "name": "query.QueryExplorer",
  10. "mvcStyle": "style.css",
  11. "icon": "icon.png",
  12. "width": "1500",
  13. "height": "760",
  14. "isResize": true,
  15. "isMax": true,
  16. "title": MWF.xApplication.query.QueryExplorer.LP.title,
  17. "maxWidth": 840,
  18. "minWidth": 540
  19. },
  20. onQueryLoad: function(){
  21. this.lp = MWF.QueryLP;
  22. this.viewPath = this.path+this.options.style+"/view.html";
  23. this.restActions = MWF.Actions.get("x_query_assemble_designer");
  24. this.deleteElements = [];
  25. },
  26. loadControl: function(){
  27. this.control = {};
  28. this.control.canCreate = MWF.AC.isQueryPlatformCreator();
  29. this.control.canManage = !!(MWF.AC.isAdministrator() || MWF.AC.isQueryManager());
  30. },
  31. createApplicationItem: function(appData, where){
  32. var application = new MWF.xApplication.query.QueryExplorer.Query(this, appData, where);
  33. application.load();
  34. },
  35. okCreateApplication: function(e){
  36. var nameNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationName");
  37. var aliasNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationAlias");
  38. var descriptionNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationDescription");
  39. var typeNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationType");
  40. var data = {
  41. "name": nameNode.get("value"),
  42. "alias": aliasNode.get("value"),
  43. "description": descriptionNode.get("value"),
  44. "queryCategory": typeNode.get("value")
  45. };
  46. if (data.name){
  47. this.restActions.saveApplication(data, function(json){
  48. this.applicationCreateMarkNode.destroy();
  49. this.applicationCreateAreaNode.destroy();
  50. this.restActions.getApplication(json.data.id, function(json){
  51. json.data.viewList = [];
  52. json.data.statList = [];
  53. this.createApplicationItem(json.data, "top");
  54. }.bind(this));
  55. this.reloadApplicationCategoryList(true);
  56. this.notice(this.lp.application.createApplicationSuccess, "success");
  57. }.bind(this));
  58. }else{
  59. nameNode.setStyle("border-color", "red");
  60. nameNode.focus();
  61. this.notice(this.lp.application.inputApplicationName, "error");
  62. }
  63. },
  64. importApplication: function(e){
  65. MWF.xDesktop.requireApp("query.QueryExplorer", "Importer", function(){
  66. (new MWF.xApplication.query.QueryExplorer.Importer(this, e)).load();
  67. }.bind(this));
  68. },
  69. deleteSelectedElements: function(e){
  70. var _self = this;
  71. var applicationList = [];
  72. this.deleteElements.each(function(app){
  73. applicationList.push(app.data.name);
  74. });
  75. var confirmStr = this.lp.application.deleteElementsConfirm+" ("+applicationList.join("、")+") ";
  76. var check = "<div style='display: none'><br/><br/><input type=\"checkbox\" id=\"deleteApplicationAllCheckbox\" value=\"yes\">"+this.lp.application.deleteApplicationAllConfirm+"</div>";
  77. confirmStr += check;
  78. this.confirm("infor", e, this.lp.application.deleteElementsTitle, {"html":confirmStr}, 530, 250, function(){
  79. confirmStr = _self.lp.application.deleteElementsConfirmAgain+"<br/><br/><font style='color:red; font-size:14px; font-weight: bold'>"+applicationList.join("、")+"</font>";
  80. var checkbox = this.content.getElement("#deleteApplicationAllCheckbox");
  81. var onlyRemoveNotCompleted = true;
  82. if (checkbox.checked){
  83. onlyRemoveNotCompleted = false;
  84. confirmStr = _self.lp.application.deleteElementsAllConfirmAgain+"<br/><br/><font style='color:red; font-size:14px; font-weight: bold'>"+applicationList.join("、")+"</font>";
  85. }
  86. this.close();
  87. _self.confirm("infor", e, _self.lp.application.deleteElementsTitle, {"html":confirmStr}, 500, 200, function(){
  88. var deleted = [];
  89. var doCount = 0;
  90. var readyCount = _self.deleteElements.length;
  91. var errorText = "";
  92. var complete = function(){
  93. if (doCount == readyCount){
  94. _self.reloadApplicationCategoryList( true );
  95. if (errorText){
  96. _self.app.notice(errorText, "error");
  97. }
  98. }
  99. };
  100. _self.deleteElements.each(function(application){
  101. application["delete"](onlyRemoveNotCompleted, function(){
  102. deleted.push(application);
  103. doCount++;
  104. if (_self.deleteElements.length==doCount){
  105. _self.deleteElements = _self.deleteElements.filter(function(item, index){
  106. return !deleted.contains(item);
  107. });
  108. _self.checkDeleteApplication();
  109. }
  110. complete();
  111. }, function(error){
  112. errorText = (errorText) ? errorText+"<br/><br/>"+error : error;
  113. doCount++;
  114. if (_self.deleteElements.length==doCount){
  115. _self.deleteElements = _self.deleteElements.filter(function(item, index){
  116. return !deleted.contains(item);
  117. });
  118. _self.checkDeleteApplication();
  119. }
  120. complete();
  121. });
  122. });
  123. this.close();
  124. }, function(){
  125. this.close();
  126. });
  127. this.close();
  128. }, function(){
  129. this.close();
  130. });
  131. }
  132. });
  133. MWF.xApplication.query.QueryExplorer.Query = new Class({
  134. Extends: MWF.xApplication.process.ApplicationExplorer.Application,
  135. Implements: [Events],
  136. loadElements: function(){
  137. this.loadElementList("viewList", this.viewListNode, this.openView.bind(this), this.lp.noView, this.createNewView.bind(this));
  138. this.loadElementList("statList", this.statListNode, this.openStat.bind(this), this.lp.noStat, this.createNewStat.bind(this));
  139. },
  140. createNewView: function(e){
  141. this.openApplication(e, 0);
  142. },
  143. createNewStat: function(e){
  144. this.openApplication(e, 1);
  145. },
  146. openApplication: function(e, navi){
  147. var appId = "query.QueryManager"+this.data.id;
  148. if (this.app.desktop.apps[appId]){
  149. this.app.desktop.apps[appId].setCurrent();
  150. }else {
  151. this.app.desktop.openApplication(e, "query.QueryManager", {
  152. "application": this.data,
  153. "appId": appId,
  154. "onQueryLoad": function(){
  155. this.status = {"navi": navi || null};
  156. }
  157. });
  158. }
  159. },
  160. openView: function(id, e){
  161. if (id){
  162. var _self = this;
  163. var options = {
  164. "appId": "query.ViewDesigner"+id,
  165. "onQueryLoad": function(){
  166. this.actions = _self.app.actions;
  167. //this.category = _self;
  168. this.options.id = id;
  169. this.application = _self.data;
  170. }
  171. };
  172. this.app.desktop.openApplication(e, "query.ViewDesigner", options);
  173. }
  174. },
  175. openStat: function(id, e){
  176. if (id){
  177. var _self = this;
  178. var options = {
  179. "appId": "query.StatDesigner"+id,
  180. "onQueryLoad": function(){
  181. this.actions = _self.app.actions;
  182. //this.category = _self;
  183. this.options.id = id;
  184. this.application = _self.data;
  185. }
  186. };
  187. this.app.desktop.openApplication(e, "query.StatDesigner", options);
  188. }
  189. },
  190. setIconNode: function(){
  191. if (this.data.icon){
  192. this.iconNode.setStyle("background-image", "url(data:image/png;base64,"+this.data.icon+")");
  193. }else{
  194. this.iconNode.setStyle("background-image", "url("+"/x_component_query_QueryExplorer/$Main/default/icon/application.png)")
  195. }
  196. this.iconNode.makeLnk({
  197. "par": this._getLnkPar()
  198. });
  199. },
  200. _getLnkPar: function(){
  201. var lnkIcon = "/x_component_query_QueryExplorer/$Main/default/lnk.png";
  202. if (this.data.icon) lnkIcon = "data:image/png;base64,"+this.data.icon;
  203. var appId = "query.QueryManager"+this.data.id;
  204. return {
  205. "icon": lnkIcon,
  206. "title": this.data.name,
  207. "par": "query.QueryManager#{\"application\": \""+this.data.id+"\", \"appId\": \""+appId+"\"}"
  208. };
  209. },
  210. exportApplication: function(){
  211. MWF.xDesktop.requireApp("query.QueryExplorer", "Exporter", function(){
  212. (new MWF.xApplication.query.QueryExplorer.Exporter(this.app, this.data)).load();
  213. }.bind(this));
  214. },
  215. _deleteElement: function(id, onlyRemoveNotCompleted, success, failure){
  216. this.app.restActions.deleteApplication(id, success, failure);
  217. }
  218. });