TaskMove.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. MWF.xApplication.TeamWork = MWF.xApplication.TeamWork || {};
  2. MWF.xApplication.TeamWork.TaskMove = new Class({
  3. Extends: MPopupForm,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "width": 600,
  8. "height": 450,
  9. "top": 100,
  10. "left": null,
  11. "bottom" : null,
  12. "right" : null,
  13. "minWidth" : 300,
  14. "minHeight" : 220,
  15. "isLimitSize": true,
  16. "ifFade": false,
  17. "hasTop": false,
  18. "hasTopIcon" : false,
  19. "hasTopContent" : false,
  20. "hasIcon": false,
  21. "hasBottom": false,
  22. "hasMask" : true,
  23. "closeByClickMask" : true,
  24. "hasScroll" : false,
  25. "scrollType" : "",
  26. "title": "",
  27. "draggable": false,
  28. "resizeable" : false,
  29. "maxAction" : false,
  30. "closeAction": false,
  31. "relativeToApp" : true,
  32. "sizeRelateTo" : "app", //desktop
  33. "resultSeparator" : ","
  34. },
  35. initialize: function (explorer, data, options, para) {
  36. this.setOptions(options);
  37. this.explorer = explorer;
  38. this.app = this.explorer.app;
  39. this.container = this.app.content;
  40. this.lp = this.app.lp.taskMove;
  41. //this.actions = this.explorer.actions || this.app.actions || this.app.rectActions;
  42. this.rootActions = this.app.rootActions;
  43. this.actions = this.rootActions.TaskAction;
  44. this.projectObj = this.explorer;
  45. if(para){
  46. if(para.projectObj) this.projectObj = para.projectObj;
  47. }
  48. this.data = data || {};
  49. this.cssPath = "/x_component_TeamWork/$TaskMove/"+this.options.style+"/css.wcss";
  50. this.load();
  51. },
  52. _setFormNodeSize:function(){
  53. var pos = this.formAreaNode.getPosition();
  54. var _height = this.formAreaNode.getHeight().toInt();
  55. var _width = this.formAreaNode.getWidth().toInt();
  56. var _top = pos.y+_height/2;
  57. var _left = pos.x + _width/2;
  58. this.formAreaNode.setStyles({"width":"0px","height":"0px","left":_left+"px","top":_top+"px","overflow":"hidden"});
  59. var time = 250;
  60. var rad = _width/_height;
  61. var fx = new Fx.Tween(this.formAreaNode,{duration:time});
  62. fx.start(["width"] ,"0px", _width+"px");
  63. var fx1 = new Fx.Tween(this.formAreaNode,{duration:time});
  64. fx1.start(["height"] ,"0px", _height+"px");
  65. var fx2 = new Fx.Tween(this.formAreaNode,{duration:time});
  66. fx2.start(["left"] ,_left+"px", pos.x+"px");
  67. var fx3 = new Fx.Tween(this.formAreaNode,{duration:time});
  68. fx3.start(["top"] ,_top+"px", pos.y+"px");
  69. },
  70. _createTableContent: function () {
  71. // this.formTableArea
  72. this.topLayout = new Element("div.topLayout",{styles:this.css.topLayout}).inject(this.formTableArea);
  73. this.createTopLayout();
  74. this.contentLayout = new Element("div.contentLayout",{styles:this.css.contentLayout}).inject(this.formTableArea);
  75. this.createContentLayout();
  76. this.bottomLayout = new Element("div.bottomLayout",{styles:this.css.bottomLayout}).inject(this.formTableArea);
  77. this.createBottomLayout();
  78. },
  79. createTopLayout:function(){
  80. this.topLayout.empty();
  81. this.topLayout.set("text",this.lp.title)
  82. },
  83. createContentLayout:function(){
  84. this.contentLayout.empty();
  85. this.taskGroupLayout = new Element("div.taskGroupLayout",{styles:this.css.taskGroupLayout}).inject(this.contentLayout);
  86. this.taskGroupLayout.addEvents({
  87. scroll:function(){
  88. var stop = this.taskGroupLayout.getScrollTop();
  89. var cheight= this.taskGroupLayout.getSize().y;
  90. var sheight = this.taskGroupLayout.getScrollHeight();
  91. var borderWidth = this.taskGroupLayout.getBorder()["border-top-width"].toInt()+this.taskGroupLayout.getBorder()["border-bottom-width"].toInt();
  92. if(sheight == stop + cheight-borderWidth && this.isLoaded && this.curCount < this.total){
  93. this.loadTaskGroup(this.listId);
  94. }
  95. }.bind(this)
  96. });
  97. this.loadTaskGroup()
  98. },
  99. loadTaskGroup:function(id,key){
  100. var tmploading = new Element("div.loading",{styles:{"width":"500px"}}).inject(this.taskGroupLayout);
  101. this.app.setLoading(tmploading);
  102. this.taskGroupLayout.scrollTo(0,this.taskGroupLayout.getScrollSize().y);
  103. var id = this.groupId = id||"(0)";
  104. var count=10;
  105. var filter = {
  106. project:this.data.data.project
  107. };
  108. if(key && key!=""){
  109. filter.title = key;
  110. }
  111. this.total = this.total || 0;
  112. this.curCount = this.curCount || 0;
  113. this.isLoaded = false;
  114. //this.data.data.project
  115. this.rootActions.TaskListAction.listWithTaskGroup(this.data.data.taskGroupId,function(json){
  116. tmploading.destroy();
  117. json.data.each(function(d){
  118. this.loadGroupItem(d);
  119. }.bind(this))
  120. }.bind(this));
  121. },
  122. loadGroupItem:function(data){
  123. var _self = this;
  124. var groupItem = new Element("div.groupItem",{styles:this.css.groupItem,id:data.id}).inject(this.taskGroupLayout);
  125. groupItem.addEvents({
  126. mouseover:function(){
  127. if(_self.selectedItem == this)return;
  128. this.setStyles({"background-color":"#f2f5f7"})
  129. },
  130. mouseout:function(){
  131. if(_self.selectedItem == this)return;
  132. this.setStyles({"background-color":""})
  133. },
  134. click:function(){
  135. if(_self.selectedItem){
  136. _self.selectedItem.setStyles({"background-color":""});
  137. _self.selectedItem.getElements(".groupName").setStyles({"color":"#666666"});
  138. }
  139. this.setStyles({"background-color":"#3da8f5"});
  140. this.getElements(".groupName").setStyles({"color":"#ffffff"});
  141. _self.okAction.setStyles({
  142. "cursor":"pointer",
  143. "background-color":"#4A90E2"
  144. });
  145. _self.selectedItem = this;
  146. }
  147. });
  148. var groupName = new Element("div.groupName",{styles:this.css.groupName,text:data.name}).inject(groupItem);
  149. // var n = data.executor.split("@")[0];
  150. // n = n.substr(0,1);
  151. //
  152. // var taskPerson = new Element("div.taskPerson",{styles:this.css.taskPerson,text:n}).inject(taskItem);
  153. },
  154. createBottomLayout:function(){
  155. this.bottomLayout.empty();
  156. this.okAction = new Element("div.okAction",{styles:this.css.okAction,text:this.lp.ok}).inject(this.bottomLayout);
  157. this.okAction.addEvents({
  158. click:function(){
  159. if(this.selectedItem){
  160. if(this.selectedItem.get("id")==this.data.data.taskListId){
  161. this.app.notice(this.lp.moveToSelf,"info");
  162. return;
  163. }
  164. var data = {
  165. taskId:this.data.data.id
  166. }
  167. this.rootActions.TaskListAction.addTask2ListWithBehindTask(this.selectedItem.get("id"),data,function(json){
  168. if(json.data.id){
  169. //this.app.notice(json.data.message,"success");
  170. this.projectObj.reloadTaskGroup(json.data.id); //reload to list
  171. this.projectObj.reloadTaskGroup(this.data.data.taskListId); //reload from list
  172. //this.explorer.projectObj.reloadTaskGroup(json.data.id);
  173. //this.explorer.projectObj.reloadTaskGroup(this.data.data.taskListId);
  174. // if(this.explorer.explorer){
  175. // this.explorer.explorer.reloadTaskGroup(json.data.id);
  176. // this.explorer.explorer.reloadTaskGroup(this.data.data.taskListId);
  177. // }
  178. }else{
  179. this.app.notice("不允许转移到未分类列表","error")
  180. }
  181. this.close();
  182. }.bind(this))
  183. }
  184. }.bind(this)
  185. })
  186. }
  187. });