TaskMove.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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.searchDiv = new Element("div.searchDiv",{styles:this.css.searchDiv}).inject(this.contentLayout);
  82. this.searchInput = new Element("input.searchInput",{styles:this.css.searchInput,placeHolder:this.lp.searchPlace}).inject(this.searchDiv);
  83. this.searchInput.addEvents({
  84. keyup:function(e){
  85. var keycode = (e.event.keyCode ? e.event.keyCode : e.event.which);
  86. var key = this.searchInput.get("value").trim();
  87. if(keycode == 13 && key !=""){
  88. this.total = 0;
  89. this.curCount = 0;
  90. this.searchReset.show();
  91. this.taskListLayout.empty();
  92. this.loadTaskList(null,key);
  93. this.createBottomLayout();
  94. delete this.selectedItem;
  95. }
  96. }.bind(this)
  97. });
  98. this.searchReset = new Element("div.searchReset",{styles:this.css.searchReset}).inject(this.searchDiv);
  99. this.searchReset.addEvents({
  100. mouseover:function(){ this.setStyles({"background-image":"url(/x_component_TeamWork/$TaskSub/default/icon/icon_off_click.png)"}) },
  101. mouseout:function(){ this.setStyles({"background-image":"url(/x_component_TeamWork/$TaskSub/default/icon/icon_off.png)"}) },
  102. click:function(){
  103. this.total = 0;
  104. this.curCount = 0;
  105. this.searchInput.set("value","");
  106. this.searchReset.hide();
  107. this.taskListLayout.empty();
  108. this.loadTaskList();
  109. this.createBottomLayout();
  110. delete this.selectedItem;
  111. }.bind(this)
  112. });
  113. this.taskListLayout = new Element("div.taskListLayout",{styles:this.css.taskListLayout}).inject(this.contentLayout);
  114. this.taskListLayout.addEvents({
  115. scroll:function(){
  116. var stop = this.taskListLayout.getScrollTop();
  117. var cheight= this.taskListLayout.getSize().y;
  118. var sheight = this.taskListLayout.getScrollHeight();
  119. var borderWidth = this.taskListLayout.getBorder()["border-top-width"].toInt()+this.taskListLayout.getBorder()["border-bottom-width"].toInt();
  120. if(sheight == stop + cheight-borderWidth && this.isLoaded && this.curCount < this.total){
  121. this.loadTaskList(this.listId);
  122. }
  123. }.bind(this)
  124. });
  125. this.loadTaskList()
  126. },
  127. loadTaskList:function(id,key){
  128. var tmploading = new Element("div.loading",{styles:{"width":"500px"}}).inject(this.taskListLayout);
  129. this.app.setLoading(tmploading);
  130. this.taskListLayout.scrollTo(0,this.taskListLayout.getScrollSize().y);
  131. var id = this.listId = id||"(0)";
  132. var count=10;
  133. var filter = {
  134. project:this.data.data.project
  135. };
  136. if(key && key!=""){
  137. filter.title = key
  138. }
  139. this.total = this.total || 0;
  140. this.curCount = this.curCount || 0;
  141. this.isLoaded = false;
  142. //alert("curcount="+this.curCount+"total="+this.total);alert(id)
  143. //this.actions.taskListNext(id,count,filter,function(json){
  144. this.actions.listNextWithFilter(id,count,filter,function(json){
  145. this.total = json.count;
  146. this.taskListData = json.data;
  147. tmploading.destroy();
  148. this.taskListData.each(function(d,i){
  149. this.loadTaskItem(d);
  150. id = d.id;
  151. this.listId = d.id;
  152. this.curCount = this.curCount + 1;
  153. this.isLoaded = true;
  154. }.bind(this));
  155. }.bind(this))
  156. },
  157. loadTaskItem:function(data){
  158. var _self = this;
  159. var taskItem = new Element("div.taskItem",{styles:this.css.taskItem,id:data.id}).inject(this.taskListLayout);
  160. taskItem.addEvents({
  161. mouseover:function(){
  162. if(_self.selectedItem == this)return;
  163. this.setStyles({"background-color":"#f2f5f7"})
  164. },
  165. mouseout:function(){
  166. if(_self.selectedItem == this)return;
  167. this.setStyles({"background-color":""})
  168. },
  169. click:function(){
  170. if(_self.selectedItem){
  171. _self.selectedItem.setStyles({"background-color":""});
  172. _self.selectedItem.getElements(".taskName").setStyles({"color":"#666666"});
  173. }
  174. this.setStyles({"background-color":"#3da8f5"});
  175. this.getElements(".taskName").setStyles({"color":"#ffffff"});
  176. _self.okAction.setStyles({
  177. "cursor":"pointer",
  178. "background-color":"#4A90E2"
  179. });
  180. _self.selectedItem = this;
  181. }
  182. });
  183. var taskName = new Element("div.taskName",{styles:this.css.taskName,text:data.name}).inject(taskItem);
  184. var n = data.executor.split("@")[0];
  185. n = n.substr(0,1);
  186. var taskPerson = new Element("div.taskPerson",{styles:this.css.taskPerson,text:n}).inject(taskItem);
  187. },
  188. createBottomLayout:function(){
  189. this.bottomLayout.empty();
  190. this.okAction = new Element("div.okAction",{styles:this.css.okAction,text:this.lp.ok}).inject(this.bottomLayout);
  191. this.okAction.addEvents({
  192. click:function(){
  193. if(this.selectedItem){
  194. var data = {
  195. parent : this.selectedItem.get("id"),
  196. id:this.data.data.id
  197. };
  198. this.actions.save(data,function(json){
  199. this.explorer._createTableContent();
  200. this.close();
  201. }.bind(this))
  202. }
  203. }.bind(this)
  204. })
  205. }
  206. });