Main.js 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302
  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. MWF.UD.getPublicData("meetingConfig", function(json){
  517. var process = (json) ? json.process : null;
  518. if (process){
  519. this.loadMeetingProcess(process, processData, latest);
  520. }else{
  521. //new MWF.xApplication.Meeting.Creator(this, date, hour, room);
  522. var form = new MWF.xApplication.Meeting.MeetingForm(this,{}, {
  523. date : date,
  524. hour : hour,
  525. minute : minute,
  526. room : room
  527. }, {app:this});
  528. form.view = this;
  529. form.create();
  530. //this.hideMenu();
  531. }
  532. }.bind(this));
  533. },
  534. loadMeetingProcess: function(id, processData, latest){
  535. this.getProcess(id, function(process){
  536. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  537. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(process, this, {
  538. "latest" : latest,
  539. "workData" : processData,
  540. "onStarted": function(data, title, processName){
  541. this.afterStartProcess(data, title, processName);
  542. }.bind(this)
  543. });
  544. starter.load();
  545. }.bind(this));
  546. }.bind(this));
  547. },
  548. afterStartProcess: function(data, title, processName){
  549. var workInfors = [];
  550. var currentTask = [];
  551. data.each(function(work){
  552. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  553. workInfors.push(this.getStartWorkInforObj(work));
  554. }.bind(this));
  555. if (currentTask.length===1){
  556. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  557. this.desktop.openApplication(null, "process.Work", options);
  558. this.createStartWorkResault(workInfors, title, processName, false);
  559. }else{
  560. this.createStartWorkResault(workInfors, title, processName, true);
  561. }
  562. },
  563. createStartWorkResault: function(workInfors, title, processName, isopen){
  564. var content = "";
  565. workInfors.each(function(infor){
  566. var users = [];
  567. infor.users.each(function(uname){
  568. users.push(MWF.name.cn(uname));
  569. });
  570. content += "<div><b>"+this.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  571. if (infor.currentTask && isopen){
  572. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.lp.deal+"</span></div>";
  573. }else{
  574. content += "</div>";
  575. }
  576. }.bind(this));
  577. var t = workInfors[0].title || title;
  578. var msg = {
  579. "subject": this.lp.processStarted,
  580. "content": "<div>"+this.lp.processStartedMessage+"“["+processName+"]"+t+"”</div>"+content
  581. };
  582. var tooltip = layout.desktop.message.addTooltip(msg);
  583. var item = layout.desktop.message.addMessage(msg);
  584. this.setStartWorkResaultAction(tooltip);
  585. this.setStartWorkResaultAction(item);
  586. },
  587. getStartWorkInforObj: function(work){
  588. var title = "";
  589. var users = [];
  590. var currentTask = "";
  591. work.taskList.each(function(task, idx){
  592. title = task.title;
  593. users.push(task.person+"("+task.department + ")");
  594. if (work.currentTaskIndex===idx) currentTask = task.id;
  595. }.bind(this));
  596. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask, "title" : title };
  597. },
  598. setStartWorkResaultAction: function(item){
  599. var node = item.node.getElements("span");
  600. node.setStyles(this.css.dealStartedWorkAction);
  601. var _self = this;
  602. node.addEvent("click", function(e){
  603. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  604. _self.desktop.openApplication(e, "process.Work", options);
  605. });
  606. },
  607. getProcess: function(id, callback){
  608. // MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  609. // var action = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  610. // action.getProcess(id, function(json){
  611. if (callback) callback(id);
  612. // }.bind(this));
  613. // }.bind(this));
  614. },
  615. config: function(){
  616. new MWF.xApplication.Meeting.Config(this, this.meetingConfig);
  617. //this.hideMenu();
  618. },
  619. addRoom : function(){
  620. var form = new MWF.xApplication.Meeting.RoomForm(this,{}, {}, {app:this});
  621. form.view = this;
  622. form.create();
  623. //this.hideMenu();
  624. },
  625. recordStatus: function(){
  626. //alert( JSON.stringify(
  627. // {
  628. // action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  629. // options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  630. // }
  631. //) )
  632. return {
  633. action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  634. options : (this.currentView && this.currentView.recordStatus) ? this.currentView.recordStatus() : null
  635. };
  636. },
  637. reload: function( ){
  638. // if( this.inContainer ){
  639. if( this.currentView && this.currentView.reload ){
  640. this.currentView.reload();
  641. }else{
  642. this.refresh()
  643. }
  644. // }else{
  645. // this.refresh()
  646. // }
  647. },
  648. loadSideBar : function(){
  649. this.sideBar = new MWF.xApplication.Meeting.SideBar(this.node, this);
  650. this.sideBar.show();
  651. },
  652. isMeetingViewer : function( callback ){
  653. if( typeOf( this._isMeetingViewer ) == "boolean"){
  654. if(callback)callback( this._isMeetingViewer );
  655. return;
  656. }
  657. var meetingViewer = this.meetingConfig.meetingViewer;
  658. if( !meetingViewer || !meetingViewer.length ){
  659. this._isMeetingViewer = false;
  660. if(callback)callback( this._isMeetingViewer );
  661. return;
  662. }
  663. if( this.isManager ){
  664. this._isMeetingViewer = true;
  665. if(callback)callback( this._isMeetingViewer );
  666. return;
  667. }
  668. if( typeOf( meetingViewer ) != "array" )meetingViewer = [meetingViewer];
  669. MWF.Actions.get("x_organization_assemble_personal").getPerson(function( json ){
  670. //this.actions.getCurrentPerson( function( json ){
  671. var dn = json.data.distinguishedName;
  672. //var dn = this.desktop.session.user.distinguishedName;
  673. if( meetingViewer.contains( dn ) ){
  674. this._isMeetingViewer = true;
  675. if(callback)callback( this._isMeetingViewer );
  676. return;
  677. }
  678. for( var i=0; i<json.data.woGroupList.length; i++ ){
  679. if( meetingViewer.contains( json.data.woGroupList[i].distinguishedName ) ){
  680. this._isMeetingViewer = true;
  681. if(callback)callback( this._isMeetingViewer );
  682. return;
  683. }
  684. }
  685. //var personList = [ dn ];
  686. this.personActions.listUnitSupNestedWithPersonValue({"personList":[dn]}, function(js){
  687. for( var i=0; i<js.data.unitList.length; i++ ){
  688. if( meetingViewer.contains( js.data.unitList[i] ) ){
  689. this._isMeetingViewer = true;
  690. if(callback)callback( this._isMeetingViewer );
  691. return;
  692. }
  693. }
  694. this._isMeetingViewer = false;
  695. if(callback)callback( this._isMeetingViewer );
  696. }.bind(this),null, false );
  697. }.bind(this), null, false)
  698. }
  699. });
  700. MWF.xApplication.Meeting.Config = new Class({
  701. Implements: [Events],
  702. initialize: function(app){
  703. this.app = app;
  704. this.css = this.app.css;
  705. this.lp = this.app.lp;
  706. this.configData = this.app.meetingConfig || {};
  707. this.process = null;
  708. o2.Actions.load("x_meeting_assemble_control").ConfigAction.getConfigManage(function(json){
  709. var jsonData = json.data || {};
  710. if (jsonData.process){
  711. this.configData.process = jsonData.process;
  712. }else{
  713. this.configData.process = null;
  714. }
  715. if( jsonData.weekBegin ){
  716. this.configData.weekBegin = jsonData.weekBegin;
  717. }
  718. if( jsonData.meetingViewer ){
  719. this.configData.meetingViewer = jsonData.meetingViewer;
  720. }
  721. if( jsonData.mobileCreateEnable ){
  722. this.configData.mobileCreateEnable = jsonData.mobileCreateEnable;
  723. }
  724. for( var key in jsonData ){
  725. if( key !== "process" && key !== "weekBegin" && key !== "meetingViewer" && key !=="mobileCreateEnable"){
  726. this.configData[ key ] = jsonData[key];
  727. }
  728. }
  729. this.load();
  730. }.bind(this));
  731. },
  732. load: function(){
  733. this.node = new Element("div", {
  734. "styles": MWF.AC.isMeetingAdministrator() ? this.css.configNode_admin : this.css.configNode
  735. }).inject(this.app.node);
  736. this.contentNode = new Element("div", {"styles": this.css.configContentNode}).inject(this.node);
  737. var statusStyle = "overflow: hidden;margin-top:6px;margin-left:10px;";
  738. var statusIconStyle = "float: left; width: 16px; height: 16px; border-radius: 100px; ";
  739. var statusIconStyle2 = "float: left; width: 14px; height: 14px; border-radius: 100px; ";
  740. var statusTextStyle = "margin-left:35px; line-height:16px; height:16px;font-size:14px;color:#666;";
  741. var viewStyle = "font-size:14px;color:#666;heigh:16px;margin-top:6px;margin-left:10px;";
  742. var inputTextStyle = "float:right; width:260px; border:1px solid #ccc";
  743. var viewStyle2 = "font-size:14px;color:#666;heigh:16px;margin-top:6px;";
  744. var d = this.configData;
  745. var configLp = this.lp.config;
  746. if( !d.onlineConfig )d.onlineConfig = {};
  747. var html =
  748. //"<div class='configTitle'>"+this.lp.config.meetingStatus+"</div>" +
  749. //
  750. //"<div style='"+ statusStyle +"'>"+
  751. //" <div style='"+ statusIconStyle + "background-color:#4990E2'></div>" +
  752. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.wait+"</div></div>" +
  753. //"</div>"+
  754. //
  755. //"<div style='"+ statusStyle +"'>"+
  756. //" <div style='"+ statusIconStyle + "background-color:#66CC7F'></div>" +
  757. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.progress+"</div></div>" +
  758. //"</div>"+
  759. //
  760. //"<div style='"+ statusStyle +"'>"+
  761. //" <div style='"+ statusIconStyle + "background-color:#F6A623'></div>" +
  762. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.invite+"</div></div>" +
  763. //"</div>"+
  764. //
  765. //"<div style='"+ statusStyle +"'>"+
  766. //" <div style='"+ statusIconStyle + "background-color:#ccc'></div>" +
  767. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.completed+"</div></div>" +
  768. //"</div>"+
  769. //
  770. //"<div style='"+ statusStyle +"'>"+
  771. //" <div style='"+ statusIconStyle2 + "border:2px solid #FF7F7F;'></div>" +
  772. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.conflict+"</div></div>" +
  773. //"</div>"+
  774. //
  775. //"<div class='line'></div>" +
  776. "<div class='configTitle'>"+this.lp.config["default"]+"</div>" +
  777. "<div>";
  778. if( !d.disableViewList.contains( "toMyMeeting" ) ){
  779. html +=
  780. " <div style='"+ viewStyle +"'>" +
  781. "<input type='radio' name='configSelectDefaultView' "+(((!d.defaultView) || d.defaultView=="toMyMeeting") ? "checked" : "")+" value='toMyMeeting'>"+ ( d.toMyMeetingViewName || this.lp.myMeeting )+
  782. " </div>";
  783. }
  784. if( !d.disableViewList.contains( "toMonth" ) ){
  785. html +=
  786. " <div style='"+ viewStyle +"'>" +
  787. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toMonth") ? "checked" : "")+" value='toMonth'>"+ ( d.toMonthViewName || this.lp.month )+
  788. " </div>";
  789. }
  790. if( !d.disableViewList.contains( "toWeek" ) ){
  791. html +=
  792. " <div style='"+ viewStyle +"'>" +
  793. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toWeek") ? "checked" : "")+" value='toWeek'>"+( d.toWeekViewName || this.lp.week )+
  794. " </div>";
  795. }
  796. if( !d.disableViewList.contains( "toDay" ) ){
  797. html +=
  798. " <div style='"+ viewStyle +"'>" +
  799. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toDay") ? "checked" : "")+" value='toDay'>"+(d.toDayViewName || this.lp.day)+
  800. " </div>";
  801. }
  802. if( !d.disableViewList.contains( "toList" ) ){
  803. html +=
  804. " <div style='"+ viewStyle +"'>" +
  805. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toList") ? "checked" : "")+" value='toList'>"+(d.toListViewName || this.lp.list)+
  806. " </div>";
  807. }
  808. if( !d.disableViewList.contains( "toRoom" ) ){
  809. html +=
  810. " <div style='"+ viewStyle +"'>" +
  811. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toRoom") ? "checked" : "")+" value='toRoom'>"+(d.toRoomViewName || this.lp.room)+
  812. " </div>";
  813. }
  814. html +="</div>";
  815. if( MWF.AC.isMeetingAdministrator() ){
  816. d.disableViewList = d.disableViewList || [];
  817. html += "<div class='line'></div>"+
  818. "<div class='configTitle'>"+this.lp.config.viewSetting +"</div>" +
  819. "<div>"+
  820. " <div style='"+ viewStyle +"'>" +
  821. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMyMeeting" ) ? "checked" : "")+" value='toMyMeeting'>"+this.lp.myMeeting+
  822. "<input type='text' name='toMyMeetingViewName' value='" + (d.toMyMeetingViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  823. " </div>" +
  824. " <div style='"+ viewStyle +"'>" +
  825. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMonth" ) ? "checked" : "")+" value='toMonth'>"+this.lp.month+
  826. "<input type='text' name='toMonthViewName' value='" + (d.toMonthViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  827. " </div>" +
  828. " <div style='"+ viewStyle +"'>" +
  829. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toWeek" ) ? "checked" : "")+" value='toWeek'>"+this.lp.week+
  830. "<input type='text' name='toWeekViewName' value='" + (d.toWeekViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  831. " </div>" +
  832. " <div style='"+ viewStyle +"'>" +
  833. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toDay" ) ? "checked" : "")+" value='toDay'>"+this.lp.day+
  834. "<input type='text' name='toDayViewName' value='" + (d.toDayViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  835. " </div>" +
  836. " <div style='"+ viewStyle +"'>" +
  837. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toList" ) ? "checked" : "")+" value='toList'>"+this.lp.list+
  838. "<input type='text' name='toListViewName' value='" + (d.toListViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  839. " </div>" +
  840. " <div style='"+ viewStyle +"'>" +
  841. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toRoom" ) ? "checked" : "")+" value='toRoom'>"+this.lp.room+
  842. "<input type='text' name='toRoomViewName' value='" + (d.toRoomViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  843. " </div>" +
  844. "</div>" +
  845. "<div class='line'></div>"+
  846. "<div class='configTitle'>"+this.lp.config.weekBegin +"</div>" +
  847. "<div><select name='configSelectWeekBeign'>"+
  848. "<option value='0' "+((d.weekBegin=="0") ? "selected" : "")+">"+this.lp.weeks.Sun+"</option>"+
  849. "<option value='1' "+((d.weekBegin=="1") ? "selected" : "")+">"+this.lp.weeks.Mon+"</option>"+
  850. //"<option value='2'"+((d.weekBegin=="2") ? "selected" : "")+">"+this.lp.weeks.Tues+"</option>"+
  851. //"<option value='3'"+((d.weekBegin=="3") ? "selected" : "")+">"+this.lp.weeks.Wed+"</option>"+
  852. //"<option value='4'"+((d.weekBegin=="4") ? "selected" : "")+">"+this.lp.weeks.Thur+"</option>"+
  853. //"<option value='5'"+((d.weekBegin=="5") ? "selected" : "")+">"+this.lp.weeks.Fri+"</option>"+
  854. //"<option value='6'"+((d.weekBegin=="6") ? "selected" : "")+">"+this.lp.weeks.Sat+"</option>"+
  855. "</select></div>"+
  856. "<div class='line'></div>"+
  857. "<div class='configTitle'>"+this.lp.config.applyProcess+"</div>" +
  858. "<div item='processArea'></div>" +
  859. //"<div class='line'></div>"+
  860. "<div class='configTitle' title='"+ this.lp.config.meetingViewerTitle +"'>"+this.lp.config.meetingViewer +"</div>" +
  861. "<div item='meetingViewerNode'></div>" +
  862. "<div class='configTitle'>"+this.lp.config.mobileCreateEnable +"</div>" +
  863. "<div item='mobileCreateEnable'></div>" +
  864. "<div class='line'></div>"+
  865. "<div class='configTitle'>"+this.lp.config.meetingType +"</div>" +
  866. "<div><textarea name='typeList' style='width: 370px;height: 120px;'>"+ d.typeList.join("\n") +"</textarea></div>" +
  867. "<div class='line'></div>"+
  868. "<div class='configTitle'>"+this.lp.config.enableOnline +"</div>" +
  869. "<div item='enableOnline'></div>"+
  870. "<div class='onlineArea' style='display:"+( d.enableOnline ? "" : "none" )+"'>"+
  871. " <div class='configTitle' style='margin-top:15px;'>"+this.lp.config.onlineProduct +"</div>" +
  872. " <div item='onlineProduct'></div>"+
  873. " <div class='onlineConfigArea' style='display: "+( d.onlineProduct === "好视通" ? "" : "none" )+"'>"+
  874. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.hstUrl +"</div>" +
  875. " <div style='"+ viewStyle2 +"'>" +
  876. " <input type='text' name='hstUrl' value='" + (d.onlineConfig.hstUrl || "") + "' style='width:calc(100% - 10px); border:1px solid #ccc'>"+
  877. " </div>"+
  878. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.hstKey +"</div>" +
  879. " <div style='"+ viewStyle2 +"'>" +
  880. " <input type='text' name='hstKey' value='" + (d.onlineConfig.hstKey || "") + "' style='width:calc(100% - 10px); border:1px solid #ccc'>"+
  881. " </div>"+
  882. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.hstSecret +"</div>" +
  883. " <div style='"+ viewStyle2 +"'>" +
  884. " <input type='text' name='hstSecret' value='" + (d.onlineConfig.hstSecret || "") + "' style='width:calc(100% - 10px); border:1px solid #ccc'>"+
  885. " </div>"+
  886. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.hstAuth +"</div>" +
  887. " <div item='hstAuth'></div>"+
  888. // " <div class='o2ToHstUidArea' style='display: "+( d.onlineConfig.hstAuth ? "" : "none" )+"'>"+
  889. " <div class='configTitle' style='margin-top:15px;'>"+ this.lp.config.o2ToHstUid +"</div>" +
  890. " <div item='o2ToHstUid'></div>"+
  891. // " </div>"+
  892. " </div>"+
  893. "</div>";
  894. // {
  895. // "hstUrl": "https://117.133.7.109:8443",
  896. // "hstKey": "4QY08Kyh",
  897. // "hstSecret": "HpQi5csSMrufkM)b&#YWVlr7o*wWUG3G",
  898. // "hstAuth": true,
  899. // "o2ToHstUid": "employee"
  900. // }
  901. // "<div class='line'></div>"+
  902. // "<div class='configTitle'>"+this.lp.config.apiAddress +"</div>" +
  903. // "<div><textarea name='apiAddress' style='width: 270px;height: 60px;word-break:break-all;'>"+ (d.api || "") +"</textarea></div>"+
  904. //
  905. // "<div class='configTitle'>"+this.lp.config.key +"</div>" +
  906. // "<div><input name='key' style='width: 270px;height: 26px;' value='"+(d.key || "")+"'></input></div>"+
  907. //
  908. // "<div class='configTitle'>"+this.lp.config.secret +"</div>" +
  909. // "<div><input name='secret' style='width: 270px;height: 26px;' value='"+(d.secret || "")+"'></input></div>";
  910. }
  911. this.contentNode.set("html", html);
  912. this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  913. this.contentNode.getElements("div.configTitle").setStyles(this.css.configTitleDiv);
  914. if( MWF.AC.isMeetingAdministrator() ){
  915. this.processNode = this.contentNode.getElement("[item='processArea']");
  916. this.processNode.setStyles(this.css.configProcessNode);
  917. this.createApplicationSelect();
  918. this.meetingViewerNode = this.contentNode.getElement("[item='meetingViewerNode']");
  919. //this.meetingViewerNode.setStyles(this.css.configProcessNode);
  920. this.meetingViewer = new MDomItem(this.meetingViewerNode, {
  921. name : "meetingViewer", type : "org", orgType : ["person","unit","group"], count : 0, style : this.css.configMeetingViewerNode,
  922. value : d.meetingViewer || []
  923. } , null, this.app );
  924. this.meetingViewer.load();
  925. this.mobileCreateEnableNode = this.contentNode.getElement("[item='mobileCreateEnable']");
  926. this.mobileCreateEnable = new MDomItem(this.mobileCreateEnableNode, {
  927. name : "mobileCreateEnable", type : "select", selectValue : ["true","false"], selectText : this.lp.config.mobileCreateEnableOptions,
  928. value : d.mobileCreateEnable || "true"
  929. } , null, this.app );
  930. this.mobileCreateEnable.load();
  931. this.enableOnlineNode = this.contentNode.getElement("[item='enableOnline']");
  932. this.enableOnline = new MDomItem(this.enableOnlineNode, {
  933. name : "enableOnline", type : "select", selectValue : ["true","false"], selectText : [this.lp.yes, this.lp.no],
  934. value : ( d.enableOnline || false ).toString(),
  935. event: {
  936. change: function (item, ev) {
  937. var value = item.getValue();
  938. this.contentNode.getElement("div.onlineArea").setStyle("display", value === "true" ? "" : "none");
  939. // if( this.onlineProduct.getValue() === "好视通" && value === "true" && !this.scriptEditor )this.loadScriptEditor();
  940. this.setSize();
  941. }.bind(this)
  942. }
  943. } , null, this.app );
  944. this.enableOnline.load();
  945. this.onlineProductNode = this.contentNode.getElement("[item='onlineProduct']");
  946. this.onlineProduct = new MDomItem(this.onlineProductNode, {
  947. name : "onlineProduct", type : "select", selectValue : ["其他","好视通"], selectText : [this.lp.other,"好视通"],
  948. value : d.onlineProduct || "其他",
  949. event: {
  950. change: function (item, ev ) {
  951. var value = item.getValue();
  952. this.contentNode.getElement("div.onlineConfigArea").setStyle("display", value === "好视通" ? "" : "none");
  953. // if( value === "好视通" && this.enableOnline.getValue() === "true" && !this.scriptEditor )this.loadScriptEditor();
  954. this.setSize();
  955. }.bind(this)
  956. }
  957. } , null, this.app );
  958. this.onlineProduct.load();
  959. this.hstAuthNode = this.contentNode.getElement("[item='hstAuth']");
  960. this.hstAuth = new MDomItem(this.hstAuthNode, {
  961. name : "hstAuth", type : "select", selectValue : ["true","false"], selectText : [this.lp.yes, this.lp.no],
  962. value : (d.onlineConfig.hstAuth || false).toString()
  963. // event: {
  964. // change: function (item, ev ) {
  965. // var value = item.getValue();
  966. // this.contentNode.getElement("div.o2ToHstUidArea").setStyle("display", value === "true" ? "" : "none");
  967. // this.setSize();
  968. // }.bind(this)
  969. // }
  970. } , null, this.app );
  971. this.hstAuth.load();
  972. var lp = this.lp.config;
  973. this.o2ToHstUidNode = this.contentNode.getElement("[item='o2ToHstUid']");
  974. this.o2ToHstUid = new MDomItem(this.o2ToHstUidNode, {
  975. name : "o2ToHstUid", type : "select",
  976. selectValue : ["employee", "unique", "distinguishedName", "mobile","mail", "weixin","qq"],
  977. selectText : [lp.employee, lp.unique, lp.distinguishedName, lp.mobile, lp.mail, lp.weixin, lp.qq],
  978. value : d.onlineConfig.o2ToHstUid || "employee"
  979. } , null, this.app );
  980. this.o2ToHstUid.load();
  981. // if( d.onlineProduct === "好视通" && d.enableOnline ){
  982. // this.loadScriptEditor();
  983. // }
  984. }
  985. this.actionNode = new Element("div", {"styles": this.css.configActionNode}).inject(this.node);
  986. this.cancelNode = new Element("div", {"styles": this.css.configActionCancelNode, "text": this.app.lp.cancel}).inject(this.actionNode);
  987. this.saveNode = new Element("div", {"styles": this.css.configActionSaveNode, "text": this.app.lp.save}).inject(this.actionNode);
  988. this.saveNode.addClass("mainColor_bg");
  989. this.cancelNode.addEvent("click", this.hide.bind(this));
  990. this.saveNode.addEvent("click", this.save.bind(this));
  991. this.node.addEvent("mousedown", function(e){e.stopPropagation();}.bind(this));
  992. this.setSize();
  993. this.show();
  994. },
  995. // loadScriptEditor:function(){
  996. // var json;
  997. // if( !this.configData.onlineConfig ){
  998. // json = {
  999. // 'hstUrl':'好视通服务地址',
  1000. // 'hstKey':'好视通服务接口KEY',
  1001. // 'hstSecret':'好视通服务接口SECRET',
  1002. // 'hstUserSync':'是否启用O2到好视通人员同步'
  1003. // }
  1004. // }else{
  1005. // json = this.configData.onlineConfig;
  1006. // }
  1007. // MWF.require("MWF.widget.JavascriptEditor", null, false);
  1008. // var value;
  1009. // try{
  1010. // value = JSON.stringify(json, null, "\t");
  1011. // }catch (e) {}
  1012. //
  1013. // var node = this.contentNode.getElement('div[item="onlineConfig"]');
  1014. // if( value ){
  1015. // this.scriptEditor = new MWF.widget.JavascriptEditor(node, {
  1016. // "forceType": "ace",
  1017. // "option": {"value": value, "mode" : "json" }
  1018. // });
  1019. // this.scriptEditor.load(function(){
  1020. // this.scriptEditor.setValue(value);
  1021. // }.bind(this));
  1022. // }
  1023. // },
  1024. setSize : function(){
  1025. var sizeY = this.node.getSize().y;
  1026. var y = this.app.content.getSize().y;
  1027. if( sizeY > y-50 ){
  1028. this.node.setStyle("height", y-50 );
  1029. }
  1030. },
  1031. createApplicationSelect: function(){
  1032. if (this.configData.process){
  1033. MWF.require("MWF.widget.O2Identity", function(){
  1034. var p = new MWF.widget.O2Process(this.configData.process, this.processNode);
  1035. }.bind(this));
  1036. }
  1037. this.processNode.addEvent("click", function(){
  1038. MWF.xDesktop.requireApp("Selector", "package", function(){
  1039. var options = {
  1040. "type": "Process",
  1041. "values": [this.process || this.configData.process],
  1042. "count": 1,
  1043. "onComplete": function (items) {
  1044. this.processNode.empty();
  1045. this.process = null;
  1046. this.configData.process = null;
  1047. if (items.length){
  1048. MWF.require("MWF.widget.O2Identity", function(){
  1049. var p = new MWF.widget.O2Process(items[0].data, this.processNode);
  1050. this.process = {
  1051. "name": items[0].data.name,
  1052. "id": items[0].data.id,
  1053. "application": items[0].data.application,
  1054. "applicationName": items[0].data.applicationName,
  1055. "alias": items[0].data.alias
  1056. };
  1057. this.configData.process = this.process;
  1058. }.bind(this));
  1059. }
  1060. }.bind(this)
  1061. };
  1062. var selector = new MWF.O2Selector(this.app.content, options);
  1063. }.bind(this));
  1064. }.bind(this));
  1065. },
  1066. save: function(){
  1067. //var hideMenu = "auto";
  1068. var defaultView = "toMyMeeting";
  1069. var process = null;
  1070. //var node = this.contentNode.getFirst("div");
  1071. //var hideMenuNode = node.getElement("input");
  1072. //if (hideMenuNode) if (!hideMenuNode.checked) hideMenu = "static";
  1073. //node = node.getNext();
  1074. var viewNodes = this.contentNode.getElements("input[name='configSelectDefaultView']");
  1075. for (var i=0; i<viewNodes.length; i++){
  1076. if (viewNodes[i].checked){
  1077. defaultView = viewNodes[i].get("value");
  1078. break;
  1079. }
  1080. }
  1081. MWF.UD.putData("meetingConfig", {
  1082. //"hideMenu": hideMenu,
  1083. "defaultView": defaultView
  1084. }, null, false);
  1085. if( MWF.AC.isMeetingAdministrator() ){
  1086. //if (this.processSelect){
  1087. //process = this.processSelect.options[this.processSelect.selectedIndex].get("value");
  1088. //MWF.UD.putPublicData("meetingConfig", {"process": process});
  1089. //}
  1090. var disableViewList = [];
  1091. var viewAvailableNodes = this.contentNode.getElements("input[name='configAvailableView']");
  1092. for (var i=0; i<viewAvailableNodes.length; i++){
  1093. if ( !viewAvailableNodes[i].checked){
  1094. disableViewList.push( viewAvailableNodes[i].get("value") ) ;
  1095. }
  1096. }
  1097. var weekBeginSelect = this.contentNode.getElement("select[name='configSelectWeekBeign']");
  1098. var weekBeginValue = "0";
  1099. if( weekBeginSelect ){
  1100. weekBeginValue = weekBeginSelect.options[weekBeginSelect.selectedIndex].get("value");
  1101. }
  1102. var viewer = null;
  1103. if( this.meetingViewer ){
  1104. viewer = this.meetingViewer.getValue();
  1105. }
  1106. var typeList = [];
  1107. var typeListInput = this.contentNode.getElement("textarea[name='typeList']");
  1108. if(typeListInput)typeList = typeListInput.get("value").split("\n");
  1109. // var onlineConfig;
  1110. // if( this.scriptEditor ){
  1111. // onlineConfig = this.scriptEditor.getValue();
  1112. // try{
  1113. // onlineConfig = JSON.parse( onlineConfig );
  1114. // }catch (e) {
  1115. // this.app.notice( this.app.lp.onlineConfigNotJson, "info" );
  1116. // return;
  1117. // }
  1118. // onlineConfig = JSON.parse(this.scriptEditor.getValue())
  1119. // }else{
  1120. // onlineConfig = this.configData.onlineConfig || {};
  1121. // }
  1122. var onlineConfig = {
  1123. hstUrl: this.contentNode.getElement("input[name='hstUrl']").get("value"),
  1124. hstKey: this.contentNode.getElement("input[name='hstKey']").get("value"),
  1125. hstSecret: this.contentNode.getElement("input[name='hstSecret']").get("value"),
  1126. hstAuth: this.hstAuth.getValue() === "true",
  1127. o2ToHstUid: this.o2ToHstUid.getValue(),
  1128. };
  1129. if( this.enableOnline.getValue() === "true" && this.onlineProduct.getValue() === "好视通" ){
  1130. if( !onlineConfig.hstUrl || !onlineConfig.hstKey || !onlineConfig.hstSecret ){
  1131. this.app.notice( this.app.lp.config.onlineConfigNotEmpty, "info" );
  1132. return;
  1133. }
  1134. }
  1135. var data = {
  1136. //"hideMenu": hideMenu,
  1137. "process": this.process || this.configData.process,
  1138. "weekBegin" : weekBeginValue,
  1139. "meetingViewer" : viewer,
  1140. "mobileCreateEnable" : this.mobileCreateEnable.getValue(),
  1141. "disableViewList" : disableViewList,
  1142. "typeList": typeList,
  1143. "toMyMeetingViewName" : this.contentNode.getElement("input[name='toMyMeetingViewName']").get("value"),
  1144. "toMonthViewName" : this.contentNode.getElement("input[name='toMonthViewName']").get("value"),
  1145. "toWeekViewName" : this.contentNode.getElement("input[name='toWeekViewName']").get("value"),
  1146. "toDayViewName" : this.contentNode.getElement("input[name='toDayViewName']").get("value"),
  1147. "toListViewName" : this.contentNode.getElement("input[name='toListViewName']").get("value"),
  1148. "toRoomViewName" : this.contentNode.getElement("input[name='toRoomViewName']").get("value"),
  1149. "enableOnline": this.enableOnline.getValue() === "true",
  1150. "onlineProduct": this.onlineProduct.getValue(),
  1151. "onlineConfig": onlineConfig
  1152. };
  1153. o2.Actions.load("x_meeting_assemble_control").ConfigAction.saveSystemConfig(data, function () {
  1154. this.app.meetingConfig = Object.merge(this.app.meetingConfig, data);
  1155. }.bind(this), null, false);
  1156. }
  1157. this.app.notice( this.app.lp.config_saveSuccess, "success" );
  1158. this.hide();
  1159. },
  1160. show: function(){
  1161. this.node.setStyles(MWF.AC.isMeetingAdministrator() ? this.css.configNode_admin : this.css.configNode);
  1162. var fx = new Fx.Morph(this.node, {
  1163. "duration": "500",
  1164. "transition": Fx.Transitions.Expo.easeOut
  1165. });
  1166. fx.start({
  1167. "opacity": 1
  1168. }).chain(function(){
  1169. this.hideFun = this.hide.bind(this);
  1170. this.app.node.addEvent("mousedown", this.hideFun);
  1171. }.bind(this));
  1172. },
  1173. hide: function(){
  1174. if(this.scriptEditor)this.scriptEditor.destroy();
  1175. this.node.destroy();
  1176. this.app.node.removeEvent("mousedown", this.hideFun);
  1177. MWF.release(this);
  1178. }
  1179. });