TaskContent.js 40 KB

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