Main.js 8.5 KB

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