Main.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. MWF.xDesktop.requireApp("TeamWork", "Common", null, false);
  2. MWF.xApplication.TeamWork.options = {
  3. multitask: false,
  4. executable: true
  5. };
  6. MWF.xApplication.TeamWork.Main = new Class({
  7. Extends: MWF.xApplication.Common.Main,
  8. Implements: [Options, Events],
  9. options: {
  10. "style": "default",
  11. "name": "TeamWork",
  12. "icon": "appicon.png",
  13. // "width": "1270",
  14. // "height": "700",
  15. // "isResize": false,
  16. // "isMax": true,
  17. "title": MWF.xApplication.TeamWork.LP.title
  18. },
  19. onQueryLoad: function(){
  20. this.lp = MWF.xApplication.TeamWork.LP;
  21. },
  22. loadApplication: function(callback){
  23. this.user = layout.desktop.session.user.name;
  24. this.distinguishedName = layout.desktop.session.user.distinguishedName;
  25. this.userGender = layout.desktop.session.user.genderType;
  26. this.department="";
  27. //this.restActions = MWF.Actions.get("x_teamwork_assemble_control");
  28. //this.orgActions = MWF.Actions.get("x_organization_assemble_express");
  29. this.rootActions = MWF.Actions.load("x_teamwork_assemble_control");
  30. this.orgActions = MWF.Actions.load("x_organization_assemble_express");
  31. this.path = "/x_component_TeamWork/$Main/";
  32. if(!this.css){
  33. this.cssPath = this.path+this.options.style+"/css.wcss";
  34. this._loadCss();
  35. }
  36. MWF.xDesktop.requireApp("TeamWork", "ProjectList", function(){
  37. this.pl = new MWF.xApplication.TeamWork.ProjectList(this.content,this,this.rootActions,{
  38. });
  39. this.pl.load();
  40. }.bind(this));
  41. this.addEvent("resize", function(){
  42. this.resize();
  43. }.bind(this));
  44. },
  45. showTips:function(target,data,opt){
  46. var opt = Object.merge( {nodeStyles:this.css.tips.nodeStyles}, opt );
  47. // if(this.stTimer){
  48. // clearTimeout(this.stTimer);
  49. // }
  50. // this.stTimer = window.setTimeout(function(){
  51. // var tt = new MWF.xApplication.TeamWork.Common.Tips(this.content, target, this.app, data, opt);
  52. // tt.load();
  53. // }.bind(this),100)
  54. this.st = new MWF.xApplication.TeamWork.Common.Tips(this.content, target, this.app, data, opt);
  55. this.st.load();
  56. },
  57. selectCalendar : function( target, container, options, callback ){
  58. var type = options.type;
  59. var calendarOptions = {
  60. "style" : "xform",
  61. "isTime": type == "time" || type.toLowerCase() == "datetime",
  62. "timeOnly": type == "time",
  63. "target": container,
  64. "onQueryComplate" : function( dateString ,date ){
  65. var json={
  66. "action":"ok",
  67. "dateString":dateString,
  68. "date":date
  69. };
  70. if( callback )callback( json );
  71. }.bind(this),
  72. "onClear":function(){
  73. var json={
  74. "action":"clear"
  75. };
  76. if(callback) callback(json);
  77. //if(this.calendar) delete this.calendar;
  78. }.bind(this),
  79. "onHide":function(){
  80. }.bind(this)
  81. };
  82. if( options.calendarOptions ){
  83. calendarOptions = Object.merge( calendarOptions, options.calendarOptions )
  84. }
  85. MWF.require("MWF.widget.Calendar", function(){
  86. this.calendar = new MWF.widget.Calendar( target, calendarOptions);
  87. this.calendar.show();
  88. }.bind(this));
  89. },
  90. setScrollBar: function(node, view, style, offset, callback){
  91. if (!style) style = "default";
  92. if (!offset){
  93. offset = {
  94. "V": {"x": 0, "y": 0},
  95. "H": {"x": 0, "y": 0}
  96. };
  97. }
  98. MWF.require("MWF.widget.ScrollBar", function(){
  99. if(this.scrollbar && this.scrollbar.scrollVAreaNode){
  100. this.scrollbar.scrollVAreaNode.destroy();
  101. delete this.scrollbar;
  102. }
  103. this.scrollbar = new MWF.widget.ScrollBar(node, {
  104. "style": style,
  105. "offset": offset,
  106. "where": "before",
  107. "indent": false,
  108. "distance": 100,
  109. "friction": 4,
  110. "onScroll": function (y) {
  111. var scrollSize = node.getScrollSize();
  112. var clientSize = node.getSize();
  113. var scrollHeight = scrollSize.y - clientSize.y;
  114. if (y + 200 > scrollHeight && view && view.loadElementList) {
  115. if (! view.isItemsLoaded) view.loadElementList()
  116. }
  117. }.bind(this)
  118. });
  119. if (callback) callback();
  120. }.bind(this));
  121. return false;
  122. },
  123. setLoading:function(container){
  124. var _height = container.getHeight();
  125. var _width = container.getWidth();
  126. var loading = new Element("img",{styles:this.css.loading,"src":"/x_component_TeamWork/$Main/default/icon/loading.gif"}).inject(container);
  127. //var loading = new Element("img",{"src":"/x_component_TeamWork/$Main/default/icon/loading.gif"}).inject(container);
  128. loading.setStyles({
  129. "margin-left":(_width-loading.getWidth())/2+"px"
  130. })
  131. },
  132. showErrorMessage:function(xhr,text,error){
  133. var errorText = error;
  134. var errorMessage;
  135. if (xhr) errorMessage = xhr.responseText;
  136. if(errorMessage!=""){
  137. var e = JSON.parse(errorMessage);
  138. if(e.message){
  139. this.notice( e.message,"error");
  140. }else{
  141. this.notice( errorText,"error");
  142. }
  143. }else{
  144. this.notice(errorText,"error");
  145. }
  146. },
  147. compareWithNow:function(dstr){
  148. var result = {};
  149. try{
  150. var ct = Date.parse(dstr);
  151. var intervalDay = 0;
  152. var now = new Date();
  153. var sep = now.getTime()-ct.getTime();
  154. sep = sep/1000; //毫秒
  155. //一分钟内,刚刚,一小时内,多少分钟前,2小时内,显示一小时前,2小时到今天00:00:00 显示 今天几点,本周内,显示本周几,几点几分,其他显示几月几日
  156. var cttext = "";
  157. if(sep<60){
  158. cttext = "刚刚"
  159. }else if(sep<3600){
  160. cttext = Math.floor(sep/60)+"分钟前"
  161. }else if(sep<7200){
  162. cttext = "1小时前"
  163. }else if(sep>7200 && ct.getFullYear() == now.getFullYear() && ct.getMonth()==now.getMonth() && ct.getDate() == now.getDate()){
  164. cttext = "今天"+(ct.getHours()<10?("0"+ct.getHours()):ct.getHours())+":"+(ct.getMinutes()<10?"0"+ct.getMinutes():ct.getMinutes())
  165. }else if(ct.getFullYear() == now.getFullYear() && ct.getMonth()==now.getMonth() && ct.getDate() == now.getDate()-1){
  166. cttext = "昨天"+(ct.getHours()<10?("0"+ct.getHours()):ct.getHours())+":"+(ct.getMinutes()<10?"0"+ct.getMinutes():ct.getMinutes());
  167. }else{
  168. cttext = (ct.getMonth()+1) + "月"+ct.getDay()+"日"
  169. }
  170. var sepd = ct.getTime() - now.getTime();
  171. sepd = sepd/1000;
  172. if(sepd<0){
  173. intervalDay = -1 //超时
  174. }else if(sepd /(3600*24)<2){
  175. intervalDay = 0 //一两天内
  176. }else{
  177. intervalDay = 1 //正常
  178. }
  179. result.intervalDay = intervalDay;
  180. result.text = cttext;
  181. }catch(e){
  182. result.text = dstr;
  183. }
  184. //alert(dstr + "##############" + result.intervalDay)
  185. return result;
  186. },
  187. formatDate:function(dstr,format){
  188. var result = "";
  189. try{
  190. if(dstr && dstr!=""){
  191. var ct = Date.parse(dstr);
  192. result = ct.getFullYear()+"年"+(ct.getMonth()+1)+"月"+ct.getDate()+"日"
  193. }
  194. }catch(e){}
  195. return result;
  196. },
  197. resize:function(){
  198. //alert("resize")
  199. //Project
  200. if(this.content.getElements(".taskGroupItemContainer").length>0){
  201. this.content.getElements(".taskGroupItemContainer").each(function(d){
  202. var pe = d.getParent();
  203. var pr_w = pe.getElement(".taskGroupItemTitleContainer").getHeight().toInt();
  204. var _h = pe.getHeight().toInt() - pr_w -10-10;
  205. d.setStyles({"height":_h+"px"})
  206. });
  207. }
  208. //Task
  209. if(this.content.getElement(".taskInforContainer")){
  210. var _h = this.content.getElement(".taskInforContainer").getHeight().toInt();
  211. if(this.content.getElement(".taskInforContent")){
  212. this.content.getElement(".taskInforContent").setStyle("height",(_h+70)+"px")
  213. }
  214. }
  215. //taskGroupItemContainer
  216. //taskGroupLayout,taskGroupItemContainer 自定义高度
  217. },
  218. });