Main.js 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323
  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'>"+ o2.txt( 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'>"+ o2.txt( 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'>"+ o2.txt( 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'>"+ o2.txt(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'>"+ o2.txt(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'>"+ o2.txt(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. if(this.scriptEditor)this.scriptEditor.destroy();
  1176. this.node.destroy();
  1177. this.app.node.removeEvent("mousedown", this.hideFun);
  1178. this.app.refresh();
  1179. },
  1180. show: function(){
  1181. this.node.setStyles(MWF.AC.isMeetingAdministrator() ? this.css.configNode_admin : this.css.configNode);
  1182. var fx = new Fx.Morph(this.node, {
  1183. "duration": "500",
  1184. "transition": Fx.Transitions.Expo.easeOut
  1185. });
  1186. fx.start({
  1187. "opacity": 1
  1188. }).chain(function(){
  1189. this.hideFun = this.hide.bind(this);
  1190. this.app.node.addEvent("mousedown", this.hideFun);
  1191. }.bind(this));
  1192. },
  1193. hide: function(){
  1194. if(this.scriptEditor)this.scriptEditor.destroy();
  1195. this.node.destroy();
  1196. this.app.node.removeEvent("mousedown", this.hideFun);
  1197. MWF.release(this);
  1198. }
  1199. });