TaskMove.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.data = data || {};
  43. this.cssPath = "/x_component_TeamWork/$TaskMove/"+this.options.style+"/css.wcss";
  44. this.load();
  45. },
  46. _setFormNodeSize:function(){
  47. var pos = this.formAreaNode.getPosition();
  48. var _height = this.formAreaNode.getHeight().toInt();
  49. var _width = this.formAreaNode.getWidth().toInt();
  50. var _top = pos.y+_height/2;
  51. var _left = pos.x + _width/2;
  52. this.formAreaNode.setStyles({"width":"0px","height":"0px","left":_left+"px","top":_top+"px","overflow":"hidden"});
  53. var time = 250;
  54. var rad = _width/_height;
  55. var fx = new Fx.Tween(this.formAreaNode,{duration:time});
  56. fx.start(["width"] ,"0px", _width+"px");
  57. var fx1 = new Fx.Tween(this.formAreaNode,{duration:time});
  58. fx1.start(["height"] ,"0px", _height+"px");
  59. var fx2 = new Fx.Tween(this.formAreaNode,{duration:time});
  60. fx2.start(["left"] ,_left+"px", pos.x+"px");
  61. var fx3 = new Fx.Tween(this.formAreaNode,{duration:time});
  62. fx3.start(["top"] ,_top+"px", pos.y+"px");
  63. },
  64. _createTableContent: function () {
  65. this.formTableArea
  66. this.topLayout = new Element("div.topLayout",{styles:this.css.topLayout}).inject(this.formTableArea);
  67. this.createTopLayout();
  68. this.contentLayout = new Element("div.contentLayout",{styles:this.css.contentLayout}).inject(this.formTableArea);
  69. this.createContentLayout();
  70. this.bottomLayout = new Element("div.bottomLayout",{styles:this.css.bottomLayout}).inject(this.formTableArea);
  71. this.createBottomLayout();
  72. },
  73. createTopLayout:function(){
  74. this.topLayout.empty();
  75. this.topLayout.set("text",this.lp.title)
  76. },
  77. createContentLayout:function(){
  78. this.contentLayout.empty();
  79. this.searchDiv = new Element("div.searchDiv",{styles:this.css.searchDiv}).inject(this.contentLayout);
  80. this.searchInput = new Element("input.searchInput",{styles:this.css.searchInput,placeHolder:this.lp.searchPlace}).inject(this.searchDiv);
  81. this.searchInput.addEvents({
  82. keyup:function(e){
  83. var keycode = (e.event.keyCode ? e.event.keyCode : e.event.which);
  84. var key = this.searchInput.get("value").trim();
  85. if(keycode == 13 && key !=""){
  86. this.total = 0;
  87. this.curCount = 0;
  88. this.searchReset.show();
  89. this.taskListLayout.empty();
  90. this.loadTaskList(null,key);
  91. this.createBottomLayout();
  92. delete this.selectedItem;
  93. }
  94. }.bind(this)
  95. });
  96. this.searchReset = new Element("div.searchReset",{styles:this.css.searchReset}).inject(this.searchDiv);
  97. this.searchReset.addEvents({
  98. mouseover:function(){ this.setStyles({"background-image":"url(/x_component_TeamWork/$TaskSub/default/icon/icon_off_click.png)"}) },
  99. mouseout:function(){ this.setStyles({"background-image":"url(/x_component_TeamWork/$TaskSub/default/icon/icon_off.png)"}) },
  100. click:function(){
  101. this.total = 0;
  102. this.curCount = 0;
  103. this.searchInput.set("value","");
  104. this.searchReset.hide();
  105. this.taskListLayout.empty();
  106. this.loadTaskList();
  107. this.createBottomLayout();
  108. delete this.selectedItem;
  109. }.bind(this)
  110. });
  111. this.taskListLayout = new Element("div.taskListLayout",{styles:this.css.taskListLayout}).inject(this.contentLayout);
  112. this.taskListLayout.addEvents({
  113. scroll:function(){
  114. var stop = this.taskListLayout.getScrollTop();
  115. var cheight= this.taskListLayout.getSize().y;
  116. var sheight = this.taskListLayout.getScrollHeight();
  117. var borderWidth = this.taskListLayout.getBorder()["border-top-width"].toInt()+this.taskListLayout.getBorder()["border-bottom-width"].toInt();
  118. if(sheight == stop + cheight-borderWidth && this.isLoaded && this.curCount < this.total){
  119. this.loadTaskList(this.listId);
  120. }
  121. }.bind(this)
  122. });
  123. this.loadTaskList()
  124. },
  125. loadTaskList:function(id,key){
  126. var tmploading = new Element("div.loading",{styles:{"width":"500px"}}).inject(this.taskListLayout);
  127. this.app.setLoading(tmploading);
  128. this.taskListLayout.scrollTo(0,this.taskListLayout.getScrollSize().y);
  129. var id = this.listId = id||"(0)";
  130. var count=10;
  131. var filter = {
  132. project:this.data.data.project
  133. };
  134. if(key && key!=""){
  135. filter.title = key
  136. }
  137. this.total = this.total || 0;
  138. this.curCount = this.curCount || 0;
  139. this.isLoaded = false;
  140. //alert("curcount="+this.curCount+"total="+this.total);alert(id)
  141. this.actions.taskListNext(id,count,filter,function(json){
  142. this.total = json.count;
  143. this.taskListData = json.data;
  144. tmploading.destroy();
  145. this.taskListData.each(function(d,i){
  146. this.loadTaskItem(d);
  147. id = d.id;
  148. this.listId = d.id;
  149. this.curCount = this.curCount + 1;
  150. this.isLoaded = true;
  151. }.bind(this));
  152. }.bind(this))
  153. },
  154. loadTaskItem:function(data){
  155. var _self = this;
  156. var taskItem = new Element("div.taskItem",{styles:this.css.taskItem,id:data.id}).inject(this.taskListLayout);
  157. taskItem.addEvents({
  158. mouseover:function(){
  159. if(_self.selectedItem == this)return;
  160. this.setStyles({"background-color":"#f2f5f7"})
  161. },
  162. mouseout:function(){
  163. if(_self.selectedItem == this)return;
  164. this.setStyles({"background-color":""})
  165. },
  166. click:function(){
  167. if(_self.selectedItem){
  168. _self.selectedItem.setStyles({"background-color":""});
  169. _self.selectedItem.getElements(".taskName").setStyles({"color":"#666666"});
  170. }
  171. this.setStyles({"background-color":"#3da8f5"});
  172. this.getElements(".taskName").setStyles({"color":"#ffffff"});
  173. _self.okAction.setStyles({
  174. "cursor":"pointer",
  175. "background-color":"#4A90E2"
  176. })
  177. _self.selectedItem = this;
  178. }
  179. });
  180. var taskName = new Element("div.taskName",{styles:this.css.taskName,text:data.name}).inject(taskItem);
  181. var n = data.executor.split("@")[0];
  182. n = n.substr(0,1);
  183. var taskPerson = new Element("div.taskPerson",{styles:this.css.taskPerson,text:n}).inject(taskItem);
  184. },
  185. createBottomLayout:function(){
  186. this.bottomLayout.empty();
  187. this.okAction = new Element("div.okAction",{styles:this.css.okAction,text:this.lp.ok}).inject(this.bottomLayout);
  188. this.okAction.addEvents({
  189. click:function(){
  190. if(this.selectedItem){
  191. var data = {
  192. parent : this.selectedItem.get("id"),
  193. id:this.data.data.id
  194. }
  195. this.actions.taskSave(data,function(json){
  196. this.explorer._createTableContent();
  197. this.close();
  198. }.bind(this))
  199. }
  200. }.bind(this)
  201. })
  202. }
  203. });