Main.js 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318
  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. o2.Actions.load("x_meeting_assemble_control").ConfigAction.getSystemConfig(function(json){
  35. var jsonData = json.data;
  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. if( !this.meetingConfig.typeList ){
  54. this.meetingConfig.typeList = [];
  55. }else{
  56. this.meetingConfig.typeList = this.meetingConfig.typeList.filter(function(t){return !!t});
  57. }
  58. this.createNode();
  59. if (!this.options.isRefresh) {
  60. this.maxSize(function () {
  61. this.loadLayout();
  62. }.bind(this));
  63. } else {
  64. this.loadLayout();
  65. }
  66. if (callback) callback();
  67. }.bind(this));
  68. }.bind(this));
  69. },
  70. createNode: function(){
  71. this.content.setStyle("overflow", "hidden");
  72. this.node = new Element("div", {
  73. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  74. }).inject(this.content);
  75. },
  76. loadLayout: function(){
  77. this.content.loadCss("../x_component_Meeting/$Main/default/style.css");
  78. if( this.status && this.status.action ){
  79. this.defaultAction = this.status.action;
  80. }else if (this.meetingConfig.defaultView){
  81. this.defaultAction = this.meetingConfig.defaultView;
  82. }else{
  83. this.defaultAction = "toMyMeeting";
  84. }
  85. if( this.meetingConfig.disableViewList.contains( this.defaultAction ) ){
  86. this.defaultAction = "";
  87. }
  88. this.topMenu = new Element("div", {"styles": this.css.topMenu}).inject(this.node);
  89. this.contentNode = new Element("div.contentNode", {"styles": this.inContainer ? this.css.contentNode_inContainer : this.css.contentNode}).inject(this.node);
  90. //this.bottomMenu = new Element("div", {"styles": this.css.bottomMenu}).inject(this.node);
  91. this.loadTopMenus();
  92. if( this.options.sideBarEnable ){
  93. this.loadSideBar();
  94. }
  95. //this.loadBottomMenus();
  96. //this.hideMenu();
  97. //
  98. //this.node.addEvent("contextmenu", function(e){
  99. // if (this.menuMode=="show"){
  100. // this.hideMenu();
  101. // }else{
  102. // this.showMenu();
  103. // }
  104. // e.preventDefault();
  105. //}.bind(this));
  106. this.setEvent();
  107. },
  108. isOnlineAvailable: function(){
  109. return !!this.meetingConfig.enableOnline;
  110. },
  111. isAutoCreateOnlineRoom: function(){
  112. return this.meetingConfig.enableOnline && this.meetingConfig.onlineProduct === "好视通"
  113. },
  114. isCopyEnable: function(){
  115. return Promise.resolve(false);
  116. // if( typeOf(this.copyEnable) === "boolean" )return Promise.resolve(this.copyEnable);
  117. // var text = " ";
  118. // if (navigator.clipboard) {
  119. // return navigator.clipboard.writeText(text).then(function() {
  120. // this.copyEnable = true;
  121. // return this.copyEnable;
  122. // }.bind(this), function(err) {
  123. // this.copyEnable = false;
  124. // return this.copyEnable;
  125. // });
  126. // }else{
  127. // var textArea = document.createElement("textarea");
  128. // textArea.value = text;
  129. // // Avoid scrolling to bottom
  130. // textArea.style.top = "0";
  131. // textArea.style.left = "0";
  132. // textArea.style.position = "fixed";
  133. // document.body.appendChild(textArea);
  134. // textArea.focus();
  135. // textArea.select();
  136. // try {
  137. // var successful = document.execCommand('copy');
  138. // this.copyEnable = successful;
  139. // } catch (err) {
  140. // this.copyEnable = false
  141. // }
  142. // document.body.removeChild(textArea);
  143. // return Promise.resolve(this.copyEnable);
  144. // }
  145. },
  146. copyTextToClipboard: function(text) {
  147. if (!navigator.clipboard) {
  148. this.fallbackCopyTextToClipboard(text);
  149. return;
  150. }
  151. navigator.clipboard.writeText(text);
  152. },
  153. fallbackCopyTextToClipboard: function(text) {
  154. var textArea = document.createElement("textarea");
  155. textArea.value = text;
  156. // Avoid scrolling to bottom
  157. textArea.style.top = "0";
  158. textArea.style.left = "0";
  159. textArea.style.position = "fixed";
  160. document.body.appendChild(textArea);
  161. textArea.focus();
  162. textArea.select();
  163. try {
  164. var successful = document.execCommand('copy');
  165. } catch (err) {
  166. }
  167. document.body.removeChild(textArea);
  168. },
  169. setEvent: function(){
  170. //this.topMenu.addEvent("mouseover", function(){this.showMenu();}.bind(this));
  171. //this.topMenu.addEvent("mouseout", function(){this.hideMenu();}.bind(this));
  172. //this.bottomMenu.addEvent("mouseover", function(){this.showMenu();}.bind(this));
  173. //this.bottomMenu.addEvent("mouseout", function(){this.hideMenu();}.bind(this));
  174. //this.contentNode.addEvent("click", function(){this.hideMenu();}.bind(this));
  175. },
  176. loadTopMenus_right: function(){
  177. this.topMenuRight = new Element("div", {"styles": this.css.topMenuRight }).inject(this.topMenu);
  178. this.createTopMenu_right(this.lp.addMeeting, "o2icon-create", "addMeeting");
  179. if (this.isManager)this.createTopMenu_right(this.lp.addRoom, "o2icon-icon_newhuiyishi", "addRoom");
  180. //var refreshNode = this.createTopMenu_right(this.lp.refresh, "refresh", "refresh");
  181. //refreshNode.setStyle("float", "right");
  182. if( this.options.settingEnable ){
  183. var configNode = this.createTopMenu_right(this.lp.setting, "o2icon-config", "config");
  184. configNode.setStyle("float", "right");
  185. }
  186. },
  187. createTopMenu_right : function(text, icon, action){
  188. var actionNode = new Element("div", {"styles": this.css.topMenuNode_right, "title" : text}).inject(this.topMenuRight);
  189. var actionIconNode = new Element("div."+icon, {"styles": this.css.topMenuIconNode}).inject(actionNode);
  190. var actionTextNode = new Element("div",{styles: this.css.topMenuTextNode, "text":text}).inject(actionNode);
  191. //actionIconNode.setStyle("background", "url(../x_component_Meeting/$Main/default/icon/"+icon+".png) no-repeat center center");
  192. actionNode.store("icon",icon);
  193. actionNode.store("iconNode",actionIconNode);
  194. var _self = this;
  195. actionNode.addEvents({
  196. "mouseover": function(){
  197. this.node.setStyles(_self.css.topMenuNode_over);
  198. this.node.addClass("mainColor_color");
  199. this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode_over ).addClass("mainColor_color");
  200. //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  201. }.bind( { node : actionNode } ),
  202. "mouseout": function(){
  203. this.node.setStyles(_self.css.topMenuNode_right);
  204. this.node.removeClass("mainColor_color");
  205. this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode ).removeClass("mainColor_color");
  206. //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" );
  207. }.bind({ node:actionNode }),
  208. "click": function(){
  209. this.node.setStyles(_self.css.topMenuNode_down);
  210. //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  211. if (_self[action]) _self[action].apply(_self);
  212. }.bind({ node : actionNode })
  213. });
  214. return actionNode;
  215. },
  216. loadTopMenus: function(){
  217. this.createTopMenu(this.lp.myMeeting, "o2icon-person", "toMyMeeting");
  218. this.createTopMenu(this.lp.month, "o2icon-month", "toMonth");
  219. this.createTopMenu(this.lp.week, "o2icon-week", "toWeek");
  220. this.createTopMenu(this.lp.day, "o2icon-day", "toDay");
  221. this.createTopMenu(this.lp.list, "o2icon-list", "toList");
  222. this.createTopMenu(this.lp.room, "o2icon-home", "toRoom");
  223. this.loadTopMenus_right();
  224. },
  225. isViewAvailable : function( action ){
  226. return !this.meetingConfig.disableViewList.contains( action );
  227. },
  228. createTopMenu: function(text, icon, action){
  229. if( this.meetingConfig.disableViewList.contains( action ) )return;
  230. if( this.meetingConfig[ action + "ViewName" ] ){
  231. text = this.meetingConfig[ action + "ViewName" ];
  232. }
  233. var actionNode = new Element("div", {"styles": this.css.topMenuNode}).inject(this.topMenu);
  234. var actionIconNode = new Element("div."+icon, {"styles": this.css.topMenuIconNode}).inject(actionNode);
  235. //actionIconNode.setStyle("background", "url(../x_component_Meeting/$Main/default/icon/"+icon+".png) no-repeat center center");
  236. var actionTextNode = new Element("div", {"styles": this.css.topMenuTextNode, "text": text}).inject(actionNode);
  237. actionNode.store("icon",icon);
  238. actionNode.store("iconNode",actionIconNode);
  239. actionNode.store("action",action);
  240. var _self = this;
  241. actionNode.addEvents({
  242. "mouseover": function(){
  243. if( this.node != _self.currentTopMenuNode ){
  244. this.node.setStyles(_self.css.topMenuNode_over);
  245. this.node.addClass("mainColor_color");
  246. this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode_over ).addClass("mainColor_color");
  247. //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  248. }
  249. }.bind( { node : actionNode } ),
  250. "mouseout": function(){
  251. if(this.node != _self.currentTopMenuNode){
  252. this.node.setStyles(_self.css.topMenuNode);
  253. this.node.removeClass("mainColor_color");
  254. this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode ).removeClass("mainColor_color");
  255. //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" );
  256. }
  257. }.bind({ node:actionNode }),
  258. //"mousedown": function(){this.setStyles(_self.css.topMenuNode_down);},
  259. //"mouseup": function(){this.setStyles(_self.css.topMenuNode_over);},
  260. "click": function(){
  261. if( this.node != _self.currentTopMenuNode ){
  262. this.node.setStyles( _self.css.topMenuNode_down );
  263. this.node.addClass("mainColor_color");
  264. this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode_over ).addClass("mainColor_color");
  265. //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  266. }
  267. if( _self.currentTopMenuNode && this.node != _self.currentTopMenuNode){
  268. _self.currentTopMenuNode.setStyles( _self.css.topMenuNode );
  269. _self.currentTopMenuNode.removeClass("mainColor_color");
  270. _self.currentTopMenuNode.retrieve("iconNode").setStyles( _self.css.topMenuIconNode ).removeClass("mainColor_color");
  271. //_self.currentTopMenuNode.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+_self.currentTopMenuNode.retrieve("icon")+".png) no-repeat center center" );
  272. }
  273. _self.currentTopMenuNode = this.node;
  274. if (_self[action]) _self[action].apply(_self);
  275. }.bind({ node : actionNode })
  276. });
  277. if( this.defaultAction ){
  278. if( this.defaultAction == action ){
  279. actionNode.click();
  280. }
  281. }else if( !this.loaded ){
  282. actionNode.click();
  283. this.loaded = true;
  284. }
  285. return actionNode;
  286. },
  287. hideMenu: function(){
  288. },
  289. showMenu: function(){
  290. if (this.menuMode!="show") {
  291. this.topMenu.set("tween", {duration: 100, transition: "bounce:out"});
  292. //this.bottomMenu.set("tween", {duration: 100, transition: "bounce:out"});
  293. this.topMenu.tween("top", "-50px", "0px");
  294. //this.bottomMenu.tween("bottom", "-50px", "0px");
  295. this.menuMode = "show";
  296. if (this.topMenuPoint) this.topMenuPoint.setStyle("display", "none");
  297. if (this.bottomMenuPoint) this.bottomMenuPoint.setStyle("display", "none");
  298. }
  299. },
  300. hideCurrentView: function(){
  301. if (this.currentView){
  302. this.currentView.hide();
  303. this.currentView = null;
  304. }
  305. },
  306. toMyMeeting: function(){
  307. this.contentNode.setStyles(this.css.contentNode);
  308. //if ((!this.myMeetingView) || this.currentView!=this.myMeetingView){
  309. // this.hideCurrentView();
  310. // this.getMyMeetingView(function(){
  311. // this.myMeetingView.show();
  312. // this.currentView = this.myMeetingView;
  313. // }.bind(this));
  314. //}
  315. if( this.currentView ){
  316. this.currentView.destroy();
  317. this.currentView = null;
  318. }
  319. this.myMeetingView = null;
  320. this.getMyMeetingView(function(){
  321. this.myMeetingView.show();
  322. this.currentView = this.myMeetingView;
  323. }.bind(this));
  324. },
  325. getMyMeetingView: function(callback){
  326. if (!this.myMeetingView){
  327. MWF.xDesktop.requireApp("Meeting", "MeetingView", function(){
  328. var options;
  329. if( this.status && this.status.options ){
  330. options = this.status.options
  331. }
  332. this.myMeetingView = new MWF.xApplication.Meeting.MeetingView(this.contentNode, this, options);
  333. if( options )this.status.options = null;
  334. if (callback) callback();
  335. }.bind(this));
  336. }else{
  337. if (callback) callback();
  338. }
  339. },
  340. toList: function(){
  341. this.contentNode.setStyle("background", "#EEE");
  342. //if ((!this.listView) || this.currentView!=this.listView){
  343. // this.hideCurrentView();
  344. // this.getListView(function(){
  345. // this.listView.show();
  346. // this.currentView = this.listView;
  347. // }.bind(this));
  348. //}
  349. if( this.currentView ){
  350. this.currentView.destroy();
  351. this.currentView = null;
  352. }
  353. this.listView = null;
  354. this.getListView(function(){
  355. this.listView.show();
  356. this.currentView = this.listView;
  357. }.bind(this));
  358. },
  359. getListView: function(callback){
  360. if (!this.listView){
  361. MWF.xDesktop.requireApp("Meeting", "ListView", function(){
  362. var options;
  363. if( this.status && this.status.options ){
  364. options = this.status.options
  365. }
  366. this.listView = new MWF.xApplication.Meeting.ListView(this.contentNode, this, options);
  367. if( options )this.status.options = null;
  368. if (callback) callback();
  369. }.bind(this));
  370. }else{
  371. if (callback) callback();
  372. }
  373. },
  374. toMonth: function(){
  375. this.contentNode.setStyle("background", "#EEE");
  376. //if ((!this.monthView) || this.currentView!=this.monthView){
  377. // this.hideCurrentView();
  378. // this.getMonthView(function(){
  379. // this.monthView.show();
  380. // this.currentView = this.monthView;
  381. // }.bind(this));
  382. //}
  383. if( this.currentView ){
  384. this.currentView.destroy();
  385. this.currentView = null;
  386. }
  387. this.monthView = null;
  388. this.getMonthView(function(){
  389. this.monthView.show();
  390. this.currentView = this.monthView;
  391. }.bind(this));
  392. },
  393. getMonthView: function(callback){
  394. if (!this.monthView){
  395. MWF.xDesktop.requireApp("Meeting", "MonthView", function(){
  396. var options;
  397. if( this.status && this.status.options ){
  398. options = this.status.options
  399. }
  400. this.monthView = new MWF.xApplication.Meeting.MonthView(this.contentNode, this, options);
  401. if( options )this.status.options = null;
  402. if (callback) callback();
  403. }.bind(this));
  404. }else{
  405. if (callback) callback();
  406. }
  407. },
  408. toWeek: function(){
  409. this.contentNode.setStyle("background", "#EEE");
  410. //if ((!this.monthView) || this.currentView!=this.monthView){
  411. // this.hideCurrentView();
  412. // this.getMonthView(function(){
  413. // this.monthView.show();
  414. // this.currentView = this.monthView;
  415. // }.bind(this));
  416. //}
  417. if( this.currentView ){
  418. this.currentView.destroy();
  419. this.currentView = null;
  420. }
  421. this.weekView = null;
  422. this.getWeekView(function(){
  423. this.weekView.show();
  424. this.currentView = this.weekView;
  425. }.bind(this));
  426. },
  427. getWeekView: function(callback){
  428. if (!this.weekView){
  429. MWF.xDesktop.requireApp("Meeting", "WeekView", function(){
  430. var options;
  431. if( this.status && this.status.options ){
  432. options = this.status.options
  433. }
  434. this.weekView = new MWF.xApplication.Meeting.WeekView(this.contentNode, this, options);
  435. if( options )this.status.options = null;
  436. if (callback) callback();
  437. }.bind(this));
  438. }else{
  439. if (callback) callback();
  440. }
  441. },
  442. toDay: function(d){
  443. this.contentNode.setStyle("background", "#EEE");
  444. //if ((!this.dayView) || this.currentView!=this.dayView){
  445. // this.hideCurrentView();
  446. // this.getDayView(function(){
  447. // this.dayView.show();
  448. // this.currentView = this.dayView;
  449. // }.bind(this), d);
  450. //}
  451. if( this.currentView ){
  452. this.currentView.destroy();
  453. this.currentView = null;
  454. }
  455. this.dayView = null;
  456. this.getDayView(function(){
  457. this.dayView.show();
  458. this.currentView = this.dayView;
  459. }.bind(this), d);
  460. },
  461. getDayView: function(callback, d){
  462. if (!this.dayView){
  463. MWF.xDesktop.requireApp("Meeting", "DayView", function(){
  464. var options;
  465. if( this.status && this.status.options ){
  466. options = this.status.options
  467. }
  468. this.dayView = new MWF.xApplication.Meeting.DayView(this.contentNode, this, options || {"date": d});
  469. if(this.status)this.status.options = null;
  470. if (callback) callback();
  471. }.bind(this));
  472. }else{
  473. this.dayView.toDay(d);
  474. if (callback) callback();
  475. }
  476. },
  477. toRoom: function(){
  478. this.contentNode.setStyle("background", "#EEE");
  479. //if ((!this.roomView) || this.currentView!=this.roomView){
  480. // this.hideCurrentView();
  481. // this.getRoomView(function(){
  482. // this.roomView.show();
  483. // this.currentView = this.roomView;
  484. // }.bind(this));
  485. //}
  486. if( this.currentView ){
  487. this.currentView.destroy();
  488. this.currentView = null;
  489. }
  490. this.roomView = null;
  491. this.getRoomView(function(){
  492. this.roomView.show();
  493. this.currentView = this.roomView;
  494. }.bind(this));
  495. },
  496. getRoomView: function(callback){
  497. if (!this.roomView){
  498. MWF.xDesktop.requireApp("Meeting", "RoomView", function(){
  499. var options;
  500. if( this.status && this.status.options ){
  501. options = this.status.options
  502. }
  503. this.roomView = new MWF.xApplication.Meeting.RoomView(this.contentNode, this, options);
  504. if( options )this.status.options = null;
  505. if (callback) callback();
  506. }.bind(this));
  507. }else{
  508. if (callback) callback();
  509. }
  510. },
  511. //refresh: function(){
  512. // //this.hideMenu();
  513. // if (this.currentView) this.currentView.reload();
  514. //},
  515. addMeeting: function(date, hour, minute, room, processData, latest){
  516. o2.Actions.load("x_meeting_assemble_control").ConfigAction.getSystemConfig(function(json){
  517. var jsonData = json.data;
  518. var process = (jsonData) ? jsonData.process : null;
  519. if (process){
  520. this.loadMeetingProcess(process, processData, latest);
  521. }else{
  522. //new MWF.xApplication.Meeting.Creator(this, date, hour, room);
  523. var form = new MWF.xApplication.Meeting.MeetingForm(this,{}, {
  524. date : date,
  525. hour : hour,
  526. minute : minute,
  527. room : room
  528. }, {app:this});
  529. form.view = this;
  530. form.create();
  531. //this.hideMenu();
  532. }
  533. }.bind(this));
  534. },
  535. loadMeetingProcess: function(id, processData, latest){
  536. this.getProcess(id, function(process){
  537. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  538. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(process, this, {
  539. "latest" : latest,
  540. "workData" : processData,
  541. "onStarted": function(data, title, processName){
  542. this.afterStartProcess(data, title, processName);
  543. }.bind(this)
  544. });
  545. starter.load();
  546. }.bind(this));
  547. }.bind(this));
  548. },
  549. afterStartProcess: function(data, title, processName){
  550. if (data.work){
  551. this.startProcessDraft(data, title, processName);
  552. }else{
  553. this.startProcessInstance(data, title, processName);
  554. }
  555. },
  556. startProcessDraft: function(data, title, processName){
  557. var work = data.work;
  558. var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false,
  559. "onPostClose": function(){
  560. }.bind(this)
  561. };
  562. this.desktop.openApplication(null, "process.Work", options);
  563. },
  564. startProcessInstance: function(data, title, processName){
  565. var workInfors = [];
  566. var currentTask = [];
  567. data.each(function(work){
  568. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  569. workInfors.push(this.getStartWorkInforObj(work));
  570. }.bind(this));
  571. if (currentTask.length===1){
  572. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  573. this.desktop.openApplication(null, "process.Work", options);
  574. this.createStartWorkResault(workInfors, title, processName, false);
  575. }else{
  576. this.createStartWorkResault(workInfors, title, processName, true);
  577. }
  578. },
  579. createStartWorkResault: function(workInfors, title, processName, isopen){
  580. var content = "";
  581. workInfors.each(function(infor){
  582. var users = [];
  583. infor.users.each(function(uname){
  584. users.push(MWF.name.cn(uname));
  585. });
  586. content += "<div><b>"+this.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  587. if (infor.currentTask && isopen){
  588. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.lp.deal+"</span></div>";
  589. }else{
  590. content += "</div>";
  591. }
  592. }.bind(this));
  593. var t = workInfors[0].title || title;
  594. var msg = {
  595. "subject": this.lp.processStarted,
  596. "content": "<div>"+this.lp.processStartedMessage+"“["+processName+"]"+t+"”</div>"+content
  597. };
  598. var tooltip = layout.desktop.message.addTooltip(msg);
  599. var item = layout.desktop.message.addMessage(msg);
  600. this.setStartWorkResaultAction(tooltip);
  601. this.setStartWorkResaultAction(item);
  602. },
  603. getStartWorkInforObj: function(work){
  604. var title = "";
  605. var users = [];
  606. var currentTask = "";
  607. work.taskList.each(function(task, idx){
  608. title = task.title;
  609. users.push(task.person+"("+task.department + ")");
  610. if (work.currentTaskIndex===idx) currentTask = task.id;
  611. }.bind(this));
  612. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask, "title" : title };
  613. },
  614. setStartWorkResaultAction: function(item){
  615. var node = item.node.getElements("span");
  616. node.setStyles(this.css.dealStartedWorkAction);
  617. var _self = this;
  618. node.addEvent("click", function(e){
  619. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  620. _self.desktop.openApplication(e, "process.Work", options);
  621. });
  622. },
  623. getProcess: function(id, callback){
  624. // MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  625. // var action = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  626. // action.getProcess(id, function(json){
  627. if (callback) callback(id);
  628. // }.bind(this));
  629. // }.bind(this));
  630. },
  631. config: function(){
  632. new MWF.xApplication.Meeting.Config(this, this.meetingConfig);
  633. //this.hideMenu();
  634. },
  635. addRoom : function(){
  636. var form = new MWF.xApplication.Meeting.RoomForm(this,{}, {}, {app:this});
  637. form.view = this;
  638. form.create();
  639. //this.hideMenu();
  640. },
  641. recordStatus: function(){
  642. //alert( JSON.stringify(
  643. // {
  644. // action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  645. // options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  646. // }
  647. //) )
  648. return {
  649. action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  650. options : (this.currentView && this.currentView.recordStatus) ? this.currentView.recordStatus() : null
  651. };
  652. },
  653. reload: function( ){
  654. // if( this.inContainer ){
  655. if( this.currentView && this.currentView.reload ){
  656. this.currentView.reload();
  657. }else{
  658. this.refresh()
  659. }
  660. // }else{
  661. // this.refresh()
  662. // }
  663. },
  664. loadSideBar : function(){
  665. this.sideBar = new MWF.xApplication.Meeting.SideBar(this.node, this);
  666. this.sideBar.show();
  667. },
  668. isMeetingViewer : function( callback ){
  669. if( typeOf( this._isMeetingViewer ) == "boolean"){
  670. if(callback)callback( this._isMeetingViewer );
  671. return;
  672. }
  673. var meetingViewer = this.meetingConfig.meetingViewer;
  674. if( !meetingViewer || !meetingViewer.length ){
  675. this._isMeetingViewer = false;
  676. if(callback)callback( this._isMeetingViewer );
  677. return;
  678. }
  679. if( this.isManager ){
  680. this._isMeetingViewer = true;
  681. if(callback)callback( this._isMeetingViewer );
  682. return;
  683. }
  684. if( typeOf( meetingViewer ) != "array" )meetingViewer = [meetingViewer];
  685. MWF.Actions.get("x_organization_assemble_personal").getPerson(function( json ){
  686. //this.actions.getCurrentPerson( function( json ){
  687. var dn = json.data.distinguishedName;
  688. //var dn = this.desktop.session.user.distinguishedName;
  689. if( meetingViewer.contains( dn ) ){
  690. this._isMeetingViewer = true;
  691. if(callback)callback( this._isMeetingViewer );
  692. return;
  693. }
  694. for( var i=0; i<json.data.woGroupList.length; i++ ){
  695. if( meetingViewer.contains( json.data.woGroupList[i].distinguishedName ) ){
  696. this._isMeetingViewer = true;
  697. if(callback)callback( this._isMeetingViewer );
  698. return;
  699. }
  700. }
  701. //var personList = [ dn ];
  702. this.personActions.listUnitSupNestedWithPersonValue({"personList":[dn]}, function(js){
  703. for( var i=0; i<js.data.unitList.length; i++ ){
  704. if( meetingViewer.contains( js.data.unitList[i] ) ){
  705. this._isMeetingViewer = true;
  706. if(callback)callback( this._isMeetingViewer );
  707. return;
  708. }
  709. }
  710. this._isMeetingViewer = false;
  711. if(callback)callback( this._isMeetingViewer );
  712. }.bind(this),null, false );
  713. }.bind(this), null, false)
  714. }
  715. });
  716. MWF.xApplication.Meeting.Config = new Class({
  717. Implements: [Events],
  718. initialize: function(app){
  719. this.app = app;
  720. this.css = this.app.css;
  721. this.lp = this.app.lp;
  722. this.configData = this.app.meetingConfig || {};
  723. this.process = null;
  724. o2.Actions.load("x_meeting_assemble_control").ConfigAction.getConfigManage(function(json){
  725. var jsonData = json.data || {};
  726. if (jsonData.process){
  727. this.configData.process = jsonData.process;
  728. }else{
  729. this.configData.process = null;
  730. }
  731. if( jsonData.weekBegin ){
  732. this.configData.weekBegin = jsonData.weekBegin;
  733. }
  734. if( jsonData.meetingViewer ){
  735. this.configData.meetingViewer = jsonData.meetingViewer;
  736. }
  737. if( jsonData.mobileCreateEnable ){
  738. this.configData.mobileCreateEnable = jsonData.mobileCreateEnable;
  739. }
  740. for( var key in jsonData ){
  741. if( key !== "process" && key !== "weekBegin" && key !== "meetingViewer" && key !=="mobileCreateEnable"){
  742. this.configData[ key ] = jsonData[key];
  743. }
  744. }
  745. this.load();
  746. }.bind(this));
  747. },
  748. load: function(){
  749. this.node = new Element("div", {
  750. "styles": MWF.AC.isMeetingAdministrator() ? this.css.configNode_admin : this.css.configNode
  751. }).inject(this.app.node);
  752. this.contentNode = new Element("div", {"styles": this.css.configContentNode}).inject(this.node);
  753. var statusStyle = "overflow: hidden;margin-top:6px;margin-left:10px;";
  754. var statusIconStyle = "float: left; width: 16px; height: 16px; border-radius: 100px; ";
  755. var statusIconStyle2 = "float: left; width: 14px; height: 14px; border-radius: 100px; ";
  756. var statusTextStyle = "margin-left:35px; line-height:16px; height:16px;font-size:14px;color:#666;";
  757. var viewStyle = "font-size:14px;color:#666;heigh:16px;margin-top:6px;margin-left:10px;";
  758. var inputTextStyle = "float:right; width:260px; border:1px solid #ccc";
  759. var viewStyle2 = "font-size:14px;color:#666;heigh:16px;margin-top:6px;";
  760. var d = this.configData;
  761. var configLp = this.lp.config;
  762. if( !d.onlineConfig )d.onlineConfig = {};
  763. var html =
  764. //"<div class='configTitle'>"+this.lp.config.meetingStatus+"</div>" +
  765. //
  766. //"<div style='"+ statusStyle +"'>"+
  767. //" <div style='"+ statusIconStyle + "background-color:#4990E2'></div>" +
  768. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.wait+"</div></div>" +
  769. //"</div>"+
  770. //
  771. //"<div style='"+ statusStyle +"'>"+
  772. //" <div style='"+ statusIconStyle + "background-color:#66CC7F'></div>" +
  773. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.progress+"</div></div>" +
  774. //"</div>"+
  775. //
  776. //"<div style='"+ statusStyle +"'>"+
  777. //" <div style='"+ statusIconStyle + "background-color:#F6A623'></div>" +
  778. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.invite+"</div></div>" +
  779. //"</div>"+
  780. //
  781. //"<div style='"+ statusStyle +"'>"+
  782. //" <div style='"+ statusIconStyle + "background-color:#ccc'></div>" +
  783. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.completed+"</div></div>" +
  784. //"</div>"+
  785. //
  786. //"<div style='"+ statusStyle +"'>"+
  787. //" <div style='"+ statusIconStyle2 + "border:2px solid #FF7F7F;'></div>" +
  788. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.conflict+"</div></div>" +
  789. //"</div>"+
  790. //
  791. //"<div class='line'></div>" +
  792. "<div class='configTitle'>"+this.lp.config["default"]+"</div>" +
  793. "<div>";
  794. if( !d.disableViewList.contains( "toMyMeeting" ) ){
  795. html +=
  796. " <div style='"+ viewStyle +"'>" +
  797. "<input type='radio' name='configSelectDefaultView' "+(((!d.defaultView) || d.defaultView=="toMyMeeting") ? "checked" : "")+" value='toMyMeeting'>"+ ( d.toMyMeetingViewName || this.lp.myMeeting )+
  798. " </div>";
  799. }
  800. if( !d.disableViewList.contains( "toMonth" ) ){
  801. html +=
  802. " <div style='"+ viewStyle +"'>" +
  803. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toMonth") ? "checked" : "")+" value='toMonth'>"+ ( d.toMonthViewName || this.lp.month )+
  804. " </div>";
  805. }
  806. if( !d.disableViewList.contains( "toWeek" ) ){
  807. html +=
  808. " <div style='"+ viewStyle +"'>" +
  809. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toWeek") ? "checked" : "")+" value='toWeek'>"+( d.toWeekViewName || this.lp.week )+
  810. " </div>";
  811. }
  812. if( !d.disableViewList.contains( "toDay" ) ){
  813. html +=
  814. " <div style='"+ viewStyle +"'>" +
  815. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toDay") ? "checked" : "")+" value='toDay'>"+(d.toDayViewName || this.lp.day)+
  816. " </div>";
  817. }
  818. if( !d.disableViewList.contains( "toList" ) ){
  819. html +=
  820. " <div style='"+ viewStyle +"'>" +
  821. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toList") ? "checked" : "")+" value='toList'>"+(d.toListViewName || this.lp.list)+
  822. " </div>";
  823. }
  824. if( !d.disableViewList.contains( "toRoom" ) ){
  825. html +=
  826. " <div style='"+ viewStyle +"'>" +
  827. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toRoom") ? "checked" : "")+" value='toRoom'>"+(d.toRoomViewName || this.lp.room)+
  828. " </div>";
  829. }
  830. html +="</div>";
  831. if( MWF.AC.isMeetingAdministrator() ){
  832. d.disableViewList = d.disableViewList || [];
  833. html += "<div class='line'></div>"+
  834. "<div class='configTitle'>"+this.lp.config.viewSetting +"</div>" +
  835. "<div>"+
  836. " <div style='"+ viewStyle +"'>" +
  837. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMyMeeting" ) ? "checked" : "")+" value='toMyMeeting'>"+this.lp.myMeeting+
  838. "<input type='text' name='toMyMeetingViewName' value='" + (d.toMyMeetingViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  839. " </div>" +
  840. " <div style='"+ viewStyle +"'>" +
  841. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMonth" ) ? "checked" : "")+" value='toMonth'>"+this.lp.month+
  842. "<input type='text' name='toMonthViewName' value='" + (d.toMonthViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  843. " </div>" +
  844. " <div style='"+ viewStyle +"'>" +
  845. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toWeek" ) ? "checked" : "")+" value='toWeek'>"+this.lp.week+
  846. "<input type='text' name='toWeekViewName' value='" + (d.toWeekViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  847. " </div>" +
  848. " <div style='"+ viewStyle +"'>" +
  849. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toDay" ) ? "checked" : "")+" value='toDay'>"+this.lp.day+
  850. "<input type='text' name='toDayViewName' value='" + (d.toDayViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  851. " </div>" +
  852. " <div style='"+ viewStyle +"'>" +
  853. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toList" ) ? "checked" : "")+" value='toList'>"+this.lp.list+
  854. "<input type='text' name='toListViewName' value='" + (d.toListViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  855. " </div>" +
  856. " <div style='"+ viewStyle +"'>" +
  857. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toRoom" ) ? "checked" : "")+" value='toRoom'>"+this.lp.room+
  858. "<input type='text' name='toRoomViewName' value='" + (d.toRoomViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  859. " </div>" +
  860. "</div>" +
  861. "<div class='line'></div>"+
  862. "<div class='configTitle'>"+this.lp.config.weekBegin +"</div>" +
  863. "<div><select name='configSelectWeekBeign'>"+
  864. "<option value='0' "+((d.weekBegin=="0") ? "selected" : "")+">"+this.lp.weeks.Sun+"</option>"+
  865. "<option value='1' "+((d.weekBegin=="1") ? "selected" : "")+">"+this.lp.weeks.Mon+"</option>"+
  866. //"<option value='2'"+((d.weekBegin=="2") ? "selected" : "")+">"+this.lp.weeks.Tues+"</option>"+
  867. //"<option value='3'"+((d.weekBegin=="3") ? "selected" : "")+">"+this.lp.weeks.Wed+"</option>"+
  868. //"<option value='4'"+((d.weekBegin=="4") ? "selected" : "")+">"+this.lp.weeks.Thur+"</option>"+
  869. //"<option value='5'"+((d.weekBegin=="5") ? "selected" : "")+">"+this.lp.weeks.Fri+"</option>"+
  870. //"<option value='6'"+((d.weekBegin=="6") ? "selected" : "")+">"+this.lp.weeks.Sat+"</option>"+
  871. "</select></div>"+
  872. "<div class='line'></div>"+
  873. "<div class='configTitle'>"+this.lp.config.applyProcess+"</div>" +
  874. "<div item='processArea'></div>" +
  875. //"<div class='line'></div>"+
  876. "<div class='configTitle' title='"+ this.lp.config.meetingViewerTitle +"'>"+this.lp.config.meetingViewer +"</div>" +
  877. "<div item='meetingViewerNode'></div>" +
  878. "<div class='configTitle'>"+this.lp.config.mobileCreateEnable +"</div>" +
  879. "<div item='mobileCreateEnable'></div>" +
  880. "<div class='line'></div>"+
  881. "<div class='configTitle'>"+this.lp.config.meetingType +"</div>" +
  882. "<div><textarea name='typeList' style='width: 370px;height: 120px;'>"+ d.typeList.join("\n") +"</textarea></div>" +
  883. "<div class='line'></div>"+
  884. "<div class='configTitle'>"+this.lp.config.enableOnline +"</div>" +
  885. "<div item='enableOnline'></div>"+
  886. "<div class='onlineArea' style='display:"+( d.enableOnline ? "" : "none" )+"'>"+
  887. " <div class='configTitle' style='margin-top:15px;'>"+this.lp.config.onlineProduct +"</div>" +
  888. " <div item='onlineProduct'></div>"+
  889. " <div class='onlineConfigArea' style='display: "+( d.onlineProduct === "好视通" ? "" : "none" )+"'>"+
  890. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.hstUrl +"</div>" +
  891. " <div style='"+ viewStyle2 +"'>" +
  892. " <input type='text' name='hstUrl' value='" + (d.onlineConfig.hstUrl || "") + "' style='width:calc(100% - 10px); border:1px solid #ccc'>"+
  893. " </div>"+
  894. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.hstKey +"</div>" +
  895. " <div style='"+ viewStyle2 +"'>" +
  896. " <input type='text' name='hstKey' value='" + (d.onlineConfig.hstKey || "") + "' style='width:calc(100% - 10px); border:1px solid #ccc'>"+
  897. " </div>"+
  898. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.hstSecret +"</div>" +
  899. " <div style='"+ viewStyle2 +"'>" +
  900. " <input type='text' name='hstSecret' value='" + (d.onlineConfig.hstSecret || "") + "' style='width:calc(100% - 10px); border:1px solid #ccc'>"+
  901. " </div>"+
  902. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.hstAuth +"</div>" +
  903. " <div item='hstAuth'></div>"+
  904. // " <div class='o2ToHstUidArea' style='display: "+( d.onlineConfig.hstAuth ? "" : "none" )+"'>"+
  905. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.o2ToHstUid +"</div>" +
  906. " <div item='o2ToHstUid'></div>"+
  907. // " </div>"+
  908. " </div>"+
  909. "</div>";
  910. // {
  911. // "hstUrl": "https://117.133.7.109:8443",
  912. // "hstKey": "4QY08Kyh",
  913. // "hstSecret": "HpQi5csSMrufkM)b&#YWVlr7o*wWUG3G",
  914. // "hstAuth": true,
  915. // "o2ToHstUid": "employee"
  916. // }
  917. // "<div class='line'></div>"+
  918. // "<div class='configTitle'>"+this.lp.config.apiAddress +"</div>" +
  919. // "<div><textarea name='apiAddress' style='width: 270px;height: 60px;word-break:break-all;'>"+ (d.api || "") +"</textarea></div>"+
  920. //
  921. // "<div class='configTitle'>"+this.lp.config.key +"</div>" +
  922. // "<div><input name='key' style='width: 270px;height: 26px;' value='"+(d.key || "")+"'></input></div>"+
  923. //
  924. // "<div class='configTitle'>"+this.lp.config.secret +"</div>" +
  925. // "<div><input name='secret' style='width: 270px;height: 26px;' value='"+(d.secret || "")+"'></input></div>";
  926. }
  927. this.contentNode.set("html", html);
  928. this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  929. this.contentNode.getElements("div.configTitle").setStyles(this.css.configTitleDiv);
  930. if( MWF.AC.isMeetingAdministrator() ){
  931. this.processNode = this.contentNode.getElement("[item='processArea']");
  932. this.processNode.setStyles(this.css.configProcessNode);
  933. this.createApplicationSelect();
  934. this.meetingViewerNode = this.contentNode.getElement("[item='meetingViewerNode']");
  935. //this.meetingViewerNode.setStyles(this.css.configProcessNode);
  936. this.meetingViewer = new MDomItem(this.meetingViewerNode, {
  937. name : "meetingViewer", type : "org", orgType : ["person","unit","group"], count : 0, style : this.css.configMeetingViewerNode,
  938. value : d.meetingViewer || []
  939. } , null, this.app );
  940. this.meetingViewer.load();
  941. this.mobileCreateEnableNode = this.contentNode.getElement("[item='mobileCreateEnable']");
  942. this.mobileCreateEnable = new MDomItem(this.mobileCreateEnableNode, {
  943. name : "mobileCreateEnable", type : "select", selectValue : ["true","false"], selectText : this.lp.config.mobileCreateEnableOptions,
  944. value : d.mobileCreateEnable || "true"
  945. } , null, this.app );
  946. this.mobileCreateEnable.load();
  947. this.enableOnlineNode = this.contentNode.getElement("[item='enableOnline']");
  948. this.enableOnline = new MDomItem(this.enableOnlineNode, {
  949. name : "enableOnline", type : "select", selectValue : ["true","false"], selectText : [this.lp.yes, this.lp.no],
  950. value : ( d.enableOnline || false ).toString(),
  951. event: {
  952. change: function (item, ev) {
  953. var value = item.getValue();
  954. this.contentNode.getElement("div.onlineArea").setStyle("display", value === "true" ? "" : "none");
  955. // if( this.onlineProduct.getValue() === "好视通" && value === "true" && !this.scriptEditor )this.loadScriptEditor();
  956. this.setSize();
  957. }.bind(this)
  958. }
  959. } , null, this.app );
  960. this.enableOnline.load();
  961. this.onlineProductNode = this.contentNode.getElement("[item='onlineProduct']");
  962. this.onlineProduct = new MDomItem(this.onlineProductNode, {
  963. name : "onlineProduct", type : "select", selectValue : ["其他","好视通"], selectText : [this.lp.other,"好视通"],
  964. value : d.onlineProduct || "其他",
  965. event: {
  966. change: function (item, ev ) {
  967. var value = item.getValue();
  968. this.contentNode.getElement("div.onlineConfigArea").setStyle("display", value === "好视通" ? "" : "none");
  969. // if( value === "好视通" && this.enableOnline.getValue() === "true" && !this.scriptEditor )this.loadScriptEditor();
  970. this.setSize();
  971. }.bind(this)
  972. }
  973. } , null, this.app );
  974. this.onlineProduct.load();
  975. this.hstAuthNode = this.contentNode.getElement("[item='hstAuth']");
  976. this.hstAuth = new MDomItem(this.hstAuthNode, {
  977. name : "hstAuth", type : "select", selectValue : ["true","false"], selectText : [this.lp.yes, this.lp.no],
  978. value : (d.onlineConfig.hstAuth || false).toString()
  979. // event: {
  980. // change: function (item, ev ) {
  981. // var value = item.getValue();
  982. // this.contentNode.getElement("div.o2ToHstUidArea").setStyle("display", value === "true" ? "" : "none");
  983. // this.setSize();
  984. // }.bind(this)
  985. // }
  986. } , null, this.app );
  987. this.hstAuth.load();
  988. var lp = this.lp.config;
  989. this.o2ToHstUidNode = this.contentNode.getElement("[item='o2ToHstUid']");
  990. this.o2ToHstUid = new MDomItem(this.o2ToHstUidNode, {
  991. name : "o2ToHstUid", type : "select",
  992. selectValue : ["employee", "unique", "distinguishedName", "mobile","mail", "weixin","qq"],
  993. selectText : [lp.employee, lp.unique, lp.distinguishedName, lp.mobile, lp.mail, lp.weixin, lp.qq],
  994. value : d.onlineConfig.o2ToHstUid || "employee"
  995. } , null, this.app );
  996. this.o2ToHstUid.load();
  997. // if( d.onlineProduct === "好视通" && d.enableOnline ){
  998. // this.loadScriptEditor();
  999. // }
  1000. }
  1001. this.actionNode = new Element("div", {"styles": this.css.configActionNode}).inject(this.node);
  1002. this.cancelNode = new Element("div", {"styles": this.css.configActionCancelNode, "text": this.app.lp.cancel}).inject(this.actionNode);
  1003. this.saveNode = new Element("div", {"styles": this.css.configActionSaveNode, "text": this.app.lp.save}).inject(this.actionNode);
  1004. this.saveNode.addClass("mainColor_bg");
  1005. this.cancelNode.addEvent("click", this.hide.bind(this));
  1006. this.saveNode.addEvent("click", this.save.bind(this));
  1007. this.node.addEvent("mousedown", function(e){e.stopPropagation();}.bind(this));
  1008. this.setSize();
  1009. this.show();
  1010. },
  1011. // loadScriptEditor:function(){
  1012. // var json;
  1013. // if( !this.configData.onlineConfig ){
  1014. // json = {
  1015. // 'hstUrl':'好视通服务地址',
  1016. // 'hstKey':'好视通服务接口KEY',
  1017. // 'hstSecret':'好视通服务接口SECRET',
  1018. // 'hstUserSync':'是否启用O2到好视通人员同步'
  1019. // }
  1020. // }else{
  1021. // json = this.configData.onlineConfig;
  1022. // }
  1023. // MWF.require("MWF.widget.JavascriptEditor", null, false);
  1024. // var value;
  1025. // try{
  1026. // value = JSON.stringify(json, null, "\t");
  1027. // }catch (e) {}
  1028. //
  1029. // var node = this.contentNode.getElement('div[item="onlineConfig"]');
  1030. // if( value ){
  1031. // this.scriptEditor = new MWF.widget.JavascriptEditor(node, {
  1032. // "forceType": "ace",
  1033. // "option": {"value": value, "mode" : "json" }
  1034. // });
  1035. // this.scriptEditor.load(function(){
  1036. // this.scriptEditor.setValue(value);
  1037. // }.bind(this));
  1038. // }
  1039. // },
  1040. setSize : function(){
  1041. var sizeY = this.node.getSize().y;
  1042. var y = this.app.content.getSize().y;
  1043. if( sizeY > y-50 ){
  1044. this.node.setStyle("height", y-50 );
  1045. }
  1046. },
  1047. createApplicationSelect: function(){
  1048. if (this.configData.process){
  1049. MWF.require("MWF.widget.O2Identity", function(){
  1050. var p = new MWF.widget.O2Process(this.configData.process, this.processNode);
  1051. }.bind(this));
  1052. }
  1053. this.processNode.addEvent("click", function(){
  1054. MWF.xDesktop.requireApp("Selector", "package", function(){
  1055. var options = {
  1056. "type": "Process",
  1057. "values": [this.process || this.configData.process],
  1058. "count": 1,
  1059. "onComplete": function (items) {
  1060. this.processNode.empty();
  1061. this.process = null;
  1062. this.configData.process = null;
  1063. if (items.length){
  1064. MWF.require("MWF.widget.O2Identity", function(){
  1065. var p = new MWF.widget.O2Process(items[0].data, this.processNode);
  1066. this.process = {
  1067. "name": items[0].data.name,
  1068. "id": items[0].data.id,
  1069. "application": items[0].data.application,
  1070. "applicationName": items[0].data.applicationName,
  1071. "alias": items[0].data.alias
  1072. };
  1073. this.configData.process = this.process;
  1074. }.bind(this));
  1075. }
  1076. }.bind(this)
  1077. };
  1078. var selector = new MWF.O2Selector(this.app.content, options);
  1079. }.bind(this));
  1080. }.bind(this));
  1081. },
  1082. save: function(){
  1083. //var hideMenu = "auto";
  1084. var defaultView = "toMyMeeting";
  1085. var process = null;
  1086. //var node = this.contentNode.getFirst("div");
  1087. //var hideMenuNode = node.getElement("input");
  1088. //if (hideMenuNode) if (!hideMenuNode.checked) hideMenu = "static";
  1089. //node = node.getNext();
  1090. var viewNodes = this.contentNode.getElements("input[name='configSelectDefaultView']");
  1091. for (var i=0; i<viewNodes.length; i++){
  1092. if (viewNodes[i].checked){
  1093. defaultView = viewNodes[i].get("value");
  1094. break;
  1095. }
  1096. }
  1097. MWF.UD.putData("meetingConfig", {
  1098. //"hideMenu": hideMenu,
  1099. "defaultView": defaultView
  1100. }, null, false);
  1101. if( MWF.AC.isMeetingAdministrator() ){
  1102. //if (this.processSelect){
  1103. //process = this.processSelect.options[this.processSelect.selectedIndex].get("value");
  1104. //MWF.UD.putPublicData("meetingConfig", {"process": process});
  1105. //}
  1106. var disableViewList = [];
  1107. var viewAvailableNodes = this.contentNode.getElements("input[name='configAvailableView']");
  1108. for (var i=0; i<viewAvailableNodes.length; i++){
  1109. if ( !viewAvailableNodes[i].checked){
  1110. disableViewList.push( viewAvailableNodes[i].get("value") ) ;
  1111. }
  1112. }
  1113. var weekBeginSelect = this.contentNode.getElement("select[name='configSelectWeekBeign']");
  1114. var weekBeginValue = "0";
  1115. if( weekBeginSelect ){
  1116. weekBeginValue = weekBeginSelect.options[weekBeginSelect.selectedIndex].get("value");
  1117. }
  1118. var viewer = null;
  1119. if( this.meetingViewer ){
  1120. viewer = this.meetingViewer.getValue();
  1121. }
  1122. var typeList = [];
  1123. var typeListInput = this.contentNode.getElement("textarea[name='typeList']");
  1124. if(typeListInput)typeList = typeListInput.get("value").split("\n");
  1125. // var onlineConfig;
  1126. // if( this.scriptEditor ){
  1127. // onlineConfig = this.scriptEditor.getValue();
  1128. // try{
  1129. // onlineConfig = JSON.parse( onlineConfig );
  1130. // }catch (e) {
  1131. // this.app.notice( this.app.lp.onlineConfigNotJson, "info" );
  1132. // return;
  1133. // }
  1134. // onlineConfig = JSON.parse(this.scriptEditor.getValue())
  1135. // }else{
  1136. // onlineConfig = this.configData.onlineConfig || {};
  1137. // }
  1138. var onlineConfig = {
  1139. hstUrl: this.contentNode.getElement("input[name='hstUrl']").get("value"),
  1140. hstKey: this.contentNode.getElement("input[name='hstKey']").get("value"),
  1141. hstSecret: this.contentNode.getElement("input[name='hstSecret']").get("value"),
  1142. hstAuth: this.hstAuth.getValue() === "true",
  1143. o2ToHstUid: this.o2ToHstUid.getValue(),
  1144. };
  1145. if( this.enableOnline.getValue() === "true" && this.onlineProduct.getValue() === "好视通" ){
  1146. if( !onlineConfig.hstUrl || !onlineConfig.hstKey || !onlineConfig.hstSecret ){
  1147. this.app.notice( this.app.lp.config.onlineConfigNotEmpty, "info" );
  1148. return;
  1149. }
  1150. }
  1151. var data = {
  1152. //"hideMenu": hideMenu,
  1153. "process": this.process || this.configData.process,
  1154. "weekBegin" : weekBeginValue,
  1155. "meetingViewer" : viewer,
  1156. "mobileCreateEnable" : this.mobileCreateEnable.getValue(),
  1157. "disableViewList" : disableViewList,
  1158. "typeList": typeList,
  1159. "toMyMeetingViewName" : this.contentNode.getElement("input[name='toMyMeetingViewName']").get("value"),
  1160. "toMonthViewName" : this.contentNode.getElement("input[name='toMonthViewName']").get("value"),
  1161. "toWeekViewName" : this.contentNode.getElement("input[name='toWeekViewName']").get("value"),
  1162. "toDayViewName" : this.contentNode.getElement("input[name='toDayViewName']").get("value"),
  1163. "toListViewName" : this.contentNode.getElement("input[name='toListViewName']").get("value"),
  1164. "toRoomViewName" : this.contentNode.getElement("input[name='toRoomViewName']").get("value"),
  1165. "enableOnline": this.enableOnline.getValue() === "true",
  1166. "onlineProduct": this.onlineProduct.getValue(),
  1167. "onlineConfig": onlineConfig
  1168. };
  1169. o2.Actions.load("x_meeting_assemble_control").ConfigAction.saveSystemConfig(data, function () {
  1170. this.app.meetingConfig = Object.merge(this.app.meetingConfig, data);
  1171. }.bind(this), null, false);
  1172. }
  1173. this.app.notice( this.app.lp.config_saveSuccess, "success" );
  1174. this.hide();
  1175. },
  1176. show: function(){
  1177. this.node.setStyles(MWF.AC.isMeetingAdministrator() ? this.css.configNode_admin : this.css.configNode);
  1178. var fx = new Fx.Morph(this.node, {
  1179. "duration": "500",
  1180. "transition": Fx.Transitions.Expo.easeOut
  1181. });
  1182. fx.start({
  1183. "opacity": 1
  1184. }).chain(function(){
  1185. this.hideFun = this.hide.bind(this);
  1186. this.app.node.addEvent("mousedown", this.hideFun);
  1187. }.bind(this));
  1188. },
  1189. hide: function(){
  1190. if(this.scriptEditor)this.scriptEditor.destroy();
  1191. this.node.destroy();
  1192. this.app.node.removeEvent("mousedown", this.hideFun);
  1193. MWF.release(this);
  1194. }
  1195. });