TaskMove.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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.data = data || {};
  45. this.cssPath = "/x_component_TeamWork/$TaskMove/"+this.options.style+"/css.wcss";
  46. this.load();
  47. },
  48. _setFormNodeSize:function(){
  49. var pos = this.formAreaNode.getPosition();
  50. var _height = this.formAreaNode.getHeight().toInt();
  51. var _width = this.formAreaNode.getWidth().toInt();
  52. var _top = pos.y+_height/2;
  53. var _left = pos.x + _width/2;
  54. this.formAreaNode.setStyles({"width":"0px","height":"0px","left":_left+"px","top":_top+"px","overflow":"hidden"});
  55. var time = 250;
  56. var rad = _width/_height;
  57. var fx = new Fx.Tween(this.formAreaNode,{duration:time});
  58. fx.start(["width"] ,"0px", _width+"px");
  59. var fx1 = new Fx.Tween(this.formAreaNode,{duration:time});
  60. fx1.start(["height"] ,"0px", _height+"px");
  61. var fx2 = new Fx.Tween(this.formAreaNode,{duration:time});
  62. fx2.start(["left"] ,_left+"px", pos.x+"px");
  63. var fx3 = new Fx.Tween(this.formAreaNode,{duration:time});
  64. fx3.start(["top"] ,_top+"px", pos.y+"px");
  65. },
  66. _createTableContent: function () {
  67. // this.formTableArea
  68. this.topLayout = new Element("div.topLayout",{styles:this.css.topLayout}).inject(this.formTableArea);
  69. this.createTopLayout();
  70. this.contentLayout = new Element("div.contentLayout",{styles:this.css.contentLayout}).inject(this.formTableArea);
  71. this.createContentLayout();
  72. this.bottomLayout = new Element("div.bottomLayout",{styles:this.css.bottomLayout}).inject(this.formTableArea);
  73. this.createBottomLayout();
  74. },
  75. createTopLayout:function(){
  76. this.topLayout.empty();
  77. this.topLayout.set("text",this.lp.title)
  78. },
  79. createContentLayout:function(){
  80. this.contentLayout.empty();
  81. this.taskGroupLayout = new Element("div.taskGroupLayout",{styles:this.css.taskGroupLayout}).inject(this.contentLayout);
  82. this.taskGroupLayout.addEvents({
  83. scroll:function(){
  84. var stop = this.taskGroupLayout.getScrollTop();
  85. var cheight= this.taskGroupLayout.getSize().y;
  86. var sheight = this.taskGroupLayout.getScrollHeight();
  87. var borderWidth = this.taskGroupLayout.getBorder()["border-top-width"].toInt()+this.taskGroupLayout.getBorder()["border-bottom-width"].toInt();
  88. if(sheight == stop + cheight-borderWidth && this.isLoaded && this.curCount < this.total){
  89. this.loadTaskGroup(this.listId);
  90. }
  91. }.bind(this)
  92. });
  93. this.loadTaskGroup()
  94. },
  95. loadTaskGroup:function(id,key){
  96. var tmploading = new Element("div.loading",{styles:{"width":"500px"}}).inject(this.taskGroupLayout);
  97. this.app.setLoading(tmploading);
  98. this.taskGroupLayout.scrollTo(0,this.taskGroupLayout.getScrollSize().y);
  99. var id = this.groupId = id||"(0)";
  100. var count=10;
  101. var filter = {
  102. project:this.data.data.project
  103. };
  104. if(key && key!=""){
  105. filter.title = key;
  106. }
  107. this.total = this.total || 0;
  108. this.curCount = this.curCount || 0;
  109. this.isLoaded = false;
  110. //this.data.data.project
  111. this.rootActions.TaskListAction.listWithTaskGroup(this.data.data.taskGroupId,function(json){
  112. tmploading.destroy();
  113. json.data.each(function(d){
  114. this.loadGroupItem(d);
  115. }.bind(this))
  116. }.bind(this));
  117. },
  118. loadGroupItem:function(data){
  119. var _self = this;
  120. var groupItem = new Element("div.groupItem",{styles:this.css.groupItem,id:data.id}).inject(this.taskGroupLayout);
  121. groupItem.addEvents({
  122. mouseover:function(){
  123. if(_self.selectedItem == this)return;
  124. this.setStyles({"background-color":"#f2f5f7"})
  125. },
  126. mouseout:function(){
  127. if(_self.selectedItem == this)return;
  128. this.setStyles({"background-color":""})
  129. },
  130. click:function(){
  131. if(_self.selectedItem){
  132. _self.selectedItem.setStyles({"background-color":""});
  133. _self.selectedItem.getElements(".groupName").setStyles({"color":"#666666"});
  134. }
  135. this.setStyles({"background-color":"#3da8f5"});
  136. this.getElements(".groupName").setStyles({"color":"#ffffff"});
  137. _self.okAction.setStyles({
  138. "cursor":"pointer",
  139. "background-color":"#4A90E2"
  140. });
  141. _self.selectedItem = this;
  142. }
  143. });
  144. var groupName = new Element("div.groupName",{styles:this.css.groupName,text:data.name}).inject(groupItem);
  145. // var n = data.executor.split("@")[0];
  146. // n = n.substr(0,1);
  147. //
  148. // var taskPerson = new Element("div.taskPerson",{styles:this.css.taskPerson,text:n}).inject(taskItem);
  149. },
  150. createBottomLayout:function(){
  151. this.bottomLayout.empty();
  152. this.okAction = new Element("div.okAction",{styles:this.css.okAction,text:this.lp.ok}).inject(this.bottomLayout);
  153. this.okAction.addEvents({
  154. click:function(){
  155. if(this.selectedItem){
  156. if(this.selectedItem.get("id")==this.data.data.taskListId){
  157. this.app.notice(this.lp.moveToSelf,"error");
  158. return;
  159. }
  160. // var data = {
  161. // parent : this.selectedItem.get("id"),
  162. // id:this.data.data.id
  163. // };
  164. // this.actions.save(data,function(json){
  165. // this.explorer._createTableContent();
  166. // this.close();
  167. // }.bind(this))
  168. }
  169. }.bind(this)
  170. })
  171. }
  172. });