ReadList.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. MWF.xDesktop.requireApp("process.TaskCenter", "TaskCompletedList", null, false);
  2. MWF.xApplication.process.TaskCenter.ReadList = new Class({
  3. Extends: MWF.xApplication.process.TaskCenter.TaskCompletedList,
  4. _getCurrentPageData: function(callback, count){
  5. this.app.getAction(function(){
  6. if (this.filterData){
  7. this.filterListNode.empty();
  8. var data = {};
  9. Object.each(this.filterData, function(v, key){
  10. if (key!="key"){
  11. if (v) {
  12. //data[this.app.options.filterMap[key]] = v.value;
  13. if (!data[this.app.options.filterMap[key]]) data[this.app.options.filterMap[key]] = [];
  14. data[this.app.options.filterMap[key]].push(v.value);
  15. this.createFilterItemNode(key, v);
  16. }
  17. }else{
  18. data.key = v;
  19. }
  20. }.bind(this));
  21. if (this.filterData.key){
  22. this.createFilterItemNode("key", {"name": this.filterData.key});
  23. }
  24. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  25. this.app.action.listReadFilter(function(json){
  26. if (callback) callback(json);
  27. }, null, id, count || this.pageCount, data);
  28. }else{
  29. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  30. this.app.action.listReadNext(function(json){
  31. if (callback) callback(json);
  32. }, null, id, count || this.pageCount);
  33. }
  34. }.bind(this));
  35. },
  36. _getApplicationCount: function(callback){
  37. this.app.getAction(function(){
  38. this.app.action.listReadApplication(function(json){
  39. if (callback) callback(json);
  40. }.bind(this));
  41. }.bind(this));
  42. },
  43. _createItem: function(task){
  44. return new MWF.xApplication.process.TaskCenter.ReadList.Item(task, this)
  45. },
  46. _getFilterCount: function(callback){
  47. this.app.action.listReadFilterCount(function(json){
  48. if (callback) callback(json);
  49. });
  50. }
  51. });
  52. MWF.xApplication.process.TaskCenter.ReadList.Item = new Class({
  53. Extends: MWF.xApplication.process.TaskCenter.TaskCompletedList.Item,
  54. setFlowChart: function(data){
  55. var idx = 0;
  56. data.workLogTokenList = {};
  57. data.workLogList.each(function(worklog){
  58. data.workLogTokenList[worklog.fromActivityToken] = worklog;
  59. if (!worklog.taskCompletedList) worklog.taskCompletedList = [];
  60. if (!worklog.taskList) worklog.taskList = [];
  61. if (worklog.taskCompletedList.length || worklog.taskList.length){
  62. this.createFlowInforWorklogNode(worklog.fromActivityName, worklog.taskCompletedList, worklog.taskList || [], idx, worklog.fromActivityToken == data.read.activityToken);
  63. idx++;
  64. }
  65. }.bind(this));
  66. return idx;
  67. },
  68. _getSimpleJobByTaskComplete: function(callback){
  69. this.list.app.action.getSimpleJobByRead(function(json){
  70. if (callback) callback(json.data);
  71. }.bind(this), null, this.data.id);
  72. },
  73. //loadActions: function(){
  74. // this.editNode = new Element("div", {"styles": this.list.css.titleActionReadedNode, "title": "设置为已阅"}).inject(this.titleActionNode);
  75. // this.closeNode = new Element("div", {"styles": this.list.css.titleActionCloseNode}).inject(this.titleActionNode);
  76. //},
  77. loadActions: function(){
  78. this.showTaskCompletedNode = new Element("div", {"styles": this.list.css.titleActionReadedNode, "title": this.list.app.lp.setReaded }).inject(this.actionContentNode);
  79. this.closeTaskCompletedNode = new Element("div", {"styles": this.list.css.titleActionCloseNode}).inject(this.actionContentNode);
  80. },
  81. setEvent: function(){
  82. this.node.addEvents({
  83. "mouseover": function(){this.showAction();}.bind(this),
  84. "mouseout": function(){this.hideAction();}.bind(this)
  85. });
  86. if (this.showTaskCompletedNode){
  87. this.showTaskCompletedNode.addEvent("click", function(e){
  88. this.setReadedClose(e);
  89. }.bind(this));
  90. }
  91. if (this.closeTaskCompletedNode){
  92. this.closeTaskCompletedNode.addEvent("click", function(e){
  93. this.closeTaskCompleted();
  94. }.bind(this));
  95. }
  96. if (this.rightContentNode){
  97. this.rightContentNode.addEvent("click", function(e){
  98. this.showTaskCompleted(e);
  99. }.bind(this));
  100. }
  101. },
  102. setEditTaskCompleledNodes: function(data) {
  103. this.flowInforNode = new Element("div", {"styles": this.list.css.flowInforNode}).inject(this.mainContentNode);
  104. // this.processNode = new Element("div", {"styles": this.list.css.processNode}).inject(this.node);
  105. this.workInforNode = new Element("div", {"styles": this.list.css.workInforNode}).inject(this.mainContentNode);
  106. // this.myDoneInforNode = new Element("div", {"styles": this.list.css.myDoneInforNode}).inject(this.node);
  107. MWF.require("MWF.widget.ScrollBar", function () {
  108. new MWF.widget.ScrollBar(this.workInforNode, {
  109. "style": "xApp_Task_infor",
  110. "where": "before",
  111. "distance": 30,
  112. "friction": 4,
  113. "axis": {"x": false, "y": true}
  114. });
  115. }.bind(this));
  116. this.setFlowInfor(data);
  117. this.setWorkInfor(data);
  118. this.setReadedButton();
  119. },
  120. setReadedButton: function(){
  121. this.setReadedAction = Element("div", {"styles": this.list.css.setReadedAction, "text": this.list.app.lp.setReaded}).inject(this.mainContentNode);
  122. this.setReadedAction.addEvent("click", function(e){
  123. this.setReaded(e);
  124. }.bind(this));
  125. },
  126. setReadedClose: function(e){
  127. var _self = this;
  128. var text = this.list.app.lp.setReadedConfirmContent.replace("{title}", this.data.title );
  129. this.list.app.confirm("infor", e, this.list.app.lp.setReadedConfirmTitle, text, 350, 230, function(){
  130. _self.list.app.action.setReaded(function(){
  131. this.node.destroy();
  132. this.list.refresh();
  133. }.bind(_self), null, _self.data.id, _self.data);
  134. this.close();
  135. }, function(){
  136. this.close();
  137. }, null, this.list.app.content);
  138. },
  139. setReaded: function(e){
  140. var _self = this;
  141. // var text = "您确定要将“"+this.data.title+"”标记为已阅吗?"
  142. var text = this.list.app.lp.setReadedConfirmContent.replace("{title}", this.data.title );
  143. this.list.app.confirm("infor", e, this.list.app.lp.setReadedConfirmTitle, text, 350, 230, function(){
  144. _self.list.app.action.setReaded(function(){
  145. this.closeTaskCompleted(function(){
  146. this.node.destroy();
  147. this.list.refresh();
  148. }.bind(this));
  149. }.bind(_self), null, _self.data.id, _self.data);
  150. this.close();
  151. }, function(){
  152. this.close();
  153. }, null, this.list.app.content);
  154. },
  155. openWorkByTaskCompleted: function(e, id){
  156. // 判断是否是钉钉环境 是否是独立窗口
  157. if (layout.inBrowser && (o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  158. var url = "../x_desktop/work.html?workid=" + id;
  159. window.location = o2.filterUrl(url);
  160. } else {
  161. var _self = this;
  162. var options = {"workId": id, "readonly": true, "appId": "process.Work"+id,
  163. "onQueryLoadForm" : function () {
  164. this.appForm.addEvent("afterReaded", function () {
  165. _self.node.destroy();
  166. _self.list.refresh();
  167. })
  168. }, "onPostLoadForm" :function () {
  169. }
  170. };
  171. this.list.app.desktop.openApplication(e, "process.Work", options);
  172. }
  173. },
  174. openWorkCompleteedByTaskCompleted: function(e, id){
  175. // 判断是否是钉钉环境 是否是独立窗口
  176. var ua = navigator.userAgent.toLowerCase();
  177. if (layout.inBrowser && (o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  178. var url = "../x_desktop/work.html?workCompletedId=" + id;
  179. window.location = o2.filterUrl(url);
  180. } else {
  181. var _self = this;
  182. var options = {"workCompletedId": id, "readonly": true, "appId": "process.Work"+id,
  183. "onQueryLoadForm" : function () {
  184. this.appForm.addEvent("afterReaded", function () {
  185. _self.node.destroy();
  186. _self.list.refresh();
  187. })
  188. }, "onPostLoadForm" :function () {
  189. }
  190. };
  191. this.list.app.desktop.openApplication(e, "process.Work", options);
  192. }
  193. },
  194. closeTaskCompleted: function(callback){
  195. this.closeTaskCompletedNode.setStyle("display", "none");
  196. this.flowInforLeftNode.destroy();
  197. this.flowInforRightNode.destroy();
  198. this.flowInforContentNode.destroy();
  199. this.flowInforScrollNode.destroy();
  200. this.flowInforNode.destroy();
  201. this.workInforNode.destroy();
  202. this.setReadedAction.destroy();
  203. // this.processNode.destroy();
  204. this.flowInforScrollFx = null;
  205. this.flowInforLeftNode = null;
  206. this.flowInforRightNode = null;
  207. this.flowInforScrollNode = null;
  208. this.flowInforContentNode = null;
  209. this.flowInforNode = null;
  210. this.workInforNode = null;
  211. this.setReadedAction = null;
  212. delete this.flowInforScrollFx;
  213. delete this.flowInforLeftNode;
  214. delete this.flowInforRightNode;
  215. delete this.flowInforScrollNode;
  216. delete this.flowInforContentNode;
  217. delete this.flowInforNode;
  218. delete this.workInforNode;
  219. delete this.setReadedAction;
  220. var p = this.node.getPosition(this.list.app.content);
  221. this.list.css.itemNode_edit_from.top = ""+ p.y+"px";
  222. this.list.css.itemNode_edit_from.left = ""+ p.x+"px";
  223. var morph = new Fx.Morph(this.mainContentNode, {
  224. "duration": 200,
  225. "transition": Fx.Transitions.Expo.easeIn,
  226. "onComplete": function(){
  227. this.nodeClone.destroy();
  228. this.nodeClone = null;
  229. this.list.app.content.unmask();
  230. this.mainContentNode.setStyles(this.list.css.itemMainContentAreaNode);
  231. this.mainContentNode.setStyle("opacity", 1);
  232. document.body.setStyle("-webkit-overflow-scrolling", "touch");
  233. this.list.app.removeEvent("resize", this.resizeEditNodeFun);
  234. this.showTaskCompletedNode.setStyle("display", "block");
  235. if (callback) callback();
  236. }.bind(this)
  237. });
  238. morph.start(this.list.css.itemNode_edit_from);
  239. }
  240. });