Main.js 10.0 KB

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