Main.js 9.9 KB

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