MeetingContent.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 = start.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. locationNode.set("html", this.app.lp.meetingLocation+": <span style='color: #999999'>"+d.woRoom.name+"<span>");
  132. if (!d.myAccept && !d.myReject){ //等待接受
  133. var acceptNode = new Element("div.o2_homepage_meeting_item_action_accept", {"text": this.app.lp.accept}).inject(actionArea);
  134. var rejectNode = new Element("div.o2_homepage_meeting_item_action_reject", {"text": this.app.lp.reject}).inject(actionArea);
  135. acceptNode.store("invited", d);
  136. rejectNode.store("invited", d);
  137. acceptNode.addEvent("click", function(e){
  138. var d = e.target.retrieve("invited");
  139. this.acceptInvitedConfirm(d, acceptNode, e);
  140. }.bind(this));
  141. rejectNode.addEvent("click", function(e){
  142. var d = e.target.retrieve("invited");
  143. this.rejectInvitedConfirm(d, rejectNode, e);
  144. }.bind(this));
  145. }else if (d.myAccept){ //已经参加
  146. new Element("div.o2_homepage_meeting_item_action_accepted", {"text": this.app.lp.accepted}).inject(actionArea);
  147. }else if (d.myReject){ //拒绝参加
  148. new Element("div.o2_homepage_meeting_item_action_rejected", {"text": this.app.lp.rejected}).inject(actionArea);
  149. }
  150. return row;
  151. },
  152. acceptInvitedConfirm: function(d, node, e){
  153. var text = this.app.lp.acceptConfirm;
  154. text = text.replace("{name}", d.subject);
  155. var _self = this;
  156. this.app.confirm("warn", e, this.app.lp.acceptConfirmTitle, text, 340, 100, function(){
  157. _self.acceptInvited(d, node);
  158. this.close();
  159. }, function(){this.close()})
  160. },
  161. acceptInvited: function(d, node){
  162. o2.Actions.load("x_meeting_assemble_control").MeetingAction.accpet(d.id, function(json){
  163. var actionArea = node.getParent()
  164. actionArea.empty();
  165. new Element("div.o2_homepage_meeting_item_action_accepted", {"text": this.app.lp.accepted}).inject(actionArea);
  166. }.bind(this));
  167. },
  168. rejectInvitedConfirm: function(d, node, e){
  169. var text = this.app.lp.rejectConfirm;
  170. text = text.replace("{name}", d.subject);
  171. var _self = this;
  172. this.app.confirm("warn", e, this.app.lp.rejectConfirmTitle, text, 340, 100, function(){
  173. _self.rejectInvited(d, node);
  174. this.close();
  175. }, function(){this.close()})
  176. },
  177. rejectInvited: function(d, node){
  178. o2.Actions.load("x_meeting_assemble_control").MeetingAction.reject(d.id, function(json){
  179. var actionArea = node.getParent()
  180. actionArea.empty();
  181. new Element("div.o2_homepage_meeting_item_action_rejected", {"text": this.app.lp.rejected}).inject(actionArea);
  182. }.bind(this));
  183. },
  184. loadItem: function(d, i){
  185. var row = this.loadItemRow(d, i);
  186. var _self = this;
  187. row.store("data", d);
  188. row.addEvents({
  189. "mouseover": function(){
  190. this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
  191. },
  192. "mouseout": function(){
  193. this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
  194. }
  195. });
  196. row.getLast().addEvent("click", function(e){
  197. layout.openApplication(e, "Meeting");
  198. });
  199. },
  200. open: function(e, d){
  201. layout.openApplication(e, "Meeting");
  202. }
  203. });
  204. MWF.xApplication.Homepage.MeetingContent.Meeting = new Class({
  205. Extends: MWF.xApplication.Homepage.MeetingContent.MeetingInvited,
  206. Implements: [Options, Events],
  207. options: {
  208. "itemHeight": 80,
  209. "type": "meeting",
  210. "month": 1
  211. },
  212. loadItemsRes: function(){
  213. o2.Actions.load("x_meeting_assemble_control").MeetingAction.listComingMonth(this.options.month, function(json){
  214. if (json.data && json.data.length){
  215. this.loadItems(json.data);
  216. }else{
  217. this.emptyLoadContent();
  218. }
  219. this.fireEvent("load");
  220. }.bind(this));
  221. },
  222. loadItemRow: function(d){
  223. var row = new Element("div.o2_homepage_meeting_item_node").inject(this.container);
  224. var actionArea = new Element("div.o2_homepage_meeting_item_action").inject(row);
  225. var inforArea = new Element("div.o2_homepage_meeting_item_infor").inject(row);
  226. var titleNode = new Element("div.o2_homepage_meeting_item_title", {"text": d.subject, "title": d.subject}).inject(inforArea);
  227. var timeNode = new Element("div.o2_homepage_meeting_item_time").inject(inforArea);
  228. var start = (new Date()).parse(d.startTime);
  229. var completed = (new Date()).parse(d.completedTime);
  230. var startStr = start.format("%Y-%m-%d %H:%M");
  231. var completedStr = start.format("%H:%M");
  232. timeNode.set("html", this.app.lp.meetingTime+": <span style='color: #999999'>"+startStr+" - "+completedStr+"<span>");
  233. var locationNode = new Element("div.o2_homepage_meeting_item_location").inject(inforArea);
  234. locationNode.set("html", this.app.lp.meetingLocation+": <span style='color: #999999'>"+d.woRoom.name+"<span>");
  235. return row;
  236. },
  237. });