TaskContent.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. MWF.xApplication.Homepage.TaskContent = new Class({
  2. Implements: [Options, Events],
  3. options: {
  4. "view": "taskContent.html"
  5. },
  6. initialize: function(app, container, options){
  7. this.setOptions(options);
  8. this.app = app;
  9. this.container = container;
  10. this.viewPath = this.app.path+this.app.options.style+"/"+this.options.view;
  11. this.load();
  12. },
  13. load: function(){
  14. this.container.loadHtml(this.viewPath, {"bind": {"lp": this.app.lp}, "module": this}, function(){
  15. this.initSize();
  16. this.loadCount();
  17. this.loadTask(function(){
  18. this.fireEvent("load");
  19. }.bind(this));
  20. //是否需要定时自动刷新 @todo
  21. //this.startProcessAction.addEvent("click", this.startProcess.bind(this));
  22. }.bind(this));
  23. },
  24. startProcess: function(){
  25. o2.requireApp([["process.TaskCenter", "lp."+o2.language], ["process.TaskCenter", ""]],"", function(){
  26. var obj = {
  27. "lp": MWF.xApplication.process.TaskCenter.LP,
  28. "content": this.app.content,
  29. "addEvent": function(type, fun){
  30. this.app.addEvent(type, fun);
  31. }.bind(this),
  32. "getAction": function (callback) {
  33. if (!this.action) {
  34. this.action = MWF.Actions.get("x_processplatform_assemble_surface");
  35. if (callback) callback();
  36. } else {
  37. if (callback) callback();
  38. }
  39. },
  40. "desktop": layout.desktop,
  41. "refreshAll": function(){},
  42. "notice": this.app.notice,
  43. }
  44. o2.JSON.get("/x_component_process_TaskCenter/$Main/default/css.wcss", function(data){
  45. obj.css = data;
  46. }, false);
  47. if (!this.processStarter) this.processStarter = new MWF.xApplication.process.TaskCenter.Starter(obj, {
  48. "onStartProcess": function(){
  49. if (this.currentTab.options.type == "task") this.currentTab.reload();
  50. }.bind(this)
  51. });
  52. this.processStarter.load();
  53. }.bind(this));
  54. },
  55. initSize: function(){
  56. this.setContentSize();
  57. this.app.addEvent("resize", this.setContentSize.bind(this));
  58. },
  59. setContentSize: function(){
  60. var total = this.container.getSize().y;
  61. var titleHeight = this.taskTitleNode.getSize().y+this.taskTitleNode.getEdgeHeight();
  62. var bottomHeight = this.pageAreaNode.getSize().y+this.pageAreaNode.getEdgeHeight();
  63. var thisHeight = this.itemContentNode.getEdgeHeight();
  64. var contentHeight = total-titleHeight-bottomHeight-thisHeight;
  65. this.itemContentNode.setStyle("height", ""+contentHeight+"px");
  66. this.contentHeight = contentHeight;
  67. //this.pageSize = (this.options.itemHeight/this.contentHeight).toInt();
  68. if (this.noItemNode){
  69. var m = (this.contentHeight- this.noItemNode.getSize().y)/2;
  70. this.noItemNode.setStyle("margin-top", ""+m+"px");
  71. }
  72. },
  73. loadCount: function(){
  74. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.countWithPerson(layout.session.user.id, function(json){
  75. if (!this.itemCounts) this.itemCounts = {};
  76. this.itemCounts.task = json.data.task;
  77. this.itemCounts.taskCompleted = json.data.taskCompleted;
  78. this.itemCounts.read = json.data.read;
  79. this.itemCounts.readCompleted = json.data.readCompleted;
  80. this.showTabCount(this.taskTab, json.data.task);
  81. this.showTabCount(this.taskCompletedTab, json.data.taskCompleted);
  82. this.showTabCount(this.readTab, json.data.read);
  83. this.showTabCount(this.readCompletedTab, json.data.readCompleted);
  84. this.fireEvent("loadTaskCount");
  85. this.fireEvent("loadReadCount");
  86. this.fireEvent("loadTaskCompletedCount");
  87. this.fireEvent("loadReadCompletedCount");
  88. }.bind(this));
  89. o2.Actions.load("x_processplatform_assemble_surface").ReviewAction.V2Count({"creatorPersonList": [layout.session.user.id]}, function(json){
  90. if (!this.itemCounts) this.itemCounts = {};
  91. this.itemCounts.draft = json.data.count;
  92. this.showTabCount(this.draftTab, json.data.count);
  93. this.fireEvent("loadDraftCount");
  94. }.bind(this));
  95. },
  96. showTabCount: function(node, count){
  97. var text = node.get("text");
  98. node.set("text", text+"("+count+")");
  99. },
  100. tabover: function(e){
  101. e.currentTarget.addClass("o2_homepage_title_tab_over");
  102. },
  103. tabout: function(e){
  104. e.currentTarget.removeClass("o2_homepage_title_tab_over");
  105. //e.currentTarget.removeClass("mainColor_border").removeClass("mainColor_color");
  106. },
  107. loadTask: function(callback){
  108. if (!this.isLoading){
  109. if (!this.taskContentTab){
  110. this.taskContentTab = new MWF.xApplication.Homepage.TaskContent.Task(this, this.taskTab, {
  111. "onLoad": function(){ if (callback) callback(); }
  112. });
  113. }else{
  114. this.taskContentTab.reload();
  115. }
  116. this.currentTab = this.taskContentTab;
  117. }
  118. },
  119. loadTaskCompleted: function(){
  120. if (!this.isLoading){
  121. if (!this.taskCompletedContentTab){
  122. this.taskCompletedContentTab = new MWF.xApplication.Homepage.TaskContent.TaskCompleted(this, this.taskCompletedTab);
  123. }else{
  124. this.taskCompletedContentTab.reload();
  125. }
  126. this.currentTab = this.taskCompletedContentTab;
  127. }
  128. },
  129. loadRead: function(){
  130. if (!this.isLoading){
  131. if (!this.readContentTab){
  132. this.readContentTab = new MWF.xApplication.Homepage.TaskContent.Read(this, this.readTab);
  133. }else{
  134. this.readContentTab.reload();
  135. }
  136. this.currentTab = this.readContentTab;
  137. }
  138. },
  139. loadReadCompleted: function(){
  140. if (!this.isLoading){
  141. if (!this.readCompletedContentTab){
  142. this.readCompletedContentTab = new MWF.xApplication.Homepage.TaskContent.ReadCompleted(this, this.readCompletedTab);
  143. }else{
  144. this.readCompletedContentTab.reload();
  145. }
  146. this.currentTab = this.readCompletedContentTab;
  147. }
  148. },
  149. loadDraft: function(){
  150. if (!this.isLoading){
  151. if (!this.draftContentTab){
  152. this.draftContentTab = new MWF.xApplication.Homepage.TaskContent.Draft(this, this.draftTab);
  153. }else{
  154. this.draftContentTab.reload();
  155. }
  156. this.currentTab = this.draftContentTab;
  157. }
  158. }
  159. });
  160. MWF.xApplication.Homepage.TaskContent.Task = new Class({
  161. Implements: [Options, Events],
  162. options: {
  163. "itemHeight": 40,
  164. "showPages": 5,
  165. "type": "task"
  166. },
  167. initialize: function(content, tab, options){
  168. this.setOptions(options);
  169. this.content = content;
  170. this.app = this.content.app;
  171. this.container = this.content.itemContentNode;
  172. this.tab = tab;
  173. this.load();
  174. },
  175. load: function(){
  176. this.beginLoadContent();
  177. this.showTab();
  178. this.initItemCount();
  179. this.loadItemsRes();
  180. },
  181. loadItemsRes: function(){
  182. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.listMyPaging(this.page, this.pageSize, function(json){
  183. if (json.data && json.data.length){
  184. this.loadItems(json.data);
  185. this.checkLoadPage();
  186. }else{
  187. this.emptyLoadContent();
  188. }
  189. this.fireEvent("load");
  190. }.bind(this));
  191. },
  192. reload: function(){
  193. if (!this.content.isLoading) {
  194. this.beginLoadContent();
  195. this.showTab();
  196. this.initItemCount(this.page);
  197. this.loadItemsRes();
  198. }
  199. },
  200. initItemCount: function(count){
  201. this.page = count || 1;
  202. this.pageSize = (this.container.getSize().y/this.options.itemHeight).toInt();
  203. },
  204. beginLoadContent: function(){
  205. if (this.content.currentTab) this.content.currentTab.hideTab();
  206. this.container.empty();
  207. this.content.noItemNode = null;
  208. this.container.addClass("o2_homepage_area_content_loading").addClass("icon_loading");
  209. this.content.isLoading = true;
  210. },
  211. endLoadContent: function(){
  212. if (this.content.noItemNode){
  213. this.content.noItemNode.destroy();
  214. this.content.noItemNode = null;
  215. }
  216. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  217. this.content.isLoading = false;
  218. },
  219. emptyLoadContent: function(){
  220. this.container.empty();
  221. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  222. this.content.pageAreaNode.empty();
  223. //this.itemContentNode.addClass("o2_homepage_task_area_content_empty").addClass("icon_notask");
  224. this.content.noItemNode = new Element("div.o2_homepage_task_area_content_empty_node", {"text": this.app.lp.noWork}).inject(this.container);
  225. var m = (this.content.contentHeight- this.content.noItemNode.getSize().y)/2;
  226. this.content.noItemNode.setStyle("margin-top", ""+m+"px");
  227. this.content.isLoading = false;
  228. },
  229. hideTab: function(){
  230. this.container.empty();
  231. this.content.currentTab = null;
  232. this.tab.removeClass("mainColor_color").removeClass("mainColor_border").removeClass("o2_homepage_title_tab_current").removeClass("o2_homepage_title_tab_over");
  233. // if (this.destroy) this.destroy();
  234. // o2.release(this);
  235. },
  236. showTab: function(){
  237. this.content.currentTab = this;
  238. this.tab.addClass("mainColor_color").addClass("mainColor_border").addClass("o2_homepage_title_tab_current").removeClass("o2_homepage_title_tab_over");
  239. },
  240. loadItems: function(data){
  241. var table = new Element("table", { "width": "100%", "border": 0, "cellpadding": 0, "cellspacing": 0 }).inject(this.container);
  242. data.each(function(d, i){
  243. this.loadItem(table, d, i);
  244. }.bind(this));
  245. this.endLoadContent();
  246. },
  247. loadItemRow: function(table, d, i){
  248. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  249. var idx = (this.page-1)*this.pageSize+i+1;
  250. var idxShow = (idx>99) ? "···" : idx;
  251. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  252. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  253. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  254. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  255. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  256. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  257. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  258. new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title": this.app.lp.currentActivity + ": " + d.activityName}).inject(cell);
  259. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  260. new Element("div.o2_homepage_task_item_creator", {"text": o2.name.cn(d.creatorPerson), "title": this.app.lp.draftUser + ": " + o2.name.cn(d.creatorPerson)}).inject(cell);
  261. var time = d.startTime.substr(0,10);
  262. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  263. new Element("div.o2_homepage_task_item_time", {"text": time, "title":this.app.lp.taskStartTime + ": " + time}).inject(cell);
  264. return row;
  265. },
  266. loadItem: function(table, d, i){
  267. var row = this.loadItemRow(table, d, i)
  268. var _self = this;
  269. row.store("data", d);
  270. row.addEvents({
  271. "mouseover": function(){
  272. this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
  273. this.getElement("div").addClass("mainColor_bg").addClass("o2_homepage_task_item_number_over");
  274. },
  275. "mouseout": function(){
  276. this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
  277. this.getElement("div").removeClass("mainColor_bg").removeClass("o2_homepage_task_item_number_over");
  278. },
  279. "click": function(e){
  280. var d = this.retrieve("data");
  281. if (d) {
  282. _self.open(e, d);
  283. }
  284. }
  285. })
  286. },
  287. reloadTasks: function(){
  288. var type = this.content.currentTab.options.type;
  289. if (type=="task" || type=="taskCompleted"){
  290. this.content.currentTab.reload();
  291. }
  292. },
  293. reloadReads: function(){
  294. var type = this.content.currentTab.options.type;
  295. if (type=="read" || type=="readCompleted"){
  296. this.content.currentTab.reload();
  297. }
  298. },
  299. open: function(e, d){
  300. // this._getJobByTask(function(data){
  301. var options = {
  302. "workId": d.work, "appId": "process.Work"+d.work,
  303. "onAfterProcess": this.reloadTasks.bind(this),
  304. "onAfterReset": this.reloadTasks.bind(this),
  305. "onAfterRetract": this.reloadTasks.bind(this),
  306. "onAfterReroute": this.reloadTasks.bind(this),
  307. "onAfterDelete": this.reloadTasks.bind(this),
  308. "onAfterReaded": this.reloadReads.bind(this),
  309. };
  310. layout.openApplication(e, "process.Work", options);
  311. // }.bind(this));
  312. },
  313. checkLoadPage: function(){
  314. if (this.content.itemCounts && this.content.itemCounts.task){
  315. this.getPageCount();
  316. this.loadPage();
  317. }else{
  318. this.addLoadPageEvent();
  319. }
  320. },
  321. addLoadPageEvent: function(){
  322. var loadPage = function(){
  323. this.getPageCount();
  324. this.loadPage();
  325. this.content.removeEvent("loadTaskCount", loadPage);
  326. }.bind(this);
  327. this.content.addEvent("loadTaskCount", loadPage);
  328. },
  329. getPageCount:function(){
  330. var n = this.content.itemCounts.task/this.pageSize;
  331. var nInt = n.toInt();
  332. this.pages = (nInt===n) ? nInt : nInt+1;
  333. },
  334. loadPage: function(node){
  335. var pageNode = node || this.content.pageAreaNode;
  336. pageNode.empty();
  337. if (this.pages>1){
  338. this.pageNode = new Element("div.o2_homepage_task_page_area").inject(pageNode);
  339. this.prevPageNode = new Element("div.o2_homepage_task_page_prev", {"text": this.app.lp.prevPage}).inject(this.pageNode);
  340. this.itemsPageAreaNode = new Element("div.o2_homepage_task_page_items").inject(this.pageNode);
  341. this.nextPageNode = new Element("div.o2_homepage_task_page_next", {"text": this.app.lp.nextPage}).inject(this.pageNode);
  342. this.prevPageNode.addEvents({
  343. "mouseover": function () { this.addClass("o2_homepage_task_page_prev_over").addClass("mainColor_bg"); },
  344. "mouseout": function () { this.removeClass("o2_homepage_task_page_prev_over").removeClass("mainColor_bg"); },
  345. "click": function () { this.prevPage(); }.bind(this),
  346. });
  347. this.nextPageNode.addEvents({
  348. "mouseover": function () { this.addClass("o2_homepage_task_page_next_over").addClass("mainColor_bg"); },
  349. "mouseout": function () { this.removeClass("o2_homepage_task_page_next_over").removeClass("mainColor_bg"); },
  350. "click": function () { this.nextPage(); }.bind(this),
  351. });
  352. this.loadPageNumber();
  353. }else{
  354. }
  355. },
  356. getCurrentPageRange: function(){
  357. var beginNumber = 1;
  358. var endNumber = this.pages;
  359. var reverse = false;
  360. var forward = false;
  361. if (this.pages > this.options.showPages){
  362. beginNumber = this.page-((this.options.showPages/2).toInt());
  363. if (beginNumber<1) beginNumber = 1;
  364. endNumber = beginNumber+(this.options.showPages-1);
  365. if (endNumber>this.pages){
  366. endNumber = this.pages;
  367. beginNumber = endNumber-(this.options.showPages-1);
  368. if (beginNumber<1) beginNumber = 1;
  369. }
  370. if (beginNumber>1) reverse = true;
  371. if (endNumber<this.pages) forward = true;
  372. }
  373. return {"beginNumber": beginNumber, "endNumber": endNumber, "reverse": reverse, "forward": forward};
  374. },
  375. loadPageNumber: function(){
  376. var range = this.getCurrentPageRange();
  377. this.itemsPageAreaNode.empty();
  378. if (range.reverse){
  379. this.reverseNode = new Element("div.o2_homepage_task_page_reverse", {"text": "..."}).inject(this.itemsPageAreaNode);
  380. this.reverseNode.addEvents({
  381. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  382. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  383. "click": function () {
  384. this.reversePage();
  385. }.bind(this),
  386. });
  387. }
  388. for (var i=range.beginNumber; i<=range.endNumber; i++){
  389. var pageNode = new Element("div.o2_homepage_task_page_item", {"text": i}).inject(this.itemsPageAreaNode);
  390. if (this.page===i) pageNode.addClass("o2_homepage_task_page_item_current").addClass("mainColor_bg");
  391. pageNode.addEvents({
  392. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  393. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  394. "click": function (e) {
  395. this.gotoPage(e.target.get("text"));
  396. }.bind(this),
  397. });
  398. }
  399. if (range.forward){
  400. this.forwardNode = new Element("div.o2_homepage_task_page_forward", {"text": "..."}).inject(this.itemsPageAreaNode);
  401. this.forwardNode.addEvents({
  402. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  403. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  404. "click": function () {
  405. this.forwardPage();
  406. }.bind(this),
  407. });
  408. }
  409. },
  410. prevPage: function(){
  411. if (this.page>1){
  412. this.page--;
  413. //this.loadPageNumber();
  414. this.reload();
  415. }
  416. },
  417. nextPage: function(){
  418. if (this.page<this.pages){
  419. this.page++;
  420. //this.loadPageNumber();
  421. this.reload();
  422. }
  423. },
  424. gotoPage: function(i){
  425. this.page = i.toInt();
  426. //this.loadPageNumber();
  427. this.reload();
  428. },
  429. reversePage: function(){
  430. var range = this.getCurrentPageRange();
  431. var endNumber = range.beginNumber-1;
  432. var beginNumber = endNumber-(this.options.showPages-1);
  433. if (beginNumber<1) beginNumber = 1;
  434. this.page = beginNumber+((this.options.showPages/2).toInt());
  435. this.reload();
  436. },
  437. forwardPage: function(){
  438. var range = this.getCurrentPageRange();
  439. var beginNumber = range.endNumber+1;
  440. var endNumber = beginNumber+(this.options.showPages-1);
  441. if (beginNumber>this.pages) endNumber = this.pages;
  442. this.page = endNumber-((this.options.showPages/2).toInt());
  443. this.reload();
  444. }
  445. });
  446. MWF.xApplication.Homepage.TaskContent.TaskCompleted = new Class({
  447. Extends: MWF.xApplication.Homepage.TaskContent.Task,
  448. Implements: [Options, Events],
  449. options: {
  450. "type": "taskCompleted"
  451. },
  452. loadItemsRes: function(){
  453. o2.Actions.load("x_processplatform_assemble_surface").TaskCompletedAction.listMyPaging(this.page, this.pageSize, function(json){
  454. if (json.data && json.data.length){
  455. this.loadItems(json.data);
  456. this.checkLoadPage();
  457. }else{
  458. this.emptyLoadContent();
  459. }
  460. }.bind(this));
  461. },
  462. loadItemRow: function(table, d, i){
  463. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  464. var idx = (this.page-1)*this.pageSize+i+1;
  465. var idxShow = (idx>99) ? "···" : idx;
  466. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  467. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  468. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  469. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  470. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  471. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  472. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  473. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  474. routeName = d.routeName || this.app.lp.nextActivity;
  475. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  476. new Element("div.o2_homepage_task_item_activity", {"text": routeName, "title": this.app.lp.taskRoute + ": " + routeName}).inject(cell);
  477. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  478. new Element("div.o2_homepage_task_item_creator", {"text": o2.name.cn(d.creatorPerson), "title": this.app.lp.draftUser + ": " + o2.name.cn(d.creatorPerson)}).inject(cell);
  479. var time = d.completedTime.substr(0,10);
  480. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  481. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.taskCompletedTime + ": " + time}).inject(cell);
  482. return row;
  483. },
  484. addLoadPageEvent: function(){
  485. var loadPage = function(){
  486. this.getPageCount();
  487. this.loadPage();
  488. this.content.removeEvent("loadTaskCompletedCount", loadPage);
  489. }.bind(this);
  490. this.content.addEvent("loadTaskCompletedCount", loadPage);
  491. },
  492. getPageCount:function(){
  493. var n = this.content.itemCounts.taskCompleted/this.pageSize;
  494. var nInt = n.toInt();
  495. this.pages = (nInt===n) ? nInt : nInt+1;
  496. },
  497. open: function(e, d){
  498. // this._getJobByTask(function(data){
  499. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  500. var options = {
  501. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  502. "onAfterProcess": this.reloadTasks.bind(this),
  503. "onAfterReset": this.reloadTasks.bind(this),
  504. "onAfterRetract": this.reloadTasks.bind(this),
  505. "onAfterReroute": this.reloadTasks.bind(this),
  506. "onAfterDelete": this.reloadTasks.bind(this),
  507. "onAfterReaded": this.reloadReads.bind(this),
  508. };
  509. layout.openApplication(e, "process.Work", options);
  510. }
  511. });
  512. MWF.xApplication.Homepage.TaskContent.Read = new Class({
  513. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  514. Implements: [Options, Events],
  515. options: {
  516. "type": "read"
  517. },
  518. loadItemsRes: function(){
  519. o2.Actions.load("x_processplatform_assemble_surface").ReadAction.listMyPaging(this.page, this.pageSize, function(json){
  520. if (json.data && json.data.length){
  521. this.loadItems(json.data);
  522. this.checkLoadPage();
  523. }else{
  524. this.emptyLoadContent();
  525. }
  526. }.bind(this));
  527. },
  528. loadItemRow: function(table, d, i){
  529. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  530. var idx = (this.page-1)*this.pageSize+i+1;
  531. var idxShow = (idx>99) ? "···" : idx;
  532. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  533. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  534. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  535. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  536. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  537. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  538. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  539. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  540. // activity = d.activityName || this.app.lp.completedActivityName;
  541. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  542. // new Element("div.o2_homepage_task_item_activity", {"text": activity, "title": this.app.lp.readActivity + ": " + activity}).inject(cell);
  543. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  544. new Element("div.o2_homepage_task_item_creator", {"text": o2.name.cn(d.creatorPerson), "title": this.app.lp.draftUser + ": " + o2.name.cn(d.creatorPerson)}).inject(cell);
  545. var time = d.startTime.substr(0,10);
  546. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  547. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.readStartTime + ": " + time}).inject(cell);
  548. return row;
  549. },
  550. addLoadPageEvent: function(){
  551. var loadPage = function(){
  552. this.getPageCount();
  553. this.loadPage();
  554. this.content.removeEvent("loadReadCount", loadPage);
  555. }.bind(this);
  556. this.content.addEvent("loadReadCount", loadPage);
  557. },
  558. getPageCount:function(){
  559. var n = this.content.itemCounts.read/this.pageSize;
  560. var nInt = n.toInt();
  561. this.pages = (nInt===n) ? nInt : nInt+1;
  562. },
  563. open: function(e, d){
  564. // this._getJobByTask(function(data){
  565. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  566. var options = {
  567. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  568. "onAfterProcess": this.reloadTasks.bind(this),
  569. "onAfterReset": this.reloadTasks.bind(this),
  570. "onAfterRetract": this.reloadTasks.bind(this),
  571. "onAfterReroute": this.reloadTasks.bind(this),
  572. "onAfterDelete": this.reloadTasks.bind(this),
  573. "onAfterReaded": this.reloadReads.bind(this),
  574. };
  575. layout.openApplication(e, "process.Work", options);
  576. // }.bind(this));
  577. },
  578. });
  579. MWF.xApplication.Homepage.TaskContent.ReadCompleted = new Class({
  580. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  581. Implements: [Options, Events],
  582. options: {
  583. "type": "readCompleted"
  584. },
  585. loadItemsRes: function(){
  586. o2.Actions.load("x_processplatform_assemble_surface").ReadCompletedAction.listMyPaging(this.page, this.pageSize, function(json){
  587. if (json.data && json.data.length){
  588. this.loadItems(json.data);
  589. this.checkLoadPage();
  590. }else{
  591. this.emptyLoadContent();
  592. }
  593. }.bind(this));
  594. },
  595. loadItemRow: function(table, d, i){
  596. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  597. var idx = (this.page-1)*this.pageSize+i+1;
  598. var idxShow = (idx>99) ? "···" : idx;
  599. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  600. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  601. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  602. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  603. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  604. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  605. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  606. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  607. // activity = d.activityName || this.app.lp.completedActivityName;
  608. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  609. // new Element("div.o2_homepage_task_item_activity", {"text": activity, "title": this.app.lp.readActivity + ": " + activity}).inject(cell);
  610. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  611. new Element("div.o2_homepage_task_item_creator", {"text": o2.name.cn(d.creatorPerson), "title": this.app.lp.draftUser + ": " + o2.name.cn(d.creatorPerson)}).inject(cell);
  612. var time = d.completedTime.substr(0,10);
  613. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  614. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.readCompletedTime + ": " + time}).inject(cell);
  615. return row;
  616. },
  617. addLoadPageEvent: function(){
  618. var loadPage = function(){
  619. this.getPageCount();
  620. this.loadPage();
  621. this.content.removeEvent("loadReadCompletedCount", loadPage);
  622. }.bind(this);
  623. this.content.addEvent("loadReadCompletedCount", loadPage);
  624. },
  625. getPageCount:function(){
  626. var n = this.content.itemCounts.readCompleted/this.pageSize;
  627. var nInt = n.toInt();
  628. this.pages = (nInt===n) ? nInt : nInt+1;
  629. },
  630. open: function(e, d){
  631. // this._getJobByTask(function(data){
  632. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  633. var options = {
  634. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  635. "onAfterProcess": this.reloadTasks.bind(this),
  636. "onAfterReset": this.reloadTasks.bind(this),
  637. "onAfterRetract": this.reloadTasks.bind(this),
  638. "onAfterReroute": this.reloadTasks.bind(this),
  639. "onAfterDelete": this.reloadTasks.bind(this),
  640. "onAfterReaded": this.reloadReads.bind(this),
  641. };
  642. layout.openApplication(e, "process.Work", options);
  643. // }.bind(this));
  644. },
  645. });
  646. MWF.xApplication.Homepage.TaskContent.Draft = new Class({
  647. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  648. Implements: [Options, Events],
  649. options: {
  650. "type": "draft"
  651. },
  652. loadItemsRes: function(){
  653. o2.Actions.load("x_processplatform_assemble_surface").ReviewAction.V2ListCreatePaging(this.page, this.pageSize, {"relateTask": true}, function(json){
  654. if (json.data && json.data.length){
  655. this.loadItems(json.data);
  656. this.checkLoadPage();
  657. }else{
  658. this.emptyLoadContent();
  659. }
  660. }.bind(this));
  661. },
  662. loadItemRow: function(table, d, i){
  663. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  664. var idx = (this.page-1)*this.pageSize+i+1;
  665. var idxShow = (idx>99) ? "···" : idx;
  666. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  667. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  668. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  669. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  670. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  671. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  672. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  673. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  674. var activitys = [];
  675. var users = [];
  676. d.taskList.each(function(task){
  677. var userName = o2.name.cn(task.person);
  678. if (users.indexOf(userName)==-1) users.push(userName);
  679. if (activitys.indexOf(task.activityName)==-1) activitys.push(task.activityName);
  680. });
  681. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  682. new Element("div.o2_homepage_task_item_activity", {"text": activitys.join(","), "title": this.app.lp.currentActivity+": "+activitys.join(",")}).inject(cell);
  683. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  684. new Element("div.o2_homepage_task_item_creator", {"text": users.join(","), "title": this.app.lp.currentUser+": "+users.join(",")}).inject(cell);
  685. var time = d.createTime.substr(0,10);
  686. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  687. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.draftTime+": "+time}).inject(cell);
  688. return row;
  689. },
  690. addLoadPageEvent: function(){
  691. var loadPage = function(){
  692. this.getPageCount();
  693. this.loadPage();
  694. this.content.removeEvent("loadDraftCount", loadPage);
  695. }.bind(this);
  696. this.content.addEvent("loadDraftCount", loadPage);
  697. },
  698. getPageCount:function(){
  699. var n = this.content.itemCounts.draft/this.pageSize;
  700. var nInt = n.toInt();
  701. this.pages = (nInt===n) ? nInt : nInt+1;
  702. },
  703. open: function(e, d){
  704. // this._getJobByTask(function(data){
  705. var options = {
  706. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  707. "onAfterProcess": this.reloadTasks.bind(this),
  708. "onAfterReset": this.reloadTasks.bind(this),
  709. "onAfterRetract": this.reloadTasks.bind(this),
  710. "onAfterReroute": this.reloadTasks.bind(this),
  711. "onAfterDelete": this.reloadTasks.bind(this),
  712. "onAfterReaded": this.reloadReads.bind(this),
  713. };
  714. layout.openApplication(e, "process.Work", options);
  715. // }.bind(this));
  716. },
  717. });