Main.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. //MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  2. MWF.xApplication.Org.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "name": "Org",
  8. "icon": "icon.png",
  9. "width": (layout.desktop.size) ? layout.desktop.size.x*0.7 : 1000,
  10. "height": (layout.desktop.size) ? layout.desktop.size.y*0.8: 800,
  11. "title": MWF.xApplication.Org.LP.title
  12. },
  13. onQueryLoad: function(){
  14. this.lp = MWF.xApplication.Org.LP;
  15. this.restActions = MWF.Actions.get("x_organization_assemble_control");
  16. },
  17. loadApplication: function(callback){
  18. this.createNode();
  19. this.loadApplicationContent();
  20. if (callback) callback();
  21. },
  22. createNode: function(){
  23. this.content.setStyle("overflow", "hidden");
  24. this.node = new Element("div", {
  25. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  26. }).inject(this.content);
  27. },
  28. loadApplicationContent: function(){
  29. this.loadStartMenu();
  30. // this.loadApplicationLayout();
  31. },
  32. loadStartMenu: function(){
  33. this.startMenuNode = new Element("div", {
  34. "styles": this.css.startMenuNode
  35. }).inject(this.node);
  36. this.menu = new MWF.xApplication.Org.Menu(this, this.startMenuNode, {
  37. "onPostLoad": function(){
  38. if (this.status){
  39. if (this.status.navi!==null){
  40. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  41. }
  42. }
  43. }.bind(this)
  44. });
  45. this.addEvent("resize", function(){
  46. if (this.menu) this.menu.onResize();
  47. }.bind(this));
  48. },
  49. clearContent: function(){
  50. if (this.orgConfiguratorContentNode){
  51. if (this.orgConfigurator){
  52. this.orgConfigurator.destroy();
  53. this.orgConfigurator = null;
  54. }
  55. this.orgConfiguratorContentNode.destroy();
  56. this.orgConfiguratorContentNode = null;
  57. }
  58. if (this.identityConfiguratorContentNode){
  59. if (this.identityConfigurator) delete this.identityConfigurator;
  60. this.identityConfiguratorContentNode.destroy();
  61. }
  62. if (this.groupConfiguratorContentNode){
  63. if (this.groupConfigurator){
  64. this.groupConfigurator.destroy();
  65. this.groupConfigurator = null;
  66. }
  67. this.groupConfiguratorContentNode.destroy();
  68. }
  69. if (this.roleConfiguratorContentNode){
  70. if (this.roleConfigurator){
  71. this.roleConfigurator.destroy();
  72. this.roleConfigurator = null;
  73. }
  74. this.roleConfiguratorContentNode.destroy();
  75. }
  76. if (this.personConfiguratorContentNode){
  77. if (this.personConfigurator){
  78. this.personConfigurator.destroy();
  79. this.personConfigurator = null;
  80. }
  81. this.personConfiguratorContentNode.destroy();
  82. }
  83. if (this.importConfiguratorContentNode){
  84. this.importConfiguratorContentNode.destroy();
  85. }
  86. if (this.privateNamesQueryPowerContentNode){
  87. this.privateNamesQueryPowerContentNode.destroy();
  88. }
  89. if (this.pingyinArea) this.pingyinArea.empty();
  90. },
  91. orgConfig: function(){
  92. this.clearContent();
  93. this.orgConfiguratorContentNode = new Element("div", {
  94. "styles": this.css.rightContentNode
  95. }).inject(this.node);
  96. this.loadOrgConfig();
  97. },
  98. loadOrgConfig: function(){
  99. MWF.xDesktop.requireApp("Org", "UnitExplorer", function(){
  100. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  101. // if (!this.restActions) this.restActions = new MWF.xApplication.Org.Actions.RestActions();
  102. this.orgConfigurator = new MWF.xApplication.Org.UnitExplorer(this.orgConfiguratorContentNode, this.restActions);
  103. this.orgConfigurator.app = this;
  104. this.orgConfigurator.load();
  105. //}.bind(this));
  106. }.bind(this));
  107. },
  108. groupConfig: function(){
  109. this.clearContent();
  110. this.groupConfiguratorContentNode = new Element("div", {
  111. "styles": this.css.rightContentNode
  112. }).inject(this.node);
  113. this.loadGroupConfig();
  114. },
  115. loadGroupConfig: function(){
  116. MWF.xDesktop.requireApp("Org", "GroupExplorer", function(){
  117. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  118. // if (!this.restActions) this.restActions = new MWF.xApplication.Org.Actions.RestActions();
  119. this.groupConfigurator = new MWF.xApplication.Org.GroupExplorer(this.groupConfiguratorContentNode, this.restActions);
  120. this.groupConfigurator.app = this;
  121. this.groupConfigurator.load();
  122. //}.bind(this));
  123. }.bind(this));
  124. },
  125. roleConfig: function(){
  126. this.clearContent();
  127. this.roleConfiguratorContentNode = new Element("div", {
  128. "styles": this.css.rightContentNode
  129. }).inject(this.node);
  130. this.loadRoleConfig();
  131. },
  132. loadRoleConfig: function(){
  133. MWF.xDesktop.requireApp("Org", "RoleExplorer", function(){
  134. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  135. // if (!this.restActions) this.restActions = new MWF.xApplication.Org.Actions.RestActions();
  136. this.roleConfigurator = new MWF.xApplication.Org.RoleExplorer(this.roleConfiguratorContentNode, this.restActions);
  137. this.roleConfigurator.app = this;
  138. this.roleConfigurator.load();
  139. //}.bind(this));
  140. }.bind(this));
  141. },
  142. personConfig: function(){
  143. this.clearContent();
  144. this.personConfiguratorContentNode = new Element("div", {
  145. "styles": this.css.rightContentNode
  146. }).inject(this.node);
  147. this.loadPersonConfig();
  148. },
  149. loadPersonConfig: function(){
  150. MWF.xDesktop.requireApp("Org", "PersonExplorer", function(){
  151. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  152. // if (!this.restActions) this.restActions = new MWF.xApplication.Org.Actions.RestActions();
  153. this.personConfigurator = new MWF.xApplication.Org.PersonExplorer(this.personConfiguratorContentNode, this.restActions);
  154. this.personConfigurator.app = this;
  155. this.personConfigurator.load();
  156. //}.bind(this));
  157. }.bind(this));
  158. },
  159. personImport: function(){
  160. debugger;
  161. this.clearContent();
  162. this.importConfiguratorContentNode = new Element("div", {
  163. "styles": this.css.rightContentNode
  164. }).inject(this.node);
  165. this.importConfiguratorContentNode.set("load", {"onSuccess": function(){
  166. this.importPersonTitleNode = this.importConfiguratorContentNode.getElement(".importPersonTitleNode");
  167. this.importPersonTemplateNode = this.importConfiguratorContentNode.getElement(".importPersonTemplateNode");
  168. this.importPersonNode = this.importConfiguratorContentNode.getElement(".importPersonNode");
  169. this.importPersonResultNode = this.importConfiguratorContentNode.getElement(".importPersonResultNode");
  170. o2.loadCss(this.path+this.options.style+"/importCss.css", this.importConfiguratorContentNode, function(){
  171. this.loadPersonImport();
  172. }.bind(this));
  173. }.bind(this)}).load(this.path+this.options.style+"/importView.html");
  174. },
  175. loadPersonImport: function(){
  176. var action = o2.Actions.get("x_organization_assemble_control");
  177. var url = action.action.address + action.action.actions.getImportPersonTemplate.uri;
  178. var infor = this.lp.importPersonInfor.replace("{url}", url);
  179. this.importPersonTitleNode.set("text", this.lp.importPersonTitle);
  180. this.importPersonTemplateNode.set("html", infor);
  181. this.importPersonNode.set("text", this.lp.importPersonAction);
  182. this.importPersonNode.addEvent("click", function(){
  183. this.importPersonResultNode.hide();
  184. o2.require("o2.widget.Upload", function(){
  185. new o2.widget.Upload(this.content, {
  186. "action": "x_organization_assemble_control",
  187. "method": "importPerson",
  188. "multiple": false,
  189. "onCompleted": function(json){
  190. var url = action.action.address + action.action.actions.getImportPersonResault.uri;
  191. url = url.replace("{flag}", json.data.flag);
  192. var result = this.lp.importPersonResult.replace("{url}", url);
  193. this.importPersonResultNode.set("html", result);
  194. this.importPersonResultNode.show();
  195. }.bind(this)
  196. }).load();
  197. }.bind(this));
  198. }.bind(this));
  199. },
  200. privateNamesQueryPower:function(){
  201. debugger;
  202. this.clearContent();
  203. this.privateNamesQueryPowerContentNode = new Element("div", {
  204. "styles": this.css.rightContentNode
  205. }).inject(this.node);
  206. this.privateNamesQueryPowerContentNode.set("load", {"onSuccess": function(){
  207. this.queryPrivateConfigAreaNode = this.privateNamesQueryPowerContentNode.getElement(".queryPrivateConfigAreaNode");
  208. o2.loadCss(this.path+this.options.style+"/queryPrivateConfig.css", this.privateNamesQueryPowerContentNode, function(){
  209. this.loadprivateNamesQueryPower();
  210. }.bind(this));
  211. }.bind(this)}).load(this.path+this.options.style+"/queryPrivateConfigView.html");
  212. },
  213. loadprivateNamesQueryPower: function(){
  214. MWF.xDesktop.requireApp("Org", "PrivateConfig", function(){
  215. this.privateConfigurator = new MWF.xApplication.Org.PrivateConfig(this.privateNamesQueryPowerContentNode);
  216. this.privateConfigurator.app = this;
  217. this.privateConfigurator.load();
  218. }.bind(this));
  219. },
  220. recordStatus: function(){
  221. var idx = null;
  222. if (this.menu.currentNavi){
  223. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  224. }
  225. return {"navi": idx};
  226. }
  227. });
  228. MWF.xApplication.Org.Menu = new Class({
  229. Implements: [Options, Events],
  230. initialize: function(app, node, options){
  231. this.setOptions(options);
  232. this.app = app;
  233. this.node = $(node);
  234. this.currentNavi = null;
  235. this.status = "start";
  236. this.startNavis = [];
  237. this.load();
  238. },
  239. load: function(){
  240. //var menuUrl = (MWF.AC.isOrganizationManager()) ? this.app.path+"startMenu_admin.json" : this.app.path+"startMenu.json";
  241. var menuUrl = this.app.path+"startMenu.json";
  242. MWF.getJSON(menuUrl, function(json){
  243. json.each(function(navi){
  244. if (navi.display){
  245. var naviNode = new Element("div", {
  246. "styles": this.app.css.startMenuNaviNode,
  247. "title": navi.title
  248. });
  249. naviNode.store("naviData", navi);
  250. var iconNode = new Element("div", {
  251. "styles": this.app.css.startMenuIconNode
  252. }).inject(naviNode);
  253. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+"60.png)");
  254. var textNode = new Element("div", {
  255. "styles": this.app.css.startMenuTextNode,
  256. "text": navi.title
  257. });
  258. textNode.inject(naviNode);
  259. naviNode.inject(this.node);
  260. this.startNavis.push(naviNode);
  261. this.setStartNaviEvent(naviNode, navi);
  262. this.setNodeCenter(this.node);
  263. }
  264. }.bind(this));
  265. this.setStartMenuWidth();
  266. this.fireEvent("postLoad");
  267. }.bind(this));
  268. },
  269. setStartNaviEvent: function(naviNode){
  270. var _self = this;
  271. naviNode.addEvents({
  272. "mouseover": function(){
  273. //debugger;
  274. if (_self.currentNavi!==this){
  275. var iconNode = this.getFirst();
  276. this.setStyles(_self.app.css.startMenuNaviNode_over);
  277. var navi = this.retrieve("naviData");
  278. iconNode.setStyle("background-image", "url("+_self.app.path+_self.app.options.style+"/icon/"+navi.icon+".png)");
  279. iconNode.setStyles(_self.app.css.startMenuIconNode_over);
  280. }
  281. },
  282. "mouseout": function(){
  283. var iconNode = this.getFirst();
  284. if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode);
  285. var navi = this.retrieve("naviData");
  286. iconNode.setStyle("background-image", "url("+_self.app.path+_self.app.options.style+"/icon/"+navi.icon+"60.png)");
  287. iconNode.setStyles(_self.app.css.startMenuIconNode);
  288. },
  289. "mousedown": function(){
  290. if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode_down);
  291. },
  292. "mouseup": function(){if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  293. "click": function(){
  294. _self.doAction.apply(_self, [this]);
  295. }
  296. });
  297. },
  298. doAction: function(naviNode){
  299. var navi = naviNode.retrieve("naviData");
  300. var action = navi.action;
  301. this.startNavis.each(function(node){
  302. node.removeEvents("mouseover");
  303. node.removeEvents("mouseout");
  304. node.removeEvents("mousedown");
  305. node.removeEvents("mouseup");
  306. node.setStyles(this.app.css.startMenuNaviLeftNode);
  307. var iconNode = node.getFirst();
  308. var textNode = node.getLast();
  309. var tmpnavi = node.retrieve("naviData");
  310. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+tmpnavi.icon+"32.png)");
  311. iconNode.setStyles(this.app.css.startMenuIconLeftNode);
  312. textNode.setStyles(this.app.css.startMenuTextLeftNode);
  313. }.bind(this));
  314. naviNode.setStyles(this.app.css.startMenuNaviLeftNode_current);
  315. this.currentNavi = naviNode;
  316. if (this.status === "start"){
  317. this.toNormal();
  318. this.status = "normal";
  319. }
  320. if (this.app[action]) this.app[action].apply(this.app);
  321. },
  322. toNormal: function(){
  323. var css = this.app.css.normalStartMenuNode;
  324. if (!this.morph){
  325. this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"});
  326. }
  327. this.app.pingyinArea = new Element("div", {"styles": this.app.css.startMenuNaviLeftPingyinNode}).inject(this.node, "top");
  328. this.morph.start(css).chain(function(){
  329. this.node.setStyles(css);
  330. // MWF.require("MWF.widget.ScrollBar", function(){
  331. // new MWF.widget.ScrollBar(this.node, {
  332. // "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  333. // });
  334. // }.bind(this));
  335. }.bind(this));
  336. },
  337. setNodeCenter: function(node){
  338. var size = node.getSize();
  339. var contentSize = this.app.node.getSize();
  340. var top = contentSize.y/2 - size.y/2;
  341. var left = contentSize.x/2 - size.x/2;
  342. if (left<0) left = 0;
  343. if (top<0) top = 0;
  344. node.setStyles({"left": left, "top": top});
  345. },
  346. getStartMenuNormalSize: function(){
  347. var naviItemNode = this.node.getFirst();
  348. var size = naviItemNode.getComputedSize();
  349. var mt = naviItemNode.getStyle("margin-top").toFloat();
  350. var mb = naviItemNode.getStyle("margin-bottom").toFloat();
  351. var height = size.totalWidth+mt+mb;
  352. var ml = naviItemNode.getStyle("margin-left").toFloat();
  353. var mr = naviItemNode.getStyle("margin-right").toFloat();
  354. var width = size.totalWidth+ml+mr;
  355. return {"width": width, "height": height*this.startNavis.length};
  356. },
  357. setStartMenuWidth: function(){
  358. var naviItemNode = this.node.getFirst();
  359. var size = naviItemNode.getComputedSize();
  360. var ml = naviItemNode.getStyle("margin-left").toFloat();
  361. var mr = naviItemNode.getStyle("margin-right").toFloat();
  362. var width = size.totalWidth+ml+mr;
  363. this.node.setStyle("width", (width*this.startNavis.length)+"px");
  364. },
  365. onResize: function(){
  366. if (this.status === "start"){
  367. this.setNodeCenter(this.node);
  368. }
  369. }
  370. });