MeetingContent.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. MWF.xApplication.Homepage.MeetingContent = new Class({
  2. Extends: MWF.xApplication.Homepage.TaskContent,
  3. Implements: [Options, Events],
  4. options: {
  5. "view": "meetingContent.html"
  6. },
  7. load: function(){
  8. this.tabs = {};
  9. this.container.loadHtml(this.viewPath, {"bind": {"lp": this.app.lp}, "module": this}, function(){
  10. this.initSize();
  11. this.loadMyMeeting(function(){
  12. this.fireEvent("load");
  13. }.bind(this));
  14. // //是否需要定时自动刷新 @todo
  15. // this.startProcessAction.addEvent("click", this.startProcess.bind(this));
  16. //this.moreInforAction.addEvent("click", this.moreInfor.bind(this));
  17. }.bind(this));
  18. },
  19. openMeeting: function(e){
  20. layout.openApplication(e, "Meeting");
  21. },
  22. setContentSize: function(){
  23. var total = this.container.getSize().y;
  24. var titleHeight = this.taskTitleNode.getSize().y+this.taskTitleNode.getEdgeHeight();
  25. var bottomHeight = this.pageAreaNode.getSize().y+this.pageAreaNode.getEdgeHeight();
  26. var thisHeight = this.itemContentNode.getEdgeHeight();
  27. var contentHeight = total-titleHeight-bottomHeight-thisHeight;
  28. this.itemContentNode.setStyle("height", ""+contentHeight+"px");
  29. this.contentHeight = contentHeight;
  30. //this.pageSize = (this.options.itemHeight/this.contentHeight).toInt();
  31. if (this.noItemNode){
  32. var m = (this.contentHeight- this.noItemNode.getSize().y)/2;
  33. this.noItemNode.setStyle("margin-top", ""+m+"px");
  34. }
  35. },
  36. loadMyMeeting: function(callback){
  37. o2.Actions.load("x_meeting_assemble_control").MeetingAction.lisInvitedWait(function(json){
  38. if (json.data && json.data.length){
  39. this.loadMeetingInvited(null, callback, this.data);
  40. }else{
  41. this.loadMeeting(null, callback);
  42. }
  43. }.bind(this));
  44. },
  45. loadMeetingInvited: function(e, callback, data){
  46. if (!this.isLoading) {
  47. if (!this.invitedContentTab){
  48. this.invitedContentTab = new MWF.xApplication.Homepage.MeetingContent.MeetingInvited(this, this.invitedTab, data, {
  49. "onLoad": function(){ if (callback) callback(); }
  50. });
  51. }else{
  52. this.invitedContentTab.load();
  53. }
  54. this.currentTab = this.invitedContentTab;
  55. }
  56. },
  57. loadMeeting: function(e, callback){
  58. if (!this.isLoading) {
  59. if (!this.meetingContentTab){
  60. this.meetingContentTab = new MWF.xApplication.Homepage.MeetingContent.Meeting(this, this.meetingTab, null, {
  61. "onLoad": function(){ if (callback) callback(); }
  62. });
  63. }else{
  64. this.meetingContentTab.load();
  65. }
  66. this.currentTab = this.meetingContentTab;
  67. }
  68. }
  69. });
  70. MWF.xApplication.Homepage.MeetingContent.MeetingInvited = new Class({
  71. Extends: MWF.xApplication.Homepage.TaskContent.Task,
  72. Implements: [Options, Events],
  73. options: {
  74. "itemHeight": 80,
  75. "type": "meetingInvited"
  76. },
  77. initialize: function(content, tab, data, options){
  78. this.setOptions(options);
  79. this.content = content;
  80. this.app = this.content.app;
  81. this.container = this.content.itemContentNode;
  82. this.tab = tab;
  83. this.data = data;
  84. this.load();
  85. },
  86. loadItemsRes: function(){
  87. if (this.data){
  88. this.loadItems(this.data);
  89. this.data = null;
  90. this.fireEvent("load");
  91. }else{
  92. o2.Actions.load("x_meeting_assemble_control").MeetingAction.lisInvitedWait(function(json){
  93. if (json.data && json.data.length){
  94. this.loadItems(json.data);
  95. }else{
  96. this.emptyLoadContent();
  97. }
  98. this.fireEvent("load");
  99. }.bind(this));
  100. }
  101. },
  102. emptyLoadContent: function(){
  103. this.container.empty();
  104. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  105. this.content.pageAreaNode.empty();
  106. //this.itemContentNode.addClass("o2_homepage_task_area_content_empty").addClass("icon_notask");
  107. this.content.noItemNode = new Element("div.o2_homepage_meeting_area_content_empty_node", {"text": this.app.lp.noMeeting}).inject(this.container);
  108. var m = (this.content.contentHeight- this.content.noItemNode.getSize().y)/2;
  109. this.content.noItemNode.setStyle("margin-top", ""+m+"px");
  110. this.content.isLoading = false;
  111. },
  112. loadItems: function(data){
  113. for (var i=0; i<Math.min(data.length, this.pageSize); i++){
  114. var d = data[i];
  115. this.loadItem(d, i);
  116. }
  117. this.endLoadContent();
  118. },
  119. loadItemRow: function(d){
  120. var row = new Element("div.o2_homepage_meeting_item_node").inject(this.container);
  121. var actionArea = new Element("div.o2_homepage_meeting_item_action").inject(row);
  122. var inforArea = new Element("div.o2_homepage_meeting_item_infor").inject(row);
  123. var titleNode = new Element("div.o2_homepage_meeting_item_title", {"text": d.subject, "title": d.subject}).inject(inforArea);
  124. var timeNode = new Element("div.o2_homepage_meeting_item_time").inject(inforArea);
  125. var start = (new Date()).parse(d.startTime);
  126. var completed = (new Date()).parse(d.completedTime);
  127. var startStr = start.format("%Y-%m-%d %H:%M");
  128. var completedStr = completed.format("%H:%M");
  129. timeNode.set("html", this.app.lp.meetingTime+": <span style='color: #999999'>"+startStr+" - "+completedStr+"<span>");
  130. var locationNode = new Element("div.o2_homepage_meeting_item_location").inject(inforArea);
  131. if(d.woRoom ){
  132. locationNode.set("html", this.app.lp.meetingLocation+": <span style='color: #999999'>"+d.woRoom.name+"<span>");
  133. }else if(d.roomId){
  134. locationNode.set("html", this.app.lp.meetingNumber+": <span style='color: #999999'>"+d.roomId+"<a>");
  135. }
  136. if (!d.myAccept && !d.myReject){ //等待接受
  137. var acceptNode = new Element("div.o2_homepage_meeting_item_action_accept", {"text": this.app.lp.accept}).inject(actionArea);
  138. var rejectNode = new Element("div.o2_homepage_meeting_item_action_reject", {"text": this.app.lp.reject}).inject(actionArea);
  139. acceptNode.store("invited", d);
  140. rejectNode.store("invited", d);
  141. acceptNode.addEvent("click", function(e){
  142. var d = e.target.retrieve("invited");
  143. this.acceptInvitedConfirm(d, acceptNode, e);
  144. }.bind(this));
  145. rejectNode.addEvent("click", function(e){
  146. var d = e.target.retrieve("invited");
  147. this.rejectInvitedConfirm(d, rejectNode, e);
  148. }.bind(this));
  149. }else if (d.myAccept){ //已经参加
  150. new Element("div.o2_homepage_meeting_item_action_accepted", {"text": this.app.lp.accepted}).inject(actionArea);
  151. }else if (d.myReject){ //拒绝参加
  152. new Element("div.o2_homepage_meeting_item_action_rejected", {"text": this.app.lp.rejected}).inject(actionArea);
  153. }
  154. return row;
  155. },
  156. acceptInvitedConfirm: function(d, node, e){
  157. var text = this.app.lp.acceptConfirm;
  158. text = text.replace("{name}", d.subject);
  159. var _self = this;
  160. this.app.confirm("warn", e, this.app.lp.acceptConfirmTitle, text, 340, 100, function(){
  161. _self.acceptInvited(d, node);
  162. this.close();
  163. }, function(){this.close()})
  164. },
  165. acceptInvited: function(d, node){
  166. o2.Actions.load("x_meeting_assemble_control").MeetingAction.accpet(d.id, function(json){
  167. var actionArea = node.getParent()
  168. actionArea.empty();
  169. new Element("div.o2_homepage_meeting_item_action_accepted", {"text": this.app.lp.accepted}).inject(actionArea);
  170. }.bind(this));
  171. },
  172. rejectInvitedConfirm: function(d, node, e){
  173. var text = this.app.lp.rejectConfirm;
  174. text = text.replace("{name}", d.subject);
  175. var _self = this;
  176. this.app.confirm("warn", e, this.app.lp.rejectConfirmTitle, text, 340, 100, function(){
  177. _self.rejectInvited(d, node);
  178. this.close();
  179. }, function(){this.close()})
  180. },
  181. rejectInvited: function(d, node){
  182. o2.Actions.load("x_meeting_assemble_control").MeetingAction.reject(d.id, function(json){
  183. var actionArea = node.getParent()
  184. actionArea.empty();
  185. new Element("div.o2_homepage_meeting_item_action_rejected", {"text": this.app.lp.rejected}).inject(actionArea);
  186. }.bind(this));
  187. },
  188. loadItem: function(d, i){
  189. var row = this.loadItemRow(d, i);
  190. var _self = this;
  191. row.store("data", d);
  192. row.addEvents({
  193. "mouseover": function(){
  194. this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
  195. },
  196. "mouseout": function(){
  197. this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
  198. }
  199. });
  200. row.getLast().addEvent("click", function(e){
  201. if( d.roomLink ){
  202. window.open( d.roomLink, "_blank" );
  203. }else{
  204. layout.openApplication(e, "Meeting");
  205. }
  206. });
  207. },
  208. open: function(e, d){
  209. layout.openApplication(e, "Meeting");
  210. }
  211. });
  212. MWF.xApplication.Homepage.MeetingContent.Meeting = new Class({
  213. Extends: MWF.xApplication.Homepage.MeetingContent.MeetingInvited,
  214. Implements: [Options, Events],
  215. options: {
  216. "itemHeight": 80,
  217. "type": "meeting",
  218. "month": 1
  219. },
  220. loadItemsRes: function(){
  221. o2.Actions.load("x_meeting_assemble_control").MeetingAction.listComingMonth(this.options.month, function(json){
  222. if (json.data && json.data.length){
  223. this.loadItems(json.data);
  224. }else{
  225. this.emptyLoadContent();
  226. }
  227. this.fireEvent("load");
  228. }.bind(this));
  229. },
  230. loadItemRow: function(d){
  231. var row = new Element("div.o2_homepage_meeting_item_node").inject(this.container);
  232. var actionArea = new Element("div.o2_homepage_meeting_item_action").inject(row);
  233. var inforArea = new Element("div.o2_homepage_meeting_item_infor").inject(row);
  234. var titleNode = new Element("div.o2_homepage_meeting_item_title", {"text": d.subject, "title": d.subject}).inject(inforArea);
  235. var timeNode = new Element("div.o2_homepage_meeting_item_time").inject(inforArea);
  236. var start = (new Date()).parse(d.startTime);
  237. var completed = (new Date()).parse(d.completedTime);
  238. var startStr = start.format("%Y-%m-%d %H:%M");
  239. var completedStr = completed.format("%H:%M");
  240. timeNode.set("html", this.app.lp.meetingTime+": <span style='color: #999999'>"+startStr+" - "+completedStr+"<span>");
  241. var locationNode = new Element("div.o2_homepage_meeting_item_location").inject(inforArea);
  242. if( d.woRoom ){
  243. locationNode.set("html", this.app.lp.meetingLocation+": <span style='color: #999999'>"+d.woRoom.name+"<span>");
  244. }else if(d.roomId){
  245. locationNode.set("html", this.app.lp.meetingNumber+": <span style='color: #999999'>"+d.roomId+"<a>");
  246. }
  247. return row;
  248. },
  249. });