TaskContent.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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. o2.Actions.load("x_processplatform_assemble_surface").DraftAction.listNext("(0)", 1, function(json){
  96. debugger;
  97. if (!this.itemCounts) this.itemCounts = {};
  98. this.itemCounts.processDraft = json.count;
  99. this.showTabCount(this.processDraftTab, json.count);
  100. this.fireEvent("loadProcessDraftCount");
  101. }.bind(this));
  102. },
  103. showTabCount: function(node, count){
  104. var text = node.get("text");
  105. node.set("text", text+"("+count+")");
  106. },
  107. tabover: function(e){
  108. e.currentTarget.addClass("o2_homepage_title_tab_over");
  109. },
  110. tabout: function(e){
  111. e.currentTarget.removeClass("o2_homepage_title_tab_over");
  112. //e.currentTarget.removeClass("mainColor_border").removeClass("mainColor_color");
  113. },
  114. loadTask: function(callback){
  115. if (!this.isLoading){
  116. if (!this.taskContentTab){
  117. this.taskContentTab = new MWF.xApplication.Homepage.TaskContent.Task(this, this.taskTab, {
  118. "onLoad": function(){ if (callback) callback(); }
  119. });
  120. }else{
  121. this.taskContentTab.reload();
  122. }
  123. this.currentTab = this.taskContentTab;
  124. }
  125. },
  126. loadTaskCompleted: function(){
  127. if (!this.isLoading){
  128. if (!this.taskCompletedContentTab){
  129. this.taskCompletedContentTab = new MWF.xApplication.Homepage.TaskContent.TaskCompleted(this, this.taskCompletedTab);
  130. }else{
  131. this.taskCompletedContentTab.reload();
  132. }
  133. this.currentTab = this.taskCompletedContentTab;
  134. }
  135. },
  136. loadRead: function(){
  137. if (!this.isLoading){
  138. if (!this.readContentTab){
  139. this.readContentTab = new MWF.xApplication.Homepage.TaskContent.Read(this, this.readTab);
  140. }else{
  141. this.readContentTab.reload();
  142. }
  143. this.currentTab = this.readContentTab;
  144. }
  145. },
  146. loadReadCompleted: function(){
  147. if (!this.isLoading){
  148. if (!this.readCompletedContentTab){
  149. this.readCompletedContentTab = new MWF.xApplication.Homepage.TaskContent.ReadCompleted(this, this.readCompletedTab);
  150. }else{
  151. this.readCompletedContentTab.reload();
  152. }
  153. this.currentTab = this.readCompletedContentTab;
  154. }
  155. },
  156. loadDraft: function(){
  157. if (!this.isLoading){
  158. if (!this.draftContentTab){
  159. this.draftContentTab = new MWF.xApplication.Homepage.TaskContent.Draft(this, this.draftTab);
  160. }else{
  161. this.draftContentTab.reload();
  162. }
  163. this.currentTab = this.draftContentTab;
  164. }
  165. },
  166. loadProcessDraft: function(){
  167. if (!this.isLoading){
  168. if (!this.processDraftContentTab){
  169. this.processDraftContentTab = new MWF.xApplication.Homepage.TaskContent.ProcessDraft(this, this.processDraftTab);
  170. }else{
  171. this.processDraftContentTab.reload();
  172. }
  173. this.currentTab = this.processDraftContentTab;
  174. }
  175. }
  176. });
  177. MWF.xApplication.Homepage.TaskContent.Task = new Class({
  178. Implements: [Options, Events],
  179. options: {
  180. "itemHeight": 40,
  181. "showPages": 5,
  182. "type": "task"
  183. },
  184. initialize: function(content, tab, options){
  185. this.setOptions(options);
  186. this.content = content;
  187. this.app = this.content.app;
  188. this.container = this.content.itemContentNode;
  189. this.tab = tab;
  190. this.load();
  191. },
  192. load: function(){
  193. this.beginLoadContent();
  194. this.showTab();
  195. this.initItemCount();
  196. this.loadItemsRes();
  197. },
  198. loadItemsRes: function(){
  199. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.listMyPaging(this.page, this.pageSize, function(json){
  200. if (json.data && json.data.length){
  201. this.loadItems(json.data);
  202. this.checkLoadPage();
  203. }else{
  204. this.emptyLoadContent();
  205. }
  206. this.fireEvent("load");
  207. }.bind(this));
  208. },
  209. reload: function(){
  210. if (!this.content.isLoading) {
  211. this.beginLoadContent();
  212. this.showTab();
  213. this.initItemCount(this.page);
  214. this.loadItemsRes();
  215. }
  216. },
  217. initItemCount: function(count){
  218. this.page = count || 1;
  219. this.pageSize = (this.container.getSize().y/this.options.itemHeight).toInt();
  220. },
  221. beginLoadContent: function(){
  222. if (this.content.currentTab) this.content.currentTab.hideTab();
  223. this.container.empty();
  224. this.content.noItemNode = null;
  225. this.container.addClass("o2_homepage_area_content_loading").addClass("icon_loading");
  226. this.content.isLoading = true;
  227. },
  228. endLoadContent: function(){
  229. if (this.content.noItemNode){
  230. this.content.noItemNode.destroy();
  231. this.content.noItemNode = null;
  232. }
  233. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  234. this.content.isLoading = false;
  235. },
  236. emptyLoadContent: function(){
  237. this.container.empty();
  238. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  239. this.content.pageAreaNode.empty();
  240. //this.itemContentNode.addClass("o2_homepage_task_area_content_empty").addClass("icon_notask");
  241. this.content.noItemNode = new Element("div.o2_homepage_task_area_content_empty_node", {"text": this.app.lp.noWork}).inject(this.container);
  242. var m = (this.content.contentHeight- this.content.noItemNode.getSize().y)/2;
  243. this.content.noItemNode.setStyle("margin-top", ""+m+"px");
  244. this.content.isLoading = false;
  245. },
  246. hideTab: function(){
  247. this.container.empty();
  248. this.content.currentTab = null;
  249. this.tab.removeClass("mainColor_color").removeClass("mainColor_border").removeClass("o2_homepage_title_tab_current").removeClass("o2_homepage_title_tab_over");
  250. // if (this.destroy) this.destroy();
  251. // o2.release(this);
  252. },
  253. showTab: function(){
  254. this.content.currentTab = this;
  255. this.tab.addClass("mainColor_color").addClass("mainColor_border").addClass("o2_homepage_title_tab_current").removeClass("o2_homepage_title_tab_over");
  256. },
  257. loadItems: function(data){
  258. var table = new Element("table", { "width": "100%", "border": 0, "cellpadding": 0, "cellspacing": 0 }).inject(this.container);
  259. data.each(function(d, i){
  260. this.loadItem(table, d, i);
  261. }.bind(this));
  262. this.endLoadContent();
  263. },
  264. loadItemRow: function(table, d, i){
  265. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  266. var idx = (this.page-1)*this.pageSize+i+1;
  267. var idxShow = (idx>99) ? "···" : idx;
  268. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  269. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  270. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  271. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  272. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  273. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  274. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  275. new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title": this.app.lp.currentActivity + ": " + d.activityName}).inject(cell);
  276. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  277. 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);
  278. var time = d.startTime.substr(0,10);
  279. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  280. new Element("div.o2_homepage_task_item_time", {"text": time, "title":this.app.lp.taskStartTime + ": " + time}).inject(cell);
  281. return row;
  282. },
  283. loadItem: function(table, d, i){
  284. var row = this.loadItemRow(table, d, i)
  285. var _self = this;
  286. row.store("data", d);
  287. row.addEvents({
  288. "mouseover": function(){
  289. this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
  290. this.getElement("div").addClass("mainColor_bg").addClass("o2_homepage_task_item_number_over");
  291. },
  292. "mouseout": function(){
  293. this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
  294. this.getElement("div").removeClass("mainColor_bg").removeClass("o2_homepage_task_item_number_over");
  295. },
  296. "click": function(e){
  297. var d = this.retrieve("data");
  298. if (d) {
  299. _self.open(e, d);
  300. }
  301. }
  302. })
  303. },
  304. reloadTasks: function(){
  305. var type = this.content.currentTab.options.type;
  306. if (type=="task" || type=="taskCompleted"){
  307. this.content.currentTab.reload();
  308. }
  309. },
  310. reloadReads: function(){
  311. var type = this.content.currentTab.options.type;
  312. if (type=="read" || type=="readCompleted"){
  313. this.content.currentTab.reload();
  314. }
  315. },
  316. open: function(e, d){
  317. // this._getJobByTask(function(data){
  318. var options = {
  319. "workId": d.work, "appId": "process.Work"+d.work,
  320. "onAfterProcess": this.reloadTasks.bind(this),
  321. "onAfterReset": this.reloadTasks.bind(this),
  322. "onAfterRetract": this.reloadTasks.bind(this),
  323. "onAfterReroute": this.reloadTasks.bind(this),
  324. "onAfterDelete": this.reloadTasks.bind(this),
  325. "onAfterReaded": this.reloadReads.bind(this),
  326. };
  327. layout.openApplication(e, "process.Work", options);
  328. // }.bind(this));
  329. },
  330. checkLoadPage: function(){
  331. if (this.content.itemCounts && this.content.itemCounts.task){
  332. this.getPageCount();
  333. this.loadPage();
  334. }else{
  335. this.addLoadPageEvent();
  336. }
  337. },
  338. addLoadPageEvent: function(){
  339. var loadPage = function(){
  340. this.getPageCount();
  341. this.loadPage();
  342. this.content.removeEvent("loadTaskCount", loadPage);
  343. }.bind(this);
  344. this.content.addEvent("loadTaskCount", loadPage);
  345. },
  346. getPageCount:function(){
  347. var n = this.content.itemCounts.task/this.pageSize;
  348. var nInt = n.toInt();
  349. this.pages = (nInt===n) ? nInt : nInt+1;
  350. },
  351. loadPage: function(node){
  352. var pageNode = node || this.content.pageAreaNode;
  353. pageNode.empty();
  354. if (this.pages>1){
  355. this.pageNode = new Element("div.o2_homepage_task_page_area").inject(pageNode);
  356. this.prevPageNode = new Element("div.o2_homepage_task_page_prev", {"text": this.app.lp.prevPage}).inject(this.pageNode);
  357. this.itemsPageAreaNode = new Element("div.o2_homepage_task_page_items").inject(this.pageNode);
  358. this.nextPageNode = new Element("div.o2_homepage_task_page_next", {"text": this.app.lp.nextPage}).inject(this.pageNode);
  359. this.prevPageNode.addEvents({
  360. "mouseover": function () { this.addClass("o2_homepage_task_page_prev_over").addClass("mainColor_bg"); },
  361. "mouseout": function () { this.removeClass("o2_homepage_task_page_prev_over").removeClass("mainColor_bg"); },
  362. "click": function () { this.prevPage(); }.bind(this),
  363. });
  364. this.nextPageNode.addEvents({
  365. "mouseover": function () { this.addClass("o2_homepage_task_page_next_over").addClass("mainColor_bg"); },
  366. "mouseout": function () { this.removeClass("o2_homepage_task_page_next_over").removeClass("mainColor_bg"); },
  367. "click": function () { this.nextPage(); }.bind(this),
  368. });
  369. this.loadPageNumber();
  370. }else{
  371. }
  372. },
  373. getCurrentPageRange: function(){
  374. var beginNumber = 1;
  375. var endNumber = this.pages;
  376. var reverse = false;
  377. var forward = false;
  378. if (this.pages > this.options.showPages){
  379. beginNumber = this.page-((this.options.showPages/2).toInt());
  380. if (beginNumber<1) beginNumber = 1;
  381. endNumber = beginNumber+(this.options.showPages-1);
  382. if (endNumber>this.pages){
  383. endNumber = this.pages;
  384. beginNumber = endNumber-(this.options.showPages-1);
  385. if (beginNumber<1) beginNumber = 1;
  386. }
  387. if (beginNumber>1) reverse = true;
  388. if (endNumber<this.pages) forward = true;
  389. }
  390. return {"beginNumber": beginNumber, "endNumber": endNumber, "reverse": reverse, "forward": forward};
  391. },
  392. loadPageNumber: function(){
  393. var range = this.getCurrentPageRange();
  394. this.itemsPageAreaNode.empty();
  395. if (range.reverse){
  396. this.reverseNode = new Element("div.o2_homepage_task_page_reverse", {"text": "..."}).inject(this.itemsPageAreaNode);
  397. this.reverseNode.addEvents({
  398. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  399. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  400. "click": function () {
  401. this.reversePage();
  402. }.bind(this),
  403. });
  404. }
  405. for (var i=range.beginNumber; i<=range.endNumber; i++){
  406. var pageNode = new Element("div.o2_homepage_task_page_item", {"text": i}).inject(this.itemsPageAreaNode);
  407. if (this.page===i) pageNode.addClass("o2_homepage_task_page_item_current").addClass("mainColor_bg");
  408. pageNode.addEvents({
  409. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  410. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  411. "click": function (e) {
  412. this.gotoPage(e.target.get("text"));
  413. }.bind(this),
  414. });
  415. }
  416. if (range.forward){
  417. this.forwardNode = new Element("div.o2_homepage_task_page_forward", {"text": "..."}).inject(this.itemsPageAreaNode);
  418. this.forwardNode.addEvents({
  419. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  420. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  421. "click": function () {
  422. this.forwardPage();
  423. }.bind(this),
  424. });
  425. }
  426. },
  427. prevPage: function(){
  428. if (this.page>1){
  429. this.page--;
  430. //this.loadPageNumber();
  431. this.reload();
  432. }
  433. },
  434. nextPage: function(){
  435. if (this.page<this.pages){
  436. this.page++;
  437. //this.loadPageNumber();
  438. this.reload();
  439. }
  440. },
  441. gotoPage: function(i){
  442. this.page = i.toInt();
  443. //this.loadPageNumber();
  444. this.reload();
  445. },
  446. reversePage: function(){
  447. var range = this.getCurrentPageRange();
  448. var endNumber = range.beginNumber-1;
  449. var beginNumber = endNumber-(this.options.showPages-1);
  450. if (beginNumber<1) beginNumber = 1;
  451. this.page = beginNumber+((this.options.showPages/2).toInt());
  452. this.reload();
  453. },
  454. forwardPage: function(){
  455. var range = this.getCurrentPageRange();
  456. var beginNumber = range.endNumber+1;
  457. var endNumber = beginNumber+(this.options.showPages-1);
  458. if (beginNumber>this.pages) endNumber = this.pages;
  459. this.page = endNumber-((this.options.showPages/2).toInt());
  460. this.reload();
  461. }
  462. });
  463. MWF.xApplication.Homepage.TaskContent.TaskCompleted = new Class({
  464. Extends: MWF.xApplication.Homepage.TaskContent.Task,
  465. Implements: [Options, Events],
  466. options: {
  467. "type": "taskCompleted"
  468. },
  469. loadItemsRes: function(){
  470. o2.Actions.load("x_processplatform_assemble_surface").TaskCompletedAction.listMyPaging(this.page, this.pageSize, function(json){
  471. if (json.data && json.data.length){
  472. this.loadItems(json.data);
  473. this.checkLoadPage();
  474. }else{
  475. this.emptyLoadContent();
  476. }
  477. }.bind(this));
  478. },
  479. loadItemRow: function(table, d, i){
  480. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  481. var idx = (this.page-1)*this.pageSize+i+1;
  482. var idxShow = (idx>99) ? "···" : idx;
  483. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  484. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  485. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  486. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  487. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  488. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  489. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  490. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  491. routeName = d.routeName || this.app.lp.nextActivity;
  492. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  493. new Element("div.o2_homepage_task_item_activity", {"text": routeName, "title": this.app.lp.taskRoute + ": " + routeName}).inject(cell);
  494. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  495. 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);
  496. var time = d.completedTime.substr(0,10);
  497. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  498. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.taskCompletedTime + ": " + time}).inject(cell);
  499. return row;
  500. },
  501. addLoadPageEvent: function(){
  502. var loadPage = function(){
  503. this.getPageCount();
  504. this.loadPage();
  505. this.content.removeEvent("loadTaskCompletedCount", loadPage);
  506. }.bind(this);
  507. this.content.addEvent("loadTaskCompletedCount", loadPage);
  508. },
  509. getPageCount:function(){
  510. var n = this.content.itemCounts.taskCompleted/this.pageSize;
  511. var nInt = n.toInt();
  512. this.pages = (nInt===n) ? nInt : nInt+1;
  513. },
  514. open: function(e, d){
  515. // this._getJobByTask(function(data){
  516. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  517. var options = {
  518. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  519. "onAfterProcess": this.reloadTasks.bind(this),
  520. "onAfterReset": this.reloadTasks.bind(this),
  521. "onAfterRetract": this.reloadTasks.bind(this),
  522. "onAfterReroute": this.reloadTasks.bind(this),
  523. "onAfterDelete": this.reloadTasks.bind(this),
  524. "onAfterReaded": this.reloadReads.bind(this),
  525. };
  526. layout.openApplication(e, "process.Work", options);
  527. }
  528. });
  529. MWF.xApplication.Homepage.TaskContent.Read = new Class({
  530. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  531. Implements: [Options, Events],
  532. options: {
  533. "type": "read"
  534. },
  535. loadItemsRes: function(){
  536. o2.Actions.load("x_processplatform_assemble_surface").ReadAction.listMyPaging(this.page, this.pageSize, function(json){
  537. if (json.data && json.data.length){
  538. this.loadItems(json.data);
  539. this.checkLoadPage();
  540. }else{
  541. this.emptyLoadContent();
  542. }
  543. }.bind(this));
  544. },
  545. loadItemRow: function(table, d, i){
  546. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  547. var idx = (this.page-1)*this.pageSize+i+1;
  548. var idxShow = (idx>99) ? "···" : idx;
  549. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  550. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  551. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  552. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  553. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  554. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  555. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  556. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  557. // activity = d.activityName || this.app.lp.completedActivityName;
  558. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  559. // new Element("div.o2_homepage_task_item_activity", {"text": activity, "title": this.app.lp.readActivity + ": " + activity}).inject(cell);
  560. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  561. 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);
  562. var time = d.startTime.substr(0,10);
  563. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  564. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.readStartTime + ": " + time}).inject(cell);
  565. return row;
  566. },
  567. addLoadPageEvent: function(){
  568. var loadPage = function(){
  569. this.getPageCount();
  570. this.loadPage();
  571. this.content.removeEvent("loadReadCount", loadPage);
  572. }.bind(this);
  573. this.content.addEvent("loadReadCount", loadPage);
  574. },
  575. getPageCount:function(){
  576. var n = this.content.itemCounts.read/this.pageSize;
  577. var nInt = n.toInt();
  578. this.pages = (nInt===n) ? nInt : nInt+1;
  579. },
  580. open: function(e, d){
  581. // this._getJobByTask(function(data){
  582. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  583. var options = {
  584. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  585. "onAfterProcess": this.reloadTasks.bind(this),
  586. "onAfterReset": this.reloadTasks.bind(this),
  587. "onAfterRetract": this.reloadTasks.bind(this),
  588. "onAfterReroute": this.reloadTasks.bind(this),
  589. "onAfterDelete": this.reloadTasks.bind(this),
  590. "onAfterReaded": this.reloadReads.bind(this),
  591. };
  592. layout.openApplication(e, "process.Work", options);
  593. // }.bind(this));
  594. },
  595. });
  596. MWF.xApplication.Homepage.TaskContent.ReadCompleted = new Class({
  597. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  598. Implements: [Options, Events],
  599. options: {
  600. "type": "readCompleted"
  601. },
  602. loadItemsRes: function(){
  603. o2.Actions.load("x_processplatform_assemble_surface").ReadCompletedAction.listMyPaging(this.page, this.pageSize, function(json){
  604. if (json.data && json.data.length){
  605. this.loadItems(json.data);
  606. this.checkLoadPage();
  607. }else{
  608. this.emptyLoadContent();
  609. }
  610. }.bind(this));
  611. },
  612. loadItemRow: function(table, d, i){
  613. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  614. var idx = (this.page-1)*this.pageSize+i+1;
  615. var idxShow = (idx>99) ? "···" : idx;
  616. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  617. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  618. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  619. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  620. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  621. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  622. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  623. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  624. // activity = d.activityName || this.app.lp.completedActivityName;
  625. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  626. // new Element("div.o2_homepage_task_item_activity", {"text": activity, "title": this.app.lp.readActivity + ": " + activity}).inject(cell);
  627. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  628. 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);
  629. var time = d.completedTime.substr(0,10);
  630. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  631. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.readCompletedTime + ": " + time}).inject(cell);
  632. return row;
  633. },
  634. addLoadPageEvent: function(){
  635. var loadPage = function(){
  636. this.getPageCount();
  637. this.loadPage();
  638. this.content.removeEvent("loadReadCompletedCount", loadPage);
  639. }.bind(this);
  640. this.content.addEvent("loadReadCompletedCount", loadPage);
  641. },
  642. getPageCount:function(){
  643. var n = this.content.itemCounts.readCompleted/this.pageSize;
  644. var nInt = n.toInt();
  645. this.pages = (nInt===n) ? nInt : nInt+1;
  646. },
  647. open: function(e, d){
  648. // this._getJobByTask(function(data){
  649. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  650. var options = {
  651. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  652. "onAfterProcess": this.reloadTasks.bind(this),
  653. "onAfterReset": this.reloadTasks.bind(this),
  654. "onAfterRetract": this.reloadTasks.bind(this),
  655. "onAfterReroute": this.reloadTasks.bind(this),
  656. "onAfterDelete": this.reloadTasks.bind(this),
  657. "onAfterReaded": this.reloadReads.bind(this),
  658. };
  659. layout.openApplication(e, "process.Work", options);
  660. // }.bind(this));
  661. },
  662. });
  663. MWF.xApplication.Homepage.TaskContent.Draft = new Class({
  664. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  665. Implements: [Options, Events],
  666. options: {
  667. "type": "draft"
  668. },
  669. loadItemsRes: function(){
  670. o2.Actions.load("x_processplatform_assemble_surface").ReviewAction.V2ListCreatePaging(this.page, this.pageSize, {"relateTask": true}, function(json){
  671. if (json.data && json.data.length){
  672. this.loadItems(json.data);
  673. this.checkLoadPage();
  674. }else{
  675. this.emptyLoadContent();
  676. }
  677. }.bind(this));
  678. },
  679. loadItemRow: function(table, d, i){
  680. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  681. var idx = (this.page-1)*this.pageSize+i+1;
  682. var idxShow = (idx>99) ? "···" : idx;
  683. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  684. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  685. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  686. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  687. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  688. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  689. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  690. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  691. var activitys = [];
  692. var users = [];
  693. d.taskList.each(function(task){
  694. var userName = o2.name.cn(task.person);
  695. if (users.indexOf(userName)==-1) users.push(userName);
  696. if (activitys.indexOf(task.activityName)==-1) activitys.push(task.activityName);
  697. });
  698. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  699. new Element("div.o2_homepage_task_item_activity", {"text": activitys.join(","), "title": this.app.lp.currentActivity+": "+activitys.join(",")}).inject(cell);
  700. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  701. new Element("div.o2_homepage_task_item_creator", {"text": users.join(","), "title": this.app.lp.currentUser+": "+users.join(",")}).inject(cell);
  702. var time = d.createTime.substr(0,10);
  703. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  704. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.draftTime+": "+time}).inject(cell);
  705. return row;
  706. },
  707. addLoadPageEvent: function(){
  708. var loadPage = function(){
  709. this.getPageCount();
  710. this.loadPage();
  711. this.content.removeEvent("loadDraftCount", loadPage);
  712. }.bind(this);
  713. this.content.addEvent("loadDraftCount", loadPage);
  714. },
  715. getPageCount:function(){
  716. var n = this.content.itemCounts.draft/this.pageSize;
  717. var nInt = n.toInt();
  718. this.pages = (nInt===n) ? nInt : nInt+1;
  719. },
  720. open: function(e, d){
  721. // this._getJobByTask(function(data){
  722. var options = {
  723. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  724. "onAfterProcess": this.reloadTasks.bind(this),
  725. "onAfterReset": this.reloadTasks.bind(this),
  726. "onAfterRetract": this.reloadTasks.bind(this),
  727. "onAfterReroute": this.reloadTasks.bind(this),
  728. "onAfterDelete": this.reloadTasks.bind(this),
  729. "onAfterReaded": this.reloadReads.bind(this),
  730. };
  731. layout.openApplication(e, "process.Work", options);
  732. // }.bind(this));
  733. },
  734. });
  735. MWF.xApplication.Homepage.TaskContent.ProcessDraft = new Class({
  736. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  737. Implements: [Options, Events],
  738. options: {
  739. "type": "processDraft"
  740. },
  741. loadItemsRes: function(){
  742. o2.Actions.load("x_processplatform_assemble_surface").DraftAction.listMyPaging(this.page, this.pageSize, {}, function(json){
  743. if (json.data && json.data.length){
  744. this.loadItems(json.data);
  745. this.checkLoadPage();
  746. }else{
  747. this.emptyLoadContent();
  748. }
  749. }.bind(this));
  750. },
  751. loadItemRow: function(table, d, i){
  752. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  753. var idx = (this.page-1)*this.pageSize+i+1;
  754. var idxShow = (idx>99) ? "···" : idx;
  755. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  756. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  757. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  758. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  759. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  760. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  761. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  762. new Element("div.o2_homepage_task_item_activity", {"text": this.app.lp.myProcessDraft, "title": this.app.lp.currentActivity+": "+this.app.lp.myProcessDraft}).inject(cell);
  763. var user = o2.name.cn(layout.session.user.name)
  764. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  765. new Element("div.o2_homepage_task_item_creator", {"text": user, "title": this.app.lp.currentUser+": "+user}).inject(cell);
  766. var time = d.createTime.substr(0,10);
  767. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  768. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.draftTime+": "+time}).inject(cell);
  769. return row;
  770. },
  771. addLoadPageEvent: function(){
  772. var loadPage = function(){
  773. this.getPageCount();
  774. this.loadPage();
  775. this.content.removeEvent("loadProcessDraftCount", loadPage);
  776. }.bind(this);
  777. this.content.addEvent("loadProcessDraftCount", loadPage);
  778. },
  779. getPageCount:function(){
  780. var n = this.content.itemCounts.processDraft/this.pageSize;
  781. var nInt = n.toInt();
  782. this.pages = (nInt===n) ? nInt : nInt+1;
  783. },
  784. open: function(e, d){
  785. // this._getJobByTask(function(data){
  786. var options = {
  787. "draftId": d.id, "appId": "process.Work"+ d.id,
  788. "onAfterProcess": this.reloadTasks.bind(this),
  789. "onAfterReset": this.reloadTasks.bind(this),
  790. "onAfterRetract": this.reloadTasks.bind(this),
  791. "onAfterReroute": this.reloadTasks.bind(this),
  792. "onAfterDelete": this.reloadTasks.bind(this),
  793. "onAfterReaded": this.reloadReads.bind(this),
  794. };
  795. layout.openApplication(e, "process.Work", options);
  796. // }.bind(this));
  797. },
  798. });