Main.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  1. MWF.xApplication.Meeting = MWF.xApplication.Meeting || {};
  2. MWF.require("MWF.xDesktop.UserData", null, false);
  3. MWF.xDesktop.requireApp("Meeting", "MeetingView", null, false);
  4. MWF.xDesktop.requireApp("Meeting", "Common", null, false);
  5. MWF.xDesktop.requireApp("Template", "MDomItem", null, false);
  6. MWF.xApplication.Meeting.options.multitask = false;
  7. MWF.xApplication.Meeting.Main = new Class({
  8. Extends: MWF.xApplication.Common.Main,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default",
  12. "name": "Meeting",
  13. "icon": "icon.png",
  14. "width": "1000",
  15. "height": "600",
  16. "isResize": true,
  17. "isMax": true,
  18. "sideBarEnable" : true,
  19. "settingEnable" : true,
  20. "title": MWF.xApplication.Meeting.LP.title
  21. },
  22. onQueryLoad: function(){
  23. this.lp = MWF.xApplication.Meeting.LP;
  24. this.menuMode="show";
  25. this.isManager = MWF.AC.isMeetingAdministrator();
  26. this.actions = MWF.Actions.get("x_meeting_assemble_control");
  27. this.personActions = MWF.Actions.get("x_organization_assemble_express");
  28. //if (!this.actions) this.actions = new MWF.xApplication.Meeting.Actions.RestActions();
  29. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  30. },
  31. loadApplication: function(callback) {
  32. MWF.UD.getDataJson("meetingConfig", function(json){
  33. this.meetingConfig = json || {};
  34. MWF.UD.getPublicData("meetingConfig", function(json){
  35. var jsonData = json || {};
  36. if (jsonData.process){
  37. this.meetingConfig.process = jsonData.process;
  38. }else{
  39. this.meetingConfig.process = null;
  40. }
  41. if( jsonData.weekBegin ){
  42. this.meetingConfig.weekBegin = jsonData.weekBegin;
  43. }
  44. if( jsonData.meetingViewer ){
  45. this.meetingConfig.meetingViewer = jsonData.meetingViewer;
  46. }
  47. for( var key in jsonData ){
  48. if( key != "process" && key != "weekBegin" && key != "meetingViewer" ){
  49. this.meetingConfig[ key ] = jsonData[key];
  50. }
  51. }
  52. if( !this.meetingConfig.disableViewList ) this.meetingConfig.disableViewList = [];
  53. this.createNode();
  54. if (!this.options.isRefresh) {
  55. this.maxSize(function () {
  56. this.loadLayout();
  57. }.bind(this));
  58. } else {
  59. this.loadLayout();
  60. }
  61. if (callback) callback();
  62. }.bind(this));
  63. }.bind(this));
  64. },
  65. createNode: function(){
  66. this.content.setStyle("overflow", "hidden");
  67. this.node = new Element("div", {
  68. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  69. }).inject(this.content);
  70. },
  71. loadLayout: function(){
  72. if( this.status && this.status.action ){
  73. this.defaultAction = this.status.action;
  74. }else if (this.meetingConfig.defaultView){
  75. this.defaultAction = this.meetingConfig.defaultView;
  76. }else{
  77. this.defaultAction = "toMyMeeting";
  78. }
  79. if( this.meetingConfig.disableViewList.contains( this.defaultAction ) ){
  80. this.defaultAction = "";
  81. }
  82. this.topMenu = new Element("div", {"styles": this.css.topMenu}).inject(this.node);
  83. this.contentNode = new Element("div.contentNode", {"styles": this.inContainer ? this.css.contentNode_inContainer : this.css.contentNode}).inject(this.node);
  84. //this.bottomMenu = new Element("div", {"styles": this.css.bottomMenu}).inject(this.node);
  85. this.loadTopMenus();
  86. if( this.options.sideBarEnable ){
  87. this.loadSideBar();
  88. }
  89. //this.loadBottomMenus();
  90. //this.hideMenu();
  91. //
  92. //this.node.addEvent("contextmenu", function(e){
  93. // if (this.menuMode=="show"){
  94. // this.hideMenu();
  95. // }else{
  96. // this.showMenu();
  97. // }
  98. // e.preventDefault();
  99. //}.bind(this));
  100. this.setEvent();
  101. },
  102. setEvent: function(){
  103. //this.topMenu.addEvent("mouseover", function(){this.showMenu();}.bind(this));
  104. //this.topMenu.addEvent("mouseout", function(){this.hideMenu();}.bind(this));
  105. //this.bottomMenu.addEvent("mouseover", function(){this.showMenu();}.bind(this));
  106. //this.bottomMenu.addEvent("mouseout", function(){this.hideMenu();}.bind(this));
  107. //this.contentNode.addEvent("click", function(){this.hideMenu();}.bind(this));
  108. },
  109. loadTopMenus_right: function(){
  110. this.topMenuRight = new Element("div", {"styles": this.css.topMenuRight }).inject(this.topMenu);
  111. this.createTopMenu_right(this.lp.addMeeting, "icon_newapply", "addMeeting");
  112. if (this.isManager)this.createTopMenu_right(this.lp.addRoom, "icon_newhuiyishi", "addRoom");
  113. //var refreshNode = this.createTopMenu_right(this.lp.refresh, "refresh", "refresh");
  114. //refreshNode.setStyle("float", "right");
  115. if( this.options.settingEnable ){
  116. var configNode = this.createTopMenu_right(this.lp.setting, "icon_shezhi", "config");
  117. configNode.setStyle("float", "right");
  118. }
  119. },
  120. createTopMenu_right : function(text, icon, action){
  121. var actionNode = new Element("div", {"styles": this.css.topMenuNode_right, "title" : text}).inject(this.topMenuRight);
  122. var actionIconNode = new Element("div", {"styles": this.css.topMenuIconNode}).inject(actionNode);
  123. var actionTextNode = new Element("div",{styles: this.css.topMenuTextNode, "text":text}).inject(actionNode);
  124. actionIconNode.setStyle("background", "url(/x_component_Meeting/$Main/default/icon/"+icon+".png) no-repeat center center");
  125. actionNode.store("icon",icon);
  126. actionNode.store("iconNode",actionIconNode);
  127. var _self = this;
  128. actionNode.addEvents({
  129. "mouseover": function(){
  130. this.node.setStyles(_self.css.topMenuNode_over);
  131. this.node.retrieve("iconNode").setStyle( "background","url(/x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  132. }.bind( { node : actionNode } ),
  133. "mouseout": function(){
  134. this.node.setStyles(_self.css.topMenuNode_right);
  135. this.node.retrieve("iconNode").setStyle( "background","url(/x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" );
  136. }.bind({ node:actionNode }),
  137. "click": function(){
  138. this.node.setStyles(_self.css.topMenuNode_down);
  139. this.node.retrieve("iconNode").setStyle( "background","url(/x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  140. if (_self[action]) _self[action].apply(_self);
  141. }.bind({ node : actionNode })
  142. });
  143. return actionNode;
  144. },
  145. loadTopMenus: function(){
  146. this.createTopMenu(this.lp.myMeeting, "icon_huiyi", "toMyMeeting");
  147. this.createTopMenu(this.lp.month, "icon_yue", "toMonth");
  148. this.createTopMenu(this.lp.week, "icon_zhou", "toWeek");
  149. this.createTopMenu(this.lp.day, "icon_ri", "toDay");
  150. this.createTopMenu(this.lp.list, "icon_liebiao", "toList");
  151. this.createTopMenu(this.lp.room, "icon_huiyishi", "toRoom");
  152. this.loadTopMenus_right();
  153. },
  154. isViewAvailable : function( action ){
  155. return !this.meetingConfig.disableViewList.contains( action );
  156. },
  157. createTopMenu: function(text, icon, action){
  158. if( this.meetingConfig.disableViewList.contains( action ) )return;
  159. if( this.meetingConfig[ action + "ViewName" ] ){
  160. text = this.meetingConfig[ action + "ViewName" ];
  161. }
  162. var actionNode = new Element("div", {"styles": this.css.topMenuNode}).inject(this.topMenu);
  163. var actionIconNode = new Element("div", {"styles": this.css.topMenuIconNode}).inject(actionNode);
  164. actionIconNode.setStyle("background", "url(/x_component_Meeting/$Main/default/icon/"+icon+".png) no-repeat center center");
  165. var actionTextNode = new Element("div", {"styles": this.css.topMenuTextNode, "text": text}).inject(actionNode);
  166. actionNode.store("icon",icon);
  167. actionNode.store("iconNode",actionIconNode);
  168. actionNode.store("action",action);
  169. var _self = this;
  170. actionNode.addEvents({
  171. "mouseover": function(){
  172. if( this.node != _self.currentTopMenuNode ){
  173. this.node.setStyles(_self.css.topMenuNode_over);
  174. this.node.retrieve("iconNode").setStyle( "background","url(/x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  175. }
  176. }.bind( { node : actionNode } ),
  177. "mouseout": function(){
  178. if(this.node != _self.currentTopMenuNode){
  179. this.node.setStyles(_self.css.topMenuNode);
  180. this.node.retrieve("iconNode").setStyle( "background","url(/x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" );
  181. }
  182. }.bind({ node:actionNode }),
  183. //"mousedown": function(){this.setStyles(_self.css.topMenuNode_down);},
  184. //"mouseup": function(){this.setStyles(_self.css.topMenuNode_over);},
  185. "click": function(){
  186. if( this.node != _self.currentTopMenuNode ){
  187. this.node.setStyles( _self.css.topMenuNode_down );
  188. this.node.retrieve("iconNode").setStyle( "background","url(/x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  189. }
  190. if( _self.currentTopMenuNode && this.node != _self.currentTopMenuNode){
  191. _self.currentTopMenuNode.setStyles( _self.css.topMenuNode );
  192. _self.currentTopMenuNode.retrieve("iconNode").setStyle( "background","url(/x_component_Meeting/$Main/default/icon/"+_self.currentTopMenuNode.retrieve("icon")+".png) no-repeat center center" );
  193. }
  194. _self.currentTopMenuNode = this.node;
  195. if (_self[action]) _self[action].apply(_self);
  196. }.bind({ node : actionNode })
  197. });
  198. if( this.defaultAction ){
  199. if( this.defaultAction == action ){
  200. actionNode.click();
  201. }
  202. }else if( !this.loaded ){
  203. actionNode.click();
  204. this.loaded = true;
  205. }
  206. return actionNode;
  207. },
  208. hideMenu: function(){
  209. },
  210. showMenu: function(){
  211. if (this.menuMode!="show") {
  212. this.topMenu.set("tween", {duration: 100, transition: "bounce:out"});
  213. //this.bottomMenu.set("tween", {duration: 100, transition: "bounce:out"});
  214. this.topMenu.tween("top", "-50px", "0px");
  215. //this.bottomMenu.tween("bottom", "-50px", "0px");
  216. this.menuMode = "show";
  217. if (this.topMenuPoint) this.topMenuPoint.setStyle("display", "none");
  218. if (this.bottomMenuPoint) this.bottomMenuPoint.setStyle("display", "none");
  219. }
  220. },
  221. hideCurrentView: function(){
  222. if (this.currentView){
  223. this.currentView.hide();
  224. this.currentView = null;
  225. }
  226. },
  227. toMyMeeting: function(){
  228. this.contentNode.setStyles(this.css.contentNode);
  229. //if ((!this.myMeetingView) || this.currentView!=this.myMeetingView){
  230. // this.hideCurrentView();
  231. // this.getMyMeetingView(function(){
  232. // this.myMeetingView.show();
  233. // this.currentView = this.myMeetingView;
  234. // }.bind(this));
  235. //}
  236. if( this.currentView ){
  237. this.currentView.destroy();
  238. this.currentView = null;
  239. }
  240. this.myMeetingView = null;
  241. this.getMyMeetingView(function(){
  242. this.myMeetingView.show();
  243. this.currentView = this.myMeetingView;
  244. }.bind(this));
  245. },
  246. getMyMeetingView: function(callback){
  247. if (!this.myMeetingView){
  248. MWF.xDesktop.requireApp("Meeting", "MeetingView", function(){
  249. var options;
  250. if( this.status && this.status.options ){
  251. options = this.status.options
  252. }
  253. this.myMeetingView = new MWF.xApplication.Meeting.MeetingView(this.contentNode, this, options);
  254. if( options )this.status.options = null;
  255. if (callback) callback();
  256. }.bind(this));
  257. }else{
  258. if (callback) callback();
  259. }
  260. },
  261. toList: function(){
  262. this.contentNode.setStyle("background", "#EEE");
  263. //if ((!this.listView) || this.currentView!=this.listView){
  264. // this.hideCurrentView();
  265. // this.getListView(function(){
  266. // this.listView.show();
  267. // this.currentView = this.listView;
  268. // }.bind(this));
  269. //}
  270. if( this.currentView ){
  271. this.currentView.destroy();
  272. this.currentView = null;
  273. }
  274. this.listView = null;
  275. this.getListView(function(){
  276. this.listView.show();
  277. this.currentView = this.listView;
  278. }.bind(this));
  279. },
  280. getListView: function(callback){
  281. if (!this.listView){
  282. MWF.xDesktop.requireApp("Meeting", "ListView", function(){
  283. var options;
  284. if( this.status && this.status.options ){
  285. options = this.status.options
  286. }
  287. this.listView = new MWF.xApplication.Meeting.ListView(this.contentNode, this, options);
  288. if( options )this.status.options = null;
  289. if (callback) callback();
  290. }.bind(this));
  291. }else{
  292. if (callback) callback();
  293. }
  294. },
  295. toMonth: function(){
  296. this.contentNode.setStyle("background", "#EEE");
  297. //if ((!this.monthView) || this.currentView!=this.monthView){
  298. // this.hideCurrentView();
  299. // this.getMonthView(function(){
  300. // this.monthView.show();
  301. // this.currentView = this.monthView;
  302. // }.bind(this));
  303. //}
  304. if( this.currentView ){
  305. this.currentView.destroy();
  306. this.currentView = null;
  307. }
  308. this.monthView = null;
  309. this.getMonthView(function(){
  310. this.monthView.show();
  311. this.currentView = this.monthView;
  312. }.bind(this));
  313. },
  314. getMonthView: function(callback){
  315. if (!this.monthView){
  316. MWF.xDesktop.requireApp("Meeting", "MonthView", function(){
  317. var options;
  318. if( this.status && this.status.options ){
  319. options = this.status.options
  320. }
  321. this.monthView = new MWF.xApplication.Meeting.MonthView(this.contentNode, this, options);
  322. if( options )this.status.options = null;
  323. if (callback) callback();
  324. }.bind(this));
  325. }else{
  326. if (callback) callback();
  327. }
  328. },
  329. toWeek: function(){
  330. this.contentNode.setStyle("background", "#EEE");
  331. //if ((!this.monthView) || this.currentView!=this.monthView){
  332. // this.hideCurrentView();
  333. // this.getMonthView(function(){
  334. // this.monthView.show();
  335. // this.currentView = this.monthView;
  336. // }.bind(this));
  337. //}
  338. if( this.currentView ){
  339. this.currentView.destroy();
  340. this.currentView = null;
  341. }
  342. this.weekView = null;
  343. this.getWeekView(function(){
  344. this.weekView.show();
  345. this.currentView = this.weekView;
  346. }.bind(this));
  347. },
  348. getWeekView: function(callback){
  349. if (!this.weekView){
  350. MWF.xDesktop.requireApp("Meeting", "WeekView", function(){
  351. var options;
  352. if( this.status && this.status.options ){
  353. options = this.status.options
  354. }
  355. this.weekView = new MWF.xApplication.Meeting.WeekView(this.contentNode, this, options);
  356. if( options )this.status.options = null;
  357. if (callback) callback();
  358. }.bind(this));
  359. }else{
  360. if (callback) callback();
  361. }
  362. },
  363. toDay: function(d){
  364. this.contentNode.setStyle("background", "#EEE");
  365. //if ((!this.dayView) || this.currentView!=this.dayView){
  366. // this.hideCurrentView();
  367. // this.getDayView(function(){
  368. // this.dayView.show();
  369. // this.currentView = this.dayView;
  370. // }.bind(this), d);
  371. //}
  372. if( this.currentView ){
  373. this.currentView.destroy();
  374. this.currentView = null;
  375. }
  376. this.dayView = null;
  377. this.getDayView(function(){
  378. this.dayView.show();
  379. this.currentView = this.dayView;
  380. }.bind(this), d);
  381. },
  382. getDayView: function(callback, d){
  383. if (!this.dayView){
  384. MWF.xDesktop.requireApp("Meeting", "DayView", function(){
  385. var options;
  386. if( this.status && this.status.options ){
  387. options = this.status.options
  388. }
  389. this.dayView = new MWF.xApplication.Meeting.DayView(this.contentNode, this, options || {"date": d});
  390. if(this.status)this.status.options = null;
  391. if (callback) callback();
  392. }.bind(this));
  393. }else{
  394. this.dayView.toDay(d);
  395. if (callback) callback();
  396. }
  397. },
  398. toRoom: function(){
  399. this.contentNode.setStyle("background", "#EEE");
  400. //if ((!this.roomView) || this.currentView!=this.roomView){
  401. // this.hideCurrentView();
  402. // this.getRoomView(function(){
  403. // this.roomView.show();
  404. // this.currentView = this.roomView;
  405. // }.bind(this));
  406. //}
  407. if( this.currentView ){
  408. this.currentView.destroy();
  409. this.currentView = null;
  410. }
  411. this.roomView = null;
  412. this.getRoomView(function(){
  413. this.roomView.show();
  414. this.currentView = this.roomView;
  415. }.bind(this));
  416. },
  417. getRoomView: function(callback){
  418. if (!this.roomView){
  419. MWF.xDesktop.requireApp("Meeting", "RoomView", function(){
  420. var options;
  421. if( this.status && this.status.options ){
  422. options = this.status.options
  423. }
  424. this.roomView = new MWF.xApplication.Meeting.RoomView(this.contentNode, this, options);
  425. if( options )this.status.options = null;
  426. if (callback) callback();
  427. }.bind(this));
  428. }else{
  429. if (callback) callback();
  430. }
  431. },
  432. //refresh: function(){
  433. // //this.hideMenu();
  434. // if (this.currentView) this.currentView.reload();
  435. //},
  436. addMeeting: function(date, hour, minute, room, processData, latest){
  437. MWF.UD.getPublicData("meetingConfig", function(json){
  438. var process = (json) ? json.process : null;
  439. if (process){
  440. this.loadMeetingProcess(process, processData, latest);
  441. }else{
  442. //new MWF.xApplication.Meeting.Creator(this, date, hour, room);
  443. var form = new MWF.xApplication.Meeting.MeetingForm(this,{}, {
  444. date : date,
  445. hour : hour,
  446. minute : minute,
  447. room : room
  448. }, {app:this});
  449. form.view = this;
  450. form.create();
  451. //this.hideMenu();
  452. }
  453. }.bind(this));
  454. },
  455. loadMeetingProcess: function(id, processData, latest){
  456. this.getProcess(id, function(process){
  457. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  458. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(process, this, {
  459. "latest" : latest,
  460. "workData" : processData,
  461. "onStarted": function(data, title, processName){
  462. this.afterStartProcess(data, title, processName);
  463. }.bind(this)
  464. });
  465. starter.load();
  466. }.bind(this));
  467. }.bind(this));
  468. },
  469. afterStartProcess: function(data, title, processName){
  470. var workInfors = [];
  471. var currentTask = [];
  472. data.each(function(work){
  473. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  474. workInfors.push(this.getStartWorkInforObj(work));
  475. }.bind(this));
  476. if (currentTask.length===1){
  477. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  478. this.desktop.openApplication(null, "process.Work", options);
  479. this.createStartWorkResault(workInfors, title, processName, false);
  480. }else{
  481. this.createStartWorkResault(workInfors, title, processName, true);
  482. }
  483. },
  484. createStartWorkResault: function(workInfors, title, processName, isopen){
  485. var content = "";
  486. workInfors.each(function(infor){
  487. var users = [];
  488. infor.users.each(function(uname){
  489. users.push(MWF.name.cn(uname));
  490. });
  491. content += "<div><b>"+this.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  492. if (infor.currentTask && isopen){
  493. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.lp.deal+"</span></div>";
  494. }else{
  495. content += "</div>";
  496. }
  497. }.bind(this));
  498. var t = workInfors[0].title || title;
  499. var msg = {
  500. "subject": this.lp.processStarted,
  501. "content": "<div>"+this.lp.processStartedMessage+"“["+processName+"]"+t+"”</div>"+content
  502. };
  503. var tooltip = layout.desktop.message.addTooltip(msg);
  504. var item = layout.desktop.message.addMessage(msg);
  505. this.setStartWorkResaultAction(tooltip);
  506. this.setStartWorkResaultAction(item);
  507. },
  508. getStartWorkInforObj: function(work){
  509. var title = "";
  510. var users = [];
  511. var currentTask = "";
  512. work.taskList.each(function(task, idx){
  513. title = task.title;
  514. users.push(task.person+"("+task.department + ")");
  515. if (work.currentTaskIndex===idx) currentTask = task.id;
  516. }.bind(this));
  517. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask, "title" : title };
  518. },
  519. setStartWorkResaultAction: function(item){
  520. var node = item.node.getElements("span");
  521. node.setStyles(this.css.dealStartedWorkAction);
  522. var _self = this;
  523. node.addEvent("click", function(e){
  524. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  525. _self.desktop.openApplication(e, "process.Work", options);
  526. });
  527. },
  528. getProcess: function(id, callback){
  529. // MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  530. // var action = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  531. // action.getProcess(id, function(json){
  532. if (callback) callback(id);
  533. // }.bind(this));
  534. // }.bind(this));
  535. },
  536. config: function(){
  537. new MWF.xApplication.Meeting.Config(this, this.meetingConfig);
  538. //this.hideMenu();
  539. },
  540. addRoom : function(){
  541. var form = new MWF.xApplication.Meeting.RoomForm(this,{}, {}, {app:this});
  542. form.view = this;
  543. form.create();
  544. //this.hideMenu();
  545. },
  546. recordStatus: function(){
  547. //alert( JSON.stringify(
  548. // {
  549. // action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  550. // options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  551. // }
  552. //) )
  553. return {
  554. action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  555. options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  556. };
  557. },
  558. reload: function( ){
  559. if( this.inContainer ){
  560. if( this.currentView && this.currentView.reload ){
  561. this.currentView.reload();
  562. }
  563. }else{
  564. this.refresh()
  565. }
  566. },
  567. loadSideBar : function(){
  568. this.sideBar = new MWF.xApplication.Meeting.SideBar(this.node, this);
  569. this.sideBar.show();
  570. },
  571. isMeetingViewer : function( callback ){
  572. if( typeOf( this._isMeetingViewer ) == "boolean"){
  573. if(callback)callback( this._isMeetingViewer );
  574. return;
  575. }
  576. var meetingViewer = this.meetingConfig.meetingViewer;
  577. if( !meetingViewer || !meetingViewer.length ){
  578. this._isMeetingViewer = false;
  579. if(callback)callback( this._isMeetingViewer );
  580. return;
  581. }
  582. if( this.isManager ){
  583. this._isMeetingViewer = true;
  584. if(callback)callback( this._isMeetingViewer );
  585. return;
  586. }
  587. if( typeOf( meetingViewer ) != "array" )meetingViewer = [meetingViewer];
  588. MWF.Actions.get("x_organization_assemble_personal").getPerson(function( json ){
  589. //this.actions.getCurrentPerson( function( json ){
  590. var dn = json.data.distinguishedName;
  591. //var dn = this.desktop.session.user.distinguishedName;
  592. if( meetingViewer.contains( dn ) ){
  593. this._isMeetingViewer = true;
  594. if(callback)callback( this._isMeetingViewer );
  595. return;
  596. }
  597. for( var i=0; i<json.data.woGroupList.length; i++ ){
  598. if( meetingViewer.contains( json.data.woGroupList[i].distinguishedName ) ){
  599. this._isMeetingViewer = true;
  600. if(callback)callback( this._isMeetingViewer );
  601. return;
  602. }
  603. }
  604. //var personList = [ dn ];
  605. this.personActions.listUnitSupNestedWithPersonValue({"personList":[dn]}, function(js){
  606. for( var i=0; i<js.data.unitList.length; i++ ){
  607. if( meetingViewer.contains( js.data.unitList[i] ) ){
  608. this._isMeetingViewer = true;
  609. if(callback)callback( this._isMeetingViewer );
  610. return;
  611. }
  612. }
  613. this._isMeetingViewer = false;
  614. if(callback)callback( this._isMeetingViewer );
  615. }.bind(this),null, false );
  616. }.bind(this), null, false)
  617. }
  618. });
  619. MWF.xApplication.Meeting.Config = new Class({
  620. Implements: [Events],
  621. initialize: function(app){
  622. this.app = app;
  623. this.css = this.app.css;
  624. this.lp = this.app.lp;
  625. this.configData = this.app.meetingConfig || {};
  626. this.process = null;
  627. MWF.UD.getPublicData("meetingConfig", function(json){
  628. var jsonData = json || {};
  629. if (jsonData.process){
  630. this.configData.process = jsonData.process;
  631. }else{
  632. this.configData.process = null;
  633. }
  634. if( jsonData.weekBegin ){
  635. this.configData.weekBegin = jsonData.weekBegin;
  636. }
  637. if( jsonData.meetingViewer ){
  638. this.configData.meetingViewer = jsonData.meetingViewer;
  639. }
  640. if( jsonData.mobileCreateEnable ){
  641. this.configData.mobileCreateEnable = jsonData.mobileCreateEnable;
  642. }
  643. for( var key in jsonData ){
  644. if( key != "process" && key != "weekBegin" && key != "meetingViewer" && key !="mobileCreateEnable"){
  645. this.configData[ key ] = jsonData[key];
  646. }
  647. }
  648. this.load();
  649. }.bind(this));
  650. },
  651. load: function(){
  652. this.node = new Element("div", {"styles": this.css.configNode}).inject(this.app.node);
  653. this.contentNode = new Element("div", {"styles": this.css.configContentNode}).inject(this.node);
  654. var statusStyle = "overflow: hidden;margin-top:6px;margin-left:10px;";
  655. var statusIconStyle = "float: left; width: 16px; height: 16px; border-radius: 100px; ";
  656. var statusIconStyle2 = "float: left; width: 14px; height: 14px; border-radius: 100px; ";
  657. var statusTextStyle = "margin-left:35px; line-height:16px; height:16px;font-size:14px;color:#666;";
  658. var viewStyle = "font-size:14px;color:#666;heigh:16px;margin-top:6px;margin-left:10px;";
  659. var inputTextStyle = "float:right; width:120px; border:1px solid #ccc";
  660. var d = this.configData;
  661. var configLp = this.lp.config;
  662. var html =
  663. //"<div class='configTitle'>"+this.lp.config.meetingStatus+"</div>" +
  664. //
  665. //"<div style='"+ statusStyle +"'>"+
  666. //" <div style='"+ statusIconStyle + "background-color:#4990E2'></div>" +
  667. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.wait+"</div></div>" +
  668. //"</div>"+
  669. //
  670. //"<div style='"+ statusStyle +"'>"+
  671. //" <div style='"+ statusIconStyle + "background-color:#66CC7F'></div>" +
  672. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.progress+"</div></div>" +
  673. //"</div>"+
  674. //
  675. //"<div style='"+ statusStyle +"'>"+
  676. //" <div style='"+ statusIconStyle + "background-color:#F6A623'></div>" +
  677. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.invite+"</div></div>" +
  678. //"</div>"+
  679. //
  680. //"<div style='"+ statusStyle +"'>"+
  681. //" <div style='"+ statusIconStyle + "background-color:#ccc'></div>" +
  682. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.completed+"</div></div>" +
  683. //"</div>"+
  684. //
  685. //"<div style='"+ statusStyle +"'>"+
  686. //" <div style='"+ statusIconStyle2 + "border:2px solid #FF7F7F;'></div>" +
  687. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.conflict+"</div></div>" +
  688. //"</div>"+
  689. //
  690. //"<div class='line'></div>" +
  691. "<div class='configTitle'>"+this.lp.config["default"]+"</div>" +
  692. "<div>";
  693. if( !d.disableViewList.contains( "toMyMeeting" ) ){
  694. html +=
  695. " <div style='"+ viewStyle +"'>" +
  696. "<input type='radio' name='configSelectDefaultView' "+(((!d.defaultView) || d.defaultView=="toMyMeeting") ? "checked" : "")+" value='toMyMeeting'>"+ ( d.toMyMeetingViewName || this.lp.myMeeting )+
  697. " </div>";
  698. }
  699. if( !d.disableViewList.contains( "toMonth" ) ){
  700. html +=
  701. " <div style='"+ viewStyle +"'>" +
  702. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toMonth") ? "checked" : "")+" value='toMonth'>"+ ( d.toMonthViewName || this.lp.month )+
  703. " </div>";
  704. }
  705. if( !d.disableViewList.contains( "toWeek" ) ){
  706. html +=
  707. " <div style='"+ viewStyle +"'>" +
  708. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toWeek") ? "checked" : "")+" value='toWeek'>"+( d.toWeekViewName || this.lp.week )+
  709. " </div>";
  710. }
  711. if( !d.disableViewList.contains( "toDay" ) ){
  712. html +=
  713. " <div style='"+ viewStyle +"'>" +
  714. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toDay") ? "checked" : "")+" value='toDay'>"+(d.toDayViewName || this.lp.day)+
  715. " </div>";
  716. }
  717. if( !d.disableViewList.contains( "toList" ) ){
  718. html +=
  719. " <div style='"+ viewStyle +"'>" +
  720. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toList") ? "checked" : "")+" value='toList'>"+(d.toListViewName || this.lp.list)+
  721. " </div>";
  722. }
  723. if( !d.disableViewList.contains( "toRoom" ) ){
  724. html +=
  725. " <div style='"+ viewStyle +"'>" +
  726. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toRoom") ? "checked" : "")+" value='toRoom'>"+(d.toRoomViewName || this.lp.room)+
  727. " </div>";
  728. }
  729. html +="</div>";
  730. if( MWF.AC.isMeetingAdministrator() ){
  731. d.disableViewList = d.disableViewList || [];
  732. html += "<div class='line'></div>"+
  733. "<div class='configTitle'>"+this.lp.config.viewSetting +"</div>" +
  734. "<div>"+
  735. " <div style='"+ viewStyle +"'>" +
  736. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMyMeeting" ) ? "checked" : "")+" value='toMyMeeting'>"+this.lp.myMeeting+
  737. "<input type='text' name='toMyMeetingViewName' value='" + (d.toMyMeetingViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  738. " </div>" +
  739. " <div style='"+ viewStyle +"'>" +
  740. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMonth" ) ? "checked" : "")+" value='toMonth'>"+this.lp.month+
  741. "<input type='text' name='toMonthViewName' value='" + (d.toMonthViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  742. " </div>" +
  743. " <div style='"+ viewStyle +"'>" +
  744. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toWeek" ) ? "checked" : "")+" value='toWeek'>"+this.lp.week+
  745. "<input type='text' name='toWeekViewName' value='" + (d.toWeekViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  746. " </div>" +
  747. " <div style='"+ viewStyle +"'>" +
  748. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toDay" ) ? "checked" : "")+" value='toDay'>"+this.lp.day+
  749. "<input type='text' name='toDayViewName' value='" + (d.toDayViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  750. " </div>" +
  751. " <div style='"+ viewStyle +"'>" +
  752. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toList" ) ? "checked" : "")+" value='toList'>"+this.lp.list+
  753. "<input type='text' name='toListViewName' value='" + (d.toListViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  754. " </div>" +
  755. " <div style='"+ viewStyle +"'>" +
  756. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toRoom" ) ? "checked" : "")+" value='toRoom'>"+this.lp.room+
  757. "<input type='text' name='toRoomViewName' value='" + (d.toRoomViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  758. " </div>" +
  759. "</div>" +
  760. "<div class='line'></div>"+
  761. "<div class='configTitle'>"+this.lp.config.weekBegin +"</div>" +
  762. "<div><select name='configSelectWeekBeign'>"+
  763. "<option value='0' "+((d.weekBegin=="0") ? "selected" : "")+">"+this.lp.weeks.Sun+"</option>"+
  764. "<option value='1' "+((d.weekBegin=="1") ? "selected" : "")+">"+this.lp.weeks.Mon+"</option>"+
  765. //"<option value='2'"+((d.weekBegin=="2") ? "selected" : "")+">"+this.lp.weeks.Tues+"</option>"+
  766. //"<option value='3'"+((d.weekBegin=="3") ? "selected" : "")+">"+this.lp.weeks.Wed+"</option>"+
  767. //"<option value='4'"+((d.weekBegin=="4") ? "selected" : "")+">"+this.lp.weeks.Thur+"</option>"+
  768. //"<option value='5'"+((d.weekBegin=="5") ? "selected" : "")+">"+this.lp.weeks.Fri+"</option>"+
  769. //"<option value='6'"+((d.weekBegin=="6") ? "selected" : "")+">"+this.lp.weeks.Sat+"</option>"+
  770. "</select></div>"+
  771. "<div class='line'></div>"+
  772. "<div class='configTitle'>"+this.lp.config.applyProcess+"</div>" +
  773. "<div item='processArea'></div>" +
  774. //"<div class='line'></div>"+
  775. "<div class='configTitle' title='"+ this.lp.config.meetingViewerTitle +"'>"+this.lp.config.meetingViewer +"</div>" +
  776. "<div item='meetingViewerNode'></div>" +
  777. "<div class='configTitle'>"+this.lp.config.mobileCreateEnable +"</div>" +
  778. "<div item='mobileCreateEnable'></div>";
  779. }
  780. this.contentNode.set("html", html);
  781. this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  782. this.contentNode.getElements("div.configTitle").setStyles(this.css.configTitleDiv);
  783. if( MWF.AC.isMeetingAdministrator() ){
  784. this.processNode = this.contentNode.getElement("[item='processArea']");
  785. this.processNode.setStyles(this.css.configProcessNode);
  786. this.createApplicationSelect();
  787. this.meetingViewerNode = this.contentNode.getElement("[item='meetingViewerNode']");
  788. //this.meetingViewerNode.setStyles(this.css.configProcessNode);
  789. this.meetingViewer = new MDomItem(this.meetingViewerNode, {
  790. name : "meetingViewer", type : "org", orgType : ["person","unit","group"], count : 0, style : this.css.configMeetingViewerNode,
  791. value : d.meetingViewer || []
  792. } , null, this.app );
  793. this.meetingViewer.load();
  794. this.mobileCreateEnableNode = this.contentNode.getElement("[item='mobileCreateEnable']");
  795. this.mobileCreateEnable = new MDomItem(this.mobileCreateEnableNode, {
  796. name : "mobileCreateEnable", type : "select", selectValue : ["true","false"], selectText : this.lp.config.mobileCreateEnableOptions,
  797. value : d.mobileCreateEnable || "true"
  798. } , null, this.app );
  799. this.mobileCreateEnable.load();
  800. }
  801. this.actionNode = new Element("div", {"styles": this.css.configActionNode}).inject(this.node);
  802. this.cancelNode = new Element("div", {"styles": this.css.configActionCancelNode, "text": this.app.lp.cancel}).inject(this.actionNode);
  803. this.saveNode = new Element("div", {"styles": this.css.configActionSaveNode, "text": this.app.lp.save}).inject(this.actionNode);
  804. this.cancelNode.addEvent("click", this.hide.bind(this));
  805. this.saveNode.addEvent("click", this.save.bind(this));
  806. this.node.addEvent("mousedown", function(e){e.stopPropagation();}.bind(this));
  807. this.setSize();
  808. this.show();
  809. },
  810. setSize : function(){
  811. var sizeY = this.node.getSize().y;
  812. var y = this.app.content.getSize().y;
  813. if( sizeY > y-50 ){
  814. this.node.setStyle("height", y-50 );
  815. }
  816. },
  817. createApplicationSelect: function(){
  818. if (this.configData.process){
  819. MWF.require("MWF.widget.O2Identity", function(){
  820. var p = new MWF.widget.O2Process(this.configData.process, this.processNode);
  821. }.bind(this));
  822. }
  823. this.processNode.addEvent("click", function(){
  824. MWF.xDesktop.requireApp("Selector", "package", function(){
  825. var options = {
  826. "type": "Process",
  827. "values": [this.process || this.configData.process],
  828. "count": 1,
  829. "onComplete": function (items) {
  830. this.processNode.empty();
  831. this.process = null;
  832. this.configData.process = null;
  833. if (items.length){
  834. MWF.require("MWF.widget.O2Identity", function(){
  835. var p = new MWF.widget.O2Process(items[0].data, this.processNode);
  836. this.process = {
  837. "name": items[0].data.name,
  838. "id": items[0].data.id,
  839. "application": items[0].data.application,
  840. "applicationName": items[0].data.applicationName,
  841. "alias": items[0].data.alias
  842. };
  843. this.configData.process = this.process;
  844. }.bind(this));
  845. }
  846. }.bind(this)
  847. };
  848. var selector = new MWF.O2Selector(this.app.content, options);
  849. }.bind(this));
  850. }.bind(this));
  851. },
  852. save: function(){
  853. //var hideMenu = "auto";
  854. var defaultView = "toMyMeeting";
  855. var process = null;
  856. //var node = this.contentNode.getFirst("div");
  857. //var hideMenuNode = node.getElement("input");
  858. //if (hideMenuNode) if (!hideMenuNode.checked) hideMenu = "static";
  859. //node = node.getNext();
  860. var viewNodes = this.contentNode.getElements("input[name='configSelectDefaultView']");
  861. for (var i=0; i<viewNodes.length; i++){
  862. if (viewNodes[i].checked){
  863. defaultView = viewNodes[i].get("value");
  864. break;
  865. }
  866. }
  867. MWF.UD.putData("meetingConfig", {
  868. //"hideMenu": hideMenu,
  869. "defaultView": defaultView
  870. }, null, false);
  871. if( MWF.AC.isMeetingAdministrator() ){
  872. //if (this.processSelect){
  873. //process = this.processSelect.options[this.processSelect.selectedIndex].get("value");
  874. //MWF.UD.putPublicData("meetingConfig", {"process": process});
  875. //}
  876. var disableViewList = [];
  877. var viewAvailableNodes = this.contentNode.getElements("input[name='configAvailableView']");
  878. for (var i=0; i<viewAvailableNodes.length; i++){
  879. if ( !viewAvailableNodes[i].checked){
  880. disableViewList.push( viewAvailableNodes[i].get("value") ) ;
  881. }
  882. }
  883. var weekBeginSelect = this.contentNode.getElement("select[name='configSelectWeekBeign']");
  884. var weekBeginValue = "0";
  885. if( weekBeginSelect ){
  886. weekBeginValue = weekBeginSelect.options[weekBeginSelect.selectedIndex].get("value");
  887. }
  888. var viewer = null;
  889. if( this.meetingViewer ){
  890. viewer = this.meetingViewer.getValue();
  891. }
  892. MWF.UD.putPublicData("meetingConfig", {
  893. //"hideMenu": hideMenu,
  894. "process": this.process || this.configData.process,
  895. "weekBegin" : weekBeginValue,
  896. "meetingViewer" : viewer,
  897. "mobileCreateEnable" : this.mobileCreateEnable.getValue(),
  898. "disableViewList" : disableViewList,
  899. "toMyMeetingViewName" : this.contentNode.getElement("input[name='toMyMeetingViewName']").get("value"),
  900. "toMonthViewName" : this.contentNode.getElement("input[name='toMonthViewName']").get("value"),
  901. "toWeekViewName" : this.contentNode.getElement("input[name='toWeekViewName']").get("value"),
  902. "toDayViewName" : this.contentNode.getElement("input[name='toDayViewName']").get("value"),
  903. "toListViewName" : this.contentNode.getElement("input[name='toListViewName']").get("value"),
  904. "toRoomViewName" : this.contentNode.getElement("input[name='toRoomViewName']").get("value")
  905. }, null, false);
  906. }
  907. this.app.notice( this.app.lp.config_saveSuccess, "success" );
  908. this.hide();
  909. },
  910. show: function(){
  911. this.node.setStyles(this.css.configNode);
  912. var fx = new Fx.Morph(this.node, {
  913. "duration": "500",
  914. "transition": Fx.Transitions.Expo.easeOut
  915. });
  916. fx.start({
  917. "opacity": 1
  918. }).chain(function(){
  919. this.hideFun = this.hide.bind(this);
  920. this.app.node.addEvent("mousedown", this.hideFun);
  921. }.bind(this));
  922. },
  923. hide: function(){
  924. this.node.destroy();
  925. this.app.node.removeEvent("mousedown", this.hideFun);
  926. MWF.release(this);
  927. }
  928. });