Main.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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.importPersonCleanNode = this.importConfiguratorContentNode.getElement(".importPersonCleanNode");
  167. this.importPersonTitleNode = this.importConfiguratorContentNode.getElement(".importPersonTitleNode");
  168. this.importPersonTemplateNode = this.importConfiguratorContentNode.getElement(".importPersonTemplateNode");
  169. this.importPersonNode = this.importConfiguratorContentNode.getElement(".importPersonNode");
  170. this.importPersonResultNode = this.importConfiguratorContentNode.getElement(".importPersonResultNode");
  171. o2.loadCss(this.path+this.options.style+"/importCss.css", this.importConfiguratorContentNode, function(){
  172. this.loadPersonImport();
  173. }.bind(this));
  174. }.bind(this)}).load(this.path+this.options.style+"/importView.html");
  175. },
  176. loadPersonImport: function(){
  177. var action = o2.Actions.get("x_organization_assemble_control");
  178. var url = action.action.address + action.action.actions.getImportPersonTemplate.uri;
  179. var infor = this.lp.importPersonInfor.replace("{url}", url);
  180. this.importPersonCleanNode.set("text", this.lp.importPersonCleanNode);
  181. this.importPersonTitleNode.set("text", this.lp.importPersonTitle);
  182. this.importPersonTemplateNode.set("html", infor);
  183. this.importPersonNode.set("text", this.lp.importPersonAction);
  184. this.importPersonCleanNode.addEvent("click", function(){
  185. this.importPersonResultNode.hide();
  186. this.restActions.wipeAll(function( json ){
  187. if (json.type && json.type=="success"){
  188. this.importPersonResultNode.set("html", json.data.flag);
  189. this.importPersonResultNode.show();
  190. }
  191. }.bind(this),null,false);
  192. }.bind(this));
  193. this.importPersonNode.addEvent("click", function(){
  194. this.importPersonResultNode.hide();
  195. o2.require("o2.widget.Upload", function(){
  196. new o2.widget.Upload(this.content, {
  197. "action": "x_organization_assemble_control",
  198. "method": "importPerson",
  199. "multiple": false,
  200. "onCompleted": function(json){
  201. var url = action.action.address + action.action.actions.getImportPersonResault.uri;
  202. url = url.replace("{flag}", json.data.flag);
  203. var result = this.lp.importPersonResult.replace("{url}", url);
  204. this.importPersonResultNode.set("html", result);
  205. this.importPersonResultNode.show();
  206. }.bind(this)
  207. }).load();
  208. }.bind(this));
  209. }.bind(this));
  210. },
  211. privateNamesQueryPower:function(){
  212. debugger;
  213. this.clearContent();
  214. this.privateNamesQueryPowerContentNode = new Element("div", {
  215. "styles": this.css.rightContentNode
  216. }).inject(this.node);
  217. this.privateNamesQueryPowerContentNode.set("load", {"onSuccess": function(){
  218. this.queryPrivateConfigAreaNode = this.privateNamesQueryPowerContentNode.getElement(".queryPrivateConfigAreaNode");
  219. o2.loadCss(this.path+this.options.style+"/queryPrivateConfig.css", this.privateNamesQueryPowerContentNode, function(){
  220. this.loadprivateNamesQueryPower();
  221. }.bind(this));
  222. }.bind(this)}).load(this.path+this.options.style+"/queryPrivateConfigView.html");
  223. },
  224. loadprivateNamesQueryPower: function(){
  225. MWF.xDesktop.requireApp("Org", "PrivateConfig", function(){
  226. this.privateConfigurator = new MWF.xApplication.Org.PrivateConfig(this.privateNamesQueryPowerContentNode);
  227. this.privateConfigurator.app = this;
  228. this.privateConfigurator.load();
  229. }.bind(this));
  230. },
  231. recordStatus: function(){
  232. var idx = null;
  233. if (this.menu.currentNavi){
  234. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  235. }
  236. return {"navi": idx};
  237. }
  238. });
  239. MWF.xApplication.Org.Menu = new Class({
  240. Implements: [Options, Events],
  241. initialize: function(app, node, options){
  242. this.setOptions(options);
  243. this.app = app;
  244. this.node = $(node);
  245. this.currentNavi = null;
  246. this.status = "start";
  247. this.startNavis = [];
  248. this.load();
  249. },
  250. load: function(){
  251. //var menuUrl = (MWF.AC.isOrganizationManager()) ? this.app.path+"startMenu_admin.json" : this.app.path+"startMenu.json";
  252. var menuUrl = this.app.path+"startMenu.json";
  253. MWF.getJSON(menuUrl, function(json){
  254. json.each(function(navi){
  255. if (navi.display){
  256. var naviNode = new Element("div", {
  257. "styles": this.app.css.startMenuNaviNode,
  258. "title": navi.title
  259. });
  260. naviNode.store("naviData", navi);
  261. var iconNode = new Element("div", {
  262. "styles": this.app.css.startMenuIconNode
  263. }).inject(naviNode);
  264. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+"60.png)");
  265. var textNode = new Element("div", {
  266. "styles": this.app.css.startMenuTextNode,
  267. "text": navi.title
  268. });
  269. textNode.inject(naviNode);
  270. naviNode.inject(this.node);
  271. this.startNavis.push(naviNode);
  272. this.setStartNaviEvent(naviNode, navi);
  273. this.setNodeCenter(this.node);
  274. }
  275. }.bind(this));
  276. this.setStartMenuWidth();
  277. this.fireEvent("postLoad");
  278. }.bind(this));
  279. },
  280. setStartNaviEvent: function(naviNode){
  281. var _self = this;
  282. naviNode.addEvents({
  283. "mouseover": function(){
  284. //debugger;
  285. if (_self.currentNavi!==this){
  286. var iconNode = this.getFirst();
  287. this.setStyles(_self.app.css.startMenuNaviNode_over);
  288. var navi = this.retrieve("naviData");
  289. iconNode.setStyle("background-image", "url("+_self.app.path+_self.app.options.style+"/icon/"+navi.icon+".png)");
  290. iconNode.setStyles(_self.app.css.startMenuIconNode_over);
  291. }
  292. },
  293. "mouseout": function(){
  294. var iconNode = this.getFirst();
  295. if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode);
  296. var navi = this.retrieve("naviData");
  297. iconNode.setStyle("background-image", "url("+_self.app.path+_self.app.options.style+"/icon/"+navi.icon+"60.png)");
  298. iconNode.setStyles(_self.app.css.startMenuIconNode);
  299. },
  300. "mousedown": function(){
  301. if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode_down);
  302. },
  303. "mouseup": function(){if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  304. "click": function(){
  305. _self.doAction.apply(_self, [this]);
  306. }
  307. });
  308. },
  309. doAction: function(naviNode){
  310. var navi = naviNode.retrieve("naviData");
  311. var action = navi.action;
  312. this.startNavis.each(function(node){
  313. node.removeEvents("mouseover");
  314. node.removeEvents("mouseout");
  315. node.removeEvents("mousedown");
  316. node.removeEvents("mouseup");
  317. node.setStyles(this.app.css.startMenuNaviLeftNode);
  318. var iconNode = node.getFirst();
  319. var textNode = node.getLast();
  320. var tmpnavi = node.retrieve("naviData");
  321. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+tmpnavi.icon+"32.png)");
  322. iconNode.setStyles(this.app.css.startMenuIconLeftNode);
  323. textNode.setStyles(this.app.css.startMenuTextLeftNode);
  324. }.bind(this));
  325. naviNode.setStyles(this.app.css.startMenuNaviLeftNode_current);
  326. this.currentNavi = naviNode;
  327. if (this.status === "start"){
  328. this.toNormal();
  329. this.status = "normal";
  330. }
  331. if (this.app[action]) this.app[action].apply(this.app);
  332. },
  333. toNormal: function(){
  334. var css = this.app.css.normalStartMenuNode;
  335. if (!this.morph){
  336. this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"});
  337. }
  338. this.app.pingyinArea = new Element("div", {"styles": this.app.css.startMenuNaviLeftPingyinNode}).inject(this.node, "top");
  339. this.morph.start(css).chain(function(){
  340. this.node.setStyles(css);
  341. // MWF.require("MWF.widget.ScrollBar", function(){
  342. // new MWF.widget.ScrollBar(this.node, {
  343. // "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  344. // });
  345. // }.bind(this));
  346. }.bind(this));
  347. },
  348. setNodeCenter: function(node){
  349. var size = node.getSize();
  350. var contentSize = this.app.node.getSize();
  351. var top = contentSize.y/2 - size.y/2;
  352. var left = contentSize.x/2 - size.x/2;
  353. if (left<0) left = 0;
  354. if (top<0) top = 0;
  355. node.setStyles({"left": left, "top": top});
  356. },
  357. getStartMenuNormalSize: function(){
  358. var naviItemNode = this.node.getFirst();
  359. var size = naviItemNode.getComputedSize();
  360. var mt = naviItemNode.getStyle("margin-top").toFloat();
  361. var mb = naviItemNode.getStyle("margin-bottom").toFloat();
  362. var height = size.totalWidth+mt+mb;
  363. var ml = naviItemNode.getStyle("margin-left").toFloat();
  364. var mr = naviItemNode.getStyle("margin-right").toFloat();
  365. var width = size.totalWidth+ml+mr;
  366. return {"width": width, "height": height*this.startNavis.length};
  367. },
  368. setStartMenuWidth: function(){
  369. var naviItemNode = this.node.getFirst();
  370. var size = naviItemNode.getComputedSize();
  371. var ml = naviItemNode.getStyle("margin-left").toFloat();
  372. var mr = naviItemNode.getStyle("margin-right").toFloat();
  373. var width = size.totalWidth+ml+mr;
  374. this.node.setStyle("width", (width*this.startNavis.length)+"px");
  375. },
  376. onResize: function(){
  377. if (this.status === "start"){
  378. this.setNodeCenter(this.node);
  379. }
  380. }
  381. });