Main.js 16 KB

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