TaskSub.js 7.8 KB

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