TaskCompletedList.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. MWF.xDesktop.requireApp("process.TaskCenter", "List", null, false);
  2. MWF.xApplication.process.TaskCenter.TaskCompletedList = new Class({
  3. Extends: MWF.xApplication.process.TaskCenter.List,
  4. createAppFilterNodes: function(){
  5. var allApp = {"name": this.app.lp.all, "application": "", "count": 0};
  6. this.allAppFilterNode = this.createAppFilterNode(allApp, "appFilterNode_current");
  7. this.currentFilterNode = this.allAppFilterNode;
  8. this.filterListNode = new Element("div", {"styles": this.css.filterListNode}).inject(this.applicationFilterAreaNode);
  9. },
  10. createFilterItemNode: function(key, v){
  11. var _self = this;
  12. var node = new Element("div", {"styles": this.css.filterListItemNode}).inject(this.filterListNode);
  13. var actionNode = new Element("div", {"styles": this.css.filterListItemActionNode}).inject(node);
  14. var textNode = new Element("div", {"styles": this.css.filterListItemTextNode}).inject(node);
  15. textNode.set("text", this.app.lp[key]+": "+ v.name);
  16. actionNode.store("key", key);
  17. node.addEvents({
  18. "mouseover": function(){
  19. this.setStyles(_self.css.filterListItemNode_over);
  20. this.getLast().setStyles(_self.css.filterListItemTextNode_over);
  21. this.getFirst().setStyles(_self.css.filterListItemActionNode_over);
  22. },
  23. "mouseout": function(){
  24. this.setStyles(_self.css.filterListItemNode);
  25. this.getLast().setStyles(_self.css.filterListItemTextNode);
  26. this.getFirst().setStyles(_self.css.filterListItemActionNode);
  27. }
  28. });
  29. actionNode.addEvent("click", function(){
  30. var key = this.retrieve("key");
  31. if (_self.filterData[key]) _self.filterData[key] = null;
  32. delete _self.filterData[key];
  33. this.destroy();
  34. _self.refilter();
  35. });
  36. },
  37. _getCurrentPageData: function(callback, count){
  38. this.app.getAction(function(){
  39. if (this.filterData){
  40. this.filterListNode.empty();
  41. var data = {};
  42. Object.each(this.filterData, function(v, key){
  43. if (key!=="key"){
  44. if (v) {
  45. //data[this.app.options.filterMap[key]] = v.value;
  46. if (!data[this.app.options.filterMap[key]]) data[this.app.options.filterMap[key]] = [];
  47. data[this.app.options.filterMap[key]].push(v.value);
  48. this.createFilterItemNode(key, v);
  49. }
  50. }else{
  51. data.key = v;
  52. }
  53. }.bind(this));
  54. if (this.filterData.key){
  55. this.createFilterItemNode("key", {"name": this.filterData.key});
  56. }
  57. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  58. this.app.action.listTaskCompletedFilter(function(json){
  59. if (callback) callback(json);
  60. }, null, id, count || this.pageCount, data);
  61. }else{
  62. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  63. this.app.action.listTaskCompletedNext(function(json){
  64. if (callback) callback(json);
  65. }, null, id, count || this.pageCount);
  66. }
  67. }.bind(this));
  68. },
  69. _getApplicationCount: function(callback){
  70. this.app.getAction(function(){
  71. this.app.action.listTaskCompletedApplication(function(json){
  72. if (callback) callback(json);
  73. }.bind(this));
  74. }.bind(this));
  75. },
  76. _createItem: function(task){
  77. return new MWF.xApplication.process.TaskCenter.TaskCompletedList.Item(task, this)
  78. }
  79. });
  80. MWF.xApplication.process.TaskCenter.TaskCompletedList.Item = new Class({
  81. Extends: MWF.xApplication.process.TaskCenter.List.Item,
  82. loadActions: function(){
  83. this.showTaskCompletedNode = new Element("div", {"styles": this.list.css.titleActionShowNode}).inject(this.actionContentNode);
  84. this.closeTaskCompletedNode = new Element("div", {"styles": this.list.css.titleActionCloseNode}).inject(this.actionContentNode);
  85. },
  86. setTimeIcon: function(){
  87. if (this.data.completed){
  88. this.newIconNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/time/pic_ok.png)");
  89. return true;
  90. }
  91. },
  92. setEvent: function(){
  93. this.node.addEvents({
  94. "mouseover": function(){this.showAction();}.bind(this),
  95. "mouseout": function(){this.hideAction();}.bind(this)
  96. });
  97. if (this.showTaskCompletedNode){
  98. this.showTaskCompletedNode.addEvent("click", function(e){
  99. this.showTaskCompleted();
  100. }.bind(this));
  101. }
  102. if (this.closeTaskCompletedNode){
  103. this.closeTaskCompletedNode.addEvent("click", function(e){
  104. this.closeTaskCompleted();
  105. }.bind(this));
  106. }
  107. if (this.rightContentNode){
  108. this.rightContentNode.addEvent("click", function(e){
  109. this.showTaskCompleted(e);
  110. }.bind(this));
  111. }
  112. },
  113. setFlowChart: function(data){
  114. var idx = 0;
  115. data.workLogTokenList = {};
  116. var current = data.workLogList.shift();
  117. data.workLogList.push(current);
  118. data.workLogList.each(function(worklog){
  119. data.workLogTokenList[worklog.fromActivityToken] = worklog;
  120. if (!worklog.taskCompletedList) worklog.taskCompletedList = [];
  121. if (!worklog.taskList) worklog.taskList = [];
  122. if (worklog.taskCompletedList.length || worklog.taskList.length){
  123. this.createFlowInforWorklogNode(worklog.fromActivityName, worklog.taskCompletedList, worklog.taskList || [], idx, worklog.fromActivityToken == data.taskCompleted.activityToken);
  124. idx++;
  125. }
  126. }.bind(this));
  127. return idx;
  128. },
  129. showAction: function(){
  130. //if (this.showTaskCompletedNode) this.showTaskCompletedNode.fade("in");
  131. },
  132. hideAction: function(){
  133. //if (this.showTaskCompletedNode) this.showTaskCompletedNode.fade("out");
  134. },
  135. _getJobByTaskComplete: function(){
  136. this.list.app.action.getSimpleJobByTaskCompleted(function(json){
  137. if (callback) callback(json.data);
  138. }.bind(this), null, this.data.id);
  139. },
  140. showTaskCompleted: function(){
  141. if (layout.mobile){
  142. this.showTaskCompleted_mobile();
  143. }else{
  144. this.showTaskCompleted_pc();
  145. }
  146. },
  147. showTaskCompleted_mobile: function(){
  148. if (!this.nodeClone){
  149. this._getSimpleJobByTaskComplete(function(data){
  150. this.nodeClone = this.mainContentNode.clone(false);
  151. this.nodeClone.inject(this.mainContentNode, "after");
  152. this.mainContentNode.setStyles(this.list.css.itemNode_edit_from_mobile);
  153. this.mainContentNode.position({
  154. relativeTo: this.nodeClone,
  155. position: "topleft",
  156. edge: "topleft"
  157. });
  158. this.showEditTaskCompletedNode(data);
  159. }.bind(this));
  160. }
  161. },
  162. showTaskCompleted_pc: function(){
  163. if (!this.nodeClone){
  164. this.list.app.content.mask({
  165. "destroyOnHide": true,
  166. "id": "mask_"+this.data.id,
  167. "style": this.list.css.maskNode
  168. });
  169. this._getSimpleJobByTaskComplete(function(data){
  170. this.nodeClone = this.mainContentNode.clone(false);
  171. this.nodeClone.inject(this.mainContentNode, "after");
  172. this.mainContentNode.setStyles(this.list.css.itemNode_edit_from);
  173. this.mainContentNode.position({
  174. relativeTo: this.nodeClone,
  175. position: "topleft",
  176. edge: "topleft"
  177. });
  178. this.showEditTaskCompletedNode(data);
  179. }.bind(this));
  180. }
  181. },
  182. _getSimpleJobByTaskComplete: function(callback){
  183. this.list.app.action.getSimpleJobByTaskCompleted(function(json){
  184. if (callback) callback(json.data);
  185. }.bind(this), null, this.data.id);
  186. },
  187. showEditTaskCompletedNode: function(data, callback){
  188. if (layout.mobile){
  189. this.showEditTaskCompletedNode_mobile(data, callback);
  190. }else{
  191. this.showEditTaskCompletedNode_pc(data, callback);
  192. }
  193. },
  194. showEditTaskCompletedNode_mobile: function(data, callback){
  195. var p = this.list.app.tabAreaNode.getPosition(this.list.app.content);
  196. var contentSize = this.list.app.contentNode.getSize();
  197. var tabSize = this.list.app.tabAreaNode.getSize();
  198. var y = contentSize.y+tabSize.y;
  199. this.list.css.itemNode_edit.top = ""+ p.y+"px";
  200. this.list.css.itemNode_edit.left = ""+ p.x+"px";
  201. this.list.css.itemNode_edit.width = ""+ contentSize.x+"px";
  202. this.list.css.itemNode_edit.height = ""+ y+"px";
  203. document.body.setStyle("-webkit-overflow-scrolling", "auto");
  204. this.showTaskCompletedNode.setStyle("display", "none");
  205. var morph = new Fx.Morph(this.mainContentNode, {
  206. "duration": 200,
  207. "transition": Fx.Transitions.Expo.easeOut,
  208. "onComplete": function(){
  209. this.resizeEditNodeFun = this.resizeEditNode.bind(this);
  210. this.list.app.addEvent("resize", this.resizeEditNodeFun);
  211. this.setEditTaskCompleledNodes(data);
  212. this.closeTaskCompletedNode.setStyle("display", "block");
  213. if (callback) callback();
  214. }.bind(this)
  215. });
  216. morph.start(this.list.css.itemNode_edit);
  217. },
  218. showEditTaskCompletedNode_pc: function(data, callback){
  219. var p = this.getEditNodePosition();
  220. this.list.css.itemNode_edit.top = ""+ p.y+"px";
  221. this.list.css.itemNode_edit.left = ""+ p.x+"px";
  222. this.showTaskCompletedNode.setStyle("display", "none");
  223. var morph = new Fx.Morph(this.mainContentNode, {
  224. "duration": 200,
  225. "transition": Fx.Transitions.Expo.easeOut,
  226. "onComplete": function(){
  227. this.resizeEditNodeFun = this.resizeEditNode.bind(this);
  228. this.list.app.addEvent("resize", this.resizeEditNodeFun);
  229. this.setEditTaskCompleledNodes(data);
  230. this.closeTaskCompletedNode.setStyle("display", "block");
  231. if (callback) callback();
  232. }.bind(this)
  233. });
  234. morph.start(this.list.css.itemNode_edit);
  235. },
  236. setEditTaskCompleledNodes: function(data){
  237. this.flowInforNode = new Element("div", {"styles": this.list.css.flowInforNode}).inject(this.mainContentNode);
  238. // this.processNode = new Element("div", {"styles": this.list.css.processNode}).inject(this.node);
  239. this.workInforNode = new Element("div", {"styles": this.list.css.workInforNode}).inject(this.mainContentNode);
  240. // this.myDoneInforNode = new Element("div", {"styles": this.list.css.myDoneInforNode}).inject(this.node);
  241. MWF.require("MWF.widget.ScrollBar", function(){
  242. new MWF.widget.ScrollBar(this.workInforNode, {
  243. "style":"xApp_Task_infor", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true}
  244. });
  245. }.bind(this));
  246. this.setFlowInfor(data);
  247. this.setWorkInfor(data);
  248. // this.setProcessor();
  249. },
  250. setWorkInfor: function(data){
  251. var lp = this.list.app.lp;
  252. var taskCompletedWorkInforTitleNode = new Element("div", {
  253. "styles": this.list.css.taskCompletedWorkInforTitleNode,
  254. "text": lp.currentFileStatus
  255. }).inject(this.workInforNode);
  256. data.workList.each(function(work){
  257. var log = data.workLogTokenList[work.activityToken];
  258. if (log){
  259. var users = [];
  260. log.taskList.each(function(task){
  261. var unit = task.department || task.unit || "";
  262. unit = unit.substring(0, unit.indexOf("@"));
  263. users.push(task.person.substring(0, task.person.indexOf("@"))+((unit) ? "("+unit+")" : ""));
  264. }.bind(this));
  265. var html = "<table border=\"0\" width=\"96%\" align=\"center\"><tr>" +
  266. "<td style=\"white-space: normal;word-break: break-all;word-wrap:break-word;\">"+
  267. ""+lp.fileat+"<font style=\"color: #00F\"> "+log.fromTime.substr(0, log.fromTime.lastIndexOf(":"))+" </font>"+lp.flowto+"<font style=\"color: #00F\"> ["+log.fromActivityName+"] </font>" +
  268. "<br/><font style=\"font-weight:bold\">"+lp.list_owner+": </font>"+users.join(", ")+"</td>" +
  269. "<td style=\"width:60px; text-align:right\"><div id=\""+work.id+"\">"+lp.open+"</div></td>" +
  270. "</tr></table>";
  271. var taskCompletedWorkInforNode = new Element("div", {
  272. "styles": this.list.css.taskCompletedWorkInforNode,
  273. "html": html
  274. }).inject(this.workInforNode);
  275. var table = taskCompletedWorkInforNode.getElement("table");
  276. //table
  277. var openNode = taskCompletedWorkInforNode.getElement("div");
  278. if (openNode) {
  279. openNode.setStyles(this.list.css.taskCompletedOpenNode);
  280. var _self = this;
  281. openNode.addEvent("click", function(e){
  282. var id = this.get("id");
  283. _self.openWorkByTaskCompleted(e, id);
  284. });
  285. }
  286. }
  287. }.bind(this));
  288. data.workCompletedList.each(function(work){
  289. // var log = data.workLogTokenList[work.activityToken];
  290. // if (log){
  291. var html = "<table border=\"0\" width=\"90%\" align=\"center\"><tr>" +
  292. "<td style=\"white-space: normal;word-break: break-all;word-wrap:break-word;\">"+work.title+"”"+lp.fileat+""+work.completedTime+""+lp.completed+"</td>" +
  293. "<td><div id=\""+work.id+"\">"+lp.open+"</div></td>" +
  294. "</tr></table>";
  295. var taskCompletedWorkInforNode = new Element("div", {
  296. "styles": this.list.css.taskCompletedWorkInforNode,
  297. "html": html
  298. }).inject(this.workInforNode);
  299. var openNode = taskCompletedWorkInforNode.getElement("div");
  300. if (openNode) {
  301. openNode.setStyles(this.list.css.taskCompletedOpenNode);
  302. var _self = this;
  303. openNode.addEvent("click", function(e){
  304. var id = this.get("id");
  305. _self.openWorkCompleteedByTaskCompleted(e, id);
  306. });
  307. }
  308. // }
  309. }.bind(this));
  310. },
  311. openWorkByTaskCompleted: function(e, id){
  312. // 判断是否是钉钉环境 是否是独立窗口
  313. if (layout.inBrowser && (o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  314. var url = "../x_desktop/work.html?workid=" + id;
  315. window.location = o2.filterUrl(url);
  316. } else {
  317. var options = {"workId": id, "readonly": true, "appId": "process.Work"+id};
  318. this.list.app.desktop.openApplication(e, "process.Work", options);
  319. }
  320. },
  321. openWorkCompleteedByTaskCompleted: function(e, id){
  322. // 判断是否是钉钉环境 是否是独立窗口
  323. if (layout.inBrowser && (o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  324. var url = "../x_desktop/work.html?workCompletedId=" + id;
  325. window.location = o2.filterUrl(url);
  326. } else {
  327. var options = {"workCompletedId": id, "readonly": true, "appId": "process.Work"+id};
  328. this.list.app.desktop.openApplication(e, "process.Work", options);
  329. }
  330. },
  331. closeTaskCompleted: function(callback){
  332. this.closeTaskCompletedNode.setStyle("display", "none");
  333. this.flowInforLeftNode.destroy();
  334. this.flowInforRightNode.destroy();
  335. this.flowInforContentNode.destroy();
  336. this.flowInforScrollNode.destroy();
  337. this.flowInforNode.destroy();
  338. this.workInforNode.destroy();
  339. // this.processNode.destroy();
  340. this.flowInforScrollFx = null;
  341. this.flowInforLeftNode = null;
  342. this.flowInforRightNode = null;
  343. this.flowInforScrollNode = null;
  344. this.flowInforContentNode = null;
  345. this.flowInforNode = null;
  346. this.workInforNode = null;
  347. delete this.flowInforScrollFx;
  348. delete this.flowInforLeftNode;
  349. delete this.flowInforRightNode;
  350. delete this.flowInforScrollNode;
  351. delete this.flowInforContentNode;
  352. delete this.flowInforNode;
  353. delete this.workInforNode;
  354. this.closeTaskCompletedDom();
  355. },
  356. closeTaskCompletedDom: function(callback){
  357. var p = this.nodeClone.getPosition(this.list.app.content);
  358. this.list.css.itemNode_edit_from.top = ""+ p.y+"px";
  359. this.list.css.itemNode_edit_from.left = ""+ p.x+"px";
  360. var morph = new Fx.Morph(this.mainContentNode, {
  361. "duration": 200,
  362. "transition": Fx.Transitions.Expo.easeIn,
  363. "onComplete": function(){
  364. this.nodeClone.destroy();
  365. this.nodeClone = null;
  366. this.list.app.content.unmask();
  367. this.mainContentNode.setStyles(this.list.css.itemMainContentAreaNode);
  368. this.mainContentNode.setStyle("opacity", 1);
  369. document.body.setStyle("-webkit-overflow-scrolling", "touch");
  370. this.list.app.removeEvent("resize", this.resizeEditNodeFun);
  371. this.showTaskCompletedNode.setStyle("display", "block");
  372. if (callback) callback();
  373. }.bind(this)
  374. });
  375. morph.start(this.list.css.itemNode_edit_from);
  376. }
  377. });