FileContent.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. MWF.xApplication.Homepage.FileContent = new Class({
  2. Extends: MWF.xApplication.Homepage.TaskContent,
  3. Implements: [Options, Events],
  4. options: {
  5. "view": "fileContent.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.loadMyFile(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. openFile: function(e){
  20. layout.openApplication(e, "File");
  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. loadMyFile: function(callback){
  37. this.loadFile(null, callback);
  38. },
  39. loadFile: function(e, callback){
  40. if (!this.isLoading) {
  41. if (!this.fileContentTab){
  42. this.fileContentTab = new MWF.xApplication.Homepage.FileContent.File(this, this.fileTab, {
  43. "onLoad": function(){ if (callback) callback(); }
  44. });
  45. }else{
  46. this.fileContentTab.load();
  47. }
  48. this.currentTab = this.fileContentTab;
  49. }
  50. }
  51. });
  52. MWF.xApplication.Homepage.FileContent.File = new Class({
  53. Extends: MWF.xApplication.Homepage.TaskContent.Task,
  54. Implements: [Options, Events],
  55. options: {
  56. "itemHeight": 50,
  57. "type": "file"
  58. },
  59. getIconJson: function(callback){
  60. if (!this.iconJson){
  61. o2.JSON.get("../x_component_File/$Main/icon.json", function(iconJson){
  62. this.iconJson = iconJson;
  63. if (callback) callback();
  64. }.bind(this));
  65. }else{
  66. if (callback) callback();
  67. }
  68. },
  69. loadItemsRes: function(){
  70. o2.Actions.load("x_file_assemble_control").AttachmentAction.listTop(function(json){
  71. if (json.data && json.data.length){
  72. this.getIconJson(function(){
  73. this.loadItems(json.data);
  74. }.bind(this));
  75. }else{
  76. this.emptyLoadContent();
  77. }
  78. this.fireEvent("load");
  79. }.bind(this));
  80. },
  81. emptyLoadContent: function(){
  82. this.container.empty();
  83. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  84. this.content.pageAreaNode.empty();
  85. //this.itemContentNode.addClass("o2_homepage_task_area_content_empty").addClass("icon_notask");
  86. this.content.noItemNode = new Element("div.o2_homepage_file_area_content_empty_node", {"text": this.app.lp.noFile}).inject(this.container);
  87. this.content.noItemNode.addEvent("click", function(e){
  88. layout.openApplication(e, "File");
  89. });
  90. var m = (this.content.contentHeight- this.content.noItemNode.getSize().y)/2;
  91. this.content.noItemNode.setStyle("margin-top", ""+m+"px");
  92. this.content.isLoading = false;
  93. },
  94. loadItems: function(data){
  95. for (var i=0; i<Math.min(data.length, this.pageSize); i++){
  96. var d = data[i];
  97. this.loadItem(d, i);
  98. }
  99. this.endLoadContent();
  100. },
  101. loadItemRow: function(d){
  102. var row = new Element("div.o2_homepage_file_item_node").inject(this.container);
  103. var iconArea = new Element("div.o2_homepage_file_item_icon").inject(row);
  104. var actionArea = new Element("div.o2_homepage_file_item_action", {"title": this.app.lp.download}).inject(row);
  105. var titleArea = new Element("div.o2_homepage_file_item_title", {"text": d.name, "title": d.name}).inject(row);
  106. var imgName = this.iconJson[d.extension.toLowerCase()];
  107. if (!imgName) imgName = this.iconJson["unknow"];
  108. iconArea.setStyle("background-image", "url(../x_component_File/$Main/default/file/"+imgName+")");
  109. return row;
  110. },
  111. loadItem: function(d, i){
  112. var row = this.loadItemRow(d, i);
  113. var _self = this;
  114. row.store("data", d);
  115. row.addEvents({
  116. "mouseover": function(){
  117. this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
  118. },
  119. "mouseout": function(){
  120. this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
  121. }
  122. });
  123. row.getLast().addEvent("click", function(e){
  124. var d = this.getParent().retrieve("data");
  125. _self.openAttachment(d);
  126. });
  127. row.getLast().getPrevious().addEvent("click", function(e){
  128. var d = this.getParent().retrieve("data");
  129. _self.downloadAttachment(d);
  130. });
  131. },
  132. openAttachment: function(d){
  133. o2.Actions.get("x_file_assemble_control").getFileDownloadUrl(d.id, function(url){
  134. window.open(url);
  135. });
  136. },
  137. downloadAttachment: function(d){
  138. o2.Actions.get("x_file_assemble_control").getFileUrl(d.id, function(url){
  139. window.open(url);
  140. });
  141. },
  142. open: function(e, d){
  143. layout.openApplication(e, "Meeting");
  144. }
  145. });
  146. // MWF.xApplication.Homepage.MeetingContent.Meeting = new Class({
  147. // Extends: MWF.xApplication.Homepage.MeetingContent.MeetingInvited,
  148. // Implements: [Options, Events],
  149. // options: {
  150. // "itemHeight": 80,
  151. // "type": "meetingInvited",
  152. // "month": 1
  153. // },
  154. // loadItemsRes: function(){
  155. // o2.Actions.load("x_meeting_assemble_control").MeetingAction.listComingMonth(this.options.month, function(json){
  156. // if (json.data && json.data.length){
  157. // this.loadItems(json.data);
  158. // }else{
  159. // this.emptyLoadContent();
  160. // }
  161. // this.fireEvent("load");
  162. // }.bind(this));
  163. // },
  164. // loadItemRow: function(d){
  165. // var row = new Element("div.o2_homepage_meeting_item_node").inject(this.container);
  166. //
  167. // var actionArea = new Element("div.o2_homepage_meeting_item_action").inject(row);
  168. // var inforArea = new Element("div.o2_homepage_meeting_item_infor").inject(row);
  169. //
  170. // var titleNode = new Element("div.o2_homepage_meeting_item_title", {"text": d.subject, "title": d.subject}).inject(inforArea);
  171. //
  172. // var timeNode = new Element("div.o2_homepage_meeting_item_time").inject(inforArea);
  173. // var start = (new Date()).parse(d.startTime);
  174. // var completed = (new Date()).parse(d.completedTime);
  175. // var startStr = start.format("%Y-%m-%d %H:%M");
  176. // var completedStr = start.format("%H:%M");
  177. // timeNode.set("html", this.app.lp.meetingTime+": <span style='color: #999999'>"+startStr+" - "+completedStr+"<span>");
  178. //
  179. // var locationNode = new Element("div.o2_homepage_meeting_item_location").inject(inforArea);
  180. // locationNode.set("html", this.app.lp.meetingLocation+": <span style='color: #999999'>"+d.woRoom.name+"<span>");
  181. //
  182. //
  183. // return row;
  184. // },
  185. // });