Main.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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(){ //111
  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. tips:function(target,title){
  58. //if(myTips) delete myTips;
  59. var myTips = new Tips(target, {
  60. onShow:function(tip, el){
  61. console.log("ttt="+title);
  62. tip.setStyles({
  63. visibility: 'hidden',
  64. display: 'block',
  65. "background-color":"#000000",
  66. "border-radius":"5px",
  67. "padding":"5px",
  68. "color":"#ffffff",
  69. "offset":{
  70. x:200,
  71. y:200
  72. }
  73. }).fade('in');
  74. },
  75. onHide:function(tip,el){
  76. myTips.setTitle("");
  77. },
  78. title:function(){
  79. return title
  80. }
  81. });
  82. myTips.setTitle(title);
  83. //if you want to add this after init
  84. // myTips.removeEvents('show').addEvent('show', function(tip, el){
  85. // console.log("ttt="+title)
  86. // tip.setStyles({
  87. // visibility: 'hidden',
  88. // display: 'block',
  89. // "background-color":"#000000",
  90. // "border-radius":"5px",
  91. // "padding":"5px",
  92. // "color":"#ffffff",
  93. // "offset":{
  94. // x:200,
  95. // y:200
  96. // },
  97. // title:function(){
  98. // return title
  99. // }
  100. // }).fade('in');
  101. // });
  102. },
  103. selectCalendar : function( target, container, options, callback ){
  104. var type = options.type;
  105. var calendarOptions = {
  106. "style" : "xform",
  107. "isTime": type == "time" || type.toLowerCase() == "datetime",
  108. "timeOnly": type == "time",
  109. "target": container,
  110. "onQueryComplate" : function( dateString ,date ){
  111. var json={
  112. "action":"ok",
  113. "dateString":dateString,
  114. "date":date
  115. };
  116. if( callback )callback( json );
  117. }.bind(this),
  118. "onClear":function(){
  119. var json={
  120. "action":"clear"
  121. };
  122. if(callback) callback(json);
  123. //if(this.calendar) delete this.calendar;
  124. }.bind(this),
  125. "onHide":function(){
  126. }.bind(this)
  127. };
  128. if( options.calendarOptions ){
  129. calendarOptions = Object.merge( calendarOptions, options.calendarOptions )
  130. }
  131. MWF.require("MWF.widget.Calendar", function(){
  132. this.calendar = new MWF.widget.Calendar( target, calendarOptions);
  133. this.calendar.show();
  134. }.bind(this));
  135. },
  136. setScrollBar: function(node, view, style, offset, callback){
  137. if (!style) style = "default";
  138. if (!offset){
  139. offset = {
  140. "V": {"x": 0, "y": 0},
  141. "H": {"x": 0, "y": 0}
  142. };
  143. }
  144. MWF.require("MWF.widget.ScrollBar", function(){
  145. if(this.scrollbar && this.scrollbar.scrollVAreaNode){
  146. this.scrollbar.scrollVAreaNode.destroy();
  147. delete this.scrollbar;
  148. }
  149. this.scrollbar = new MWF.widget.ScrollBar(node, {
  150. "style": style,
  151. "offset": offset,
  152. "where": "before",
  153. "indent": false,
  154. "distance": 100,
  155. "friction": 4,
  156. "onScroll": function (y) {
  157. var scrollSize = node.getScrollSize();
  158. var clientSize = node.getSize();
  159. var scrollHeight = scrollSize.y - clientSize.y;
  160. if (y + 200 > scrollHeight && view && view.loadElementList) {
  161. if (! view.isItemsLoaded) view.loadElementList()
  162. }
  163. }.bind(this)
  164. });
  165. if (callback) callback();
  166. }.bind(this));
  167. return false;
  168. },
  169. setLoading:function(container){
  170. var _height = container.getHeight();
  171. var _width = container.getWidth();
  172. var loading = new Element("img",{styles:this.css.loading,"src":"/x_component_TeamWork/$Main/default/icon/loading.gif"}).inject(container);
  173. //var loading = new Element("img",{"src":"/x_component_TeamWork/$Main/default/icon/loading.gif"}).inject(container);
  174. loading.setStyles({
  175. "margin-left":(_width-loading.getWidth())/2+"px"
  176. })
  177. },
  178. showErrorMessage:function(xhr,text,error){
  179. var errorText = error;
  180. var errorMessage;
  181. if (xhr) errorMessage = xhr.responseText;
  182. if(errorMessage!=""){
  183. var e = JSON.parse(errorMessage);
  184. if(e.message){
  185. this.notice( e.message,"error");
  186. }else{
  187. this.notice( errorText,"error");
  188. }
  189. }else{
  190. this.notice(errorText,"error");
  191. }
  192. },
  193. compareWithNow:function(dstr){
  194. var result = {};
  195. try{
  196. var ct = Date.parse(dstr);
  197. var intervalDay = 0;
  198. var now = new Date();
  199. var sep = now.getTime()-ct.getTime();
  200. sep = sep/1000; //毫秒
  201. //一分钟内,刚刚,一小时内,多少分钟前,2小时内,显示一小时前,2小时到今天00:00:00 显示 今天几点,本周内,显示本周几,几点几分,其他显示几月几日
  202. var cttext = "";
  203. if(sep<60){
  204. cttext = "刚刚"
  205. }else if(sep<3600){
  206. cttext = Math.floor(sep/60)+"分钟前"
  207. }else if(sep<7200){
  208. cttext = "1小时前"
  209. }else if(sep>7200 && ct.getFullYear() == now.getFullYear() && ct.getMonth()==now.getMonth() && ct.getDate() == now.getDate()){
  210. cttext = "今天"+(ct.getHours()<10?("0"+ct.getHours()):ct.getHours())+":"+(ct.getMinutes()<10?"0"+ct.getMinutes():ct.getMinutes())
  211. }else if(ct.getFullYear() == now.getFullYear() && ct.getMonth()==now.getMonth() && ct.getDate() == now.getDate()-1){
  212. cttext = "昨天"+(ct.getHours()<10?("0"+ct.getHours()):ct.getHours())+":"+(ct.getMinutes()<10?"0"+ct.getMinutes():ct.getMinutes());
  213. }else{
  214. cttext = (ct.getMonth()+1) + "月"+ct.getDay()+"日"
  215. }
  216. var sepd = ct.getTime() - now.getTime();
  217. sepd = sepd/1000;
  218. if(sepd<0){
  219. intervalDay = -1 //超时
  220. }else if(sepd /(3600*24)<2){
  221. intervalDay = 0 //一两天内
  222. }else{
  223. intervalDay = 1 //正常
  224. }
  225. result.intervalDay = intervalDay;
  226. result.text = cttext;
  227. }catch(e){
  228. result.text = dstr;
  229. }
  230. //alert(dstr + "##############" + result.intervalDay)
  231. return result;
  232. },
  233. formatDate:function(dstr,format){
  234. var result = "";
  235. try{
  236. if(dstr && dstr!=""){
  237. var ct = Date.parse(dstr);
  238. result = ct.getFullYear()+"年"+(ct.getMonth()+1)+"月"+ct.getDate()+"日"
  239. }
  240. }catch(e){}
  241. return result;
  242. },
  243. resize:function(){
  244. //alert("resize")
  245. //Project
  246. if(this.content.getElements(".taskGroupItemContainer").length>0){
  247. this.content.getElements(".taskGroupItemContainer").each(function(d){
  248. var pe = d.getParent();
  249. var pr_w = pe.getElement(".taskGroupItemTitleContainer").getHeight().toInt();
  250. var _h = pe.getHeight().toInt() - pr_w -10-10;
  251. d.setStyles({"height":_h+"px"})
  252. });
  253. }
  254. if(this.content.getElements(".foldIcon").length>0){
  255. var fo = this.content.getElements(".foldIcon")[0];
  256. var p = fo.getParent();
  257. var _margin_height = (p.getHeight())/2 - (fo.getHeight())/2;
  258. fo.setStyles({"margin-top":_margin_height+"px"});
  259. }
  260. //Task
  261. if(this.content.getElement(".taskInforContainer")){
  262. var _h = this.content.getElement(".taskInforContainer").getHeight().toInt();
  263. if(this.content.getElement(".taskInforContent")){
  264. this.content.getElement(".taskInforContent").setStyle("height",(_h+70)+"px")
  265. }
  266. }
  267. //taskGroupItemContainer
  268. //taskGroupLayout,taskGroupItemContainer 自定义高度
  269. },
  270. });