TaskContent.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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. this.loadPageNumber();
  372. }else{
  373. }
  374. },
  375. getCurrentPageRange: function(){
  376. var beginNumber = 1;
  377. var endNumber = this.pages;
  378. var reverse = false;
  379. var forward = false;
  380. if (this.pages > this.options.showPages){
  381. beginNumber = this.page-((this.options.showPages/2).toInt());
  382. if (beginNumber<1) beginNumber = 1;
  383. endNumber = beginNumber+(this.options.showPages-1);
  384. if (endNumber>this.pages){
  385. endNumber = this.pages;
  386. beginNumber = endNumber-(this.options.showPages-1);
  387. if (beginNumber<1) beginNumber = 1;
  388. }
  389. if (beginNumber>1) reverse = true;
  390. if (endNumber<this.pages) forward = true;
  391. }
  392. return {"beginNumber": beginNumber, "endNumber": endNumber, "reverse": reverse, "forward": forward};
  393. },
  394. loadPageNumber: function(){
  395. var range = this.getCurrentPageRange();
  396. this.itemsPageAreaNode.empty();
  397. if (range.reverse){
  398. this.reverseNode = new Element("div.o2_homepage_task_page_reverse", {"text": "..."}).inject(this.itemsPageAreaNode);
  399. this.reverseNode.addEvents({
  400. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  401. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  402. "click": function () {
  403. this.reversePage();
  404. }.bind(this),
  405. });
  406. }
  407. for (var i=range.beginNumber; i<=range.endNumber; i++){
  408. var pageNode = new Element("div.o2_homepage_task_page_item", {"text": i}).inject(this.itemsPageAreaNode);
  409. if (this.page===i) pageNode.addClass("o2_homepage_task_page_item_current").addClass("mainColor_bg");
  410. pageNode.addEvents({
  411. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  412. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  413. "click": function (e) {
  414. this.gotoPage(e.target.get("text"));
  415. }.bind(this),
  416. });
  417. }
  418. if (range.forward){
  419. this.forwardNode = new Element("div.o2_homepage_task_page_forward", {"text": "..."}).inject(this.itemsPageAreaNode);
  420. this.forwardNode.addEvents({
  421. "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
  422. "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
  423. "click": function () {
  424. this.forwardPage();
  425. }.bind(this),
  426. });
  427. }
  428. },
  429. prevPage: function(){
  430. if (this.page>1){
  431. this.page--;
  432. //this.loadPageNumber();
  433. this.reload();
  434. }
  435. },
  436. nextPage: function(){
  437. if (this.page<this.pages){
  438. this.page++;
  439. //this.loadPageNumber();
  440. this.reload();
  441. }
  442. },
  443. gotoPage: function(i){
  444. this.page = i.toInt();
  445. //this.loadPageNumber();
  446. this.reload();
  447. },
  448. reversePage: function(){
  449. var range = this.getCurrentPageRange();
  450. var endNumber = range.beginNumber-1;
  451. var beginNumber = endNumber-(this.options.showPages-1);
  452. if (beginNumber<1) beginNumber = 1;
  453. this.page = beginNumber+((this.options.showPages/2).toInt());
  454. this.reload();
  455. },
  456. forwardPage: function(){
  457. var range = this.getCurrentPageRange();
  458. var beginNumber = range.endNumber+1;
  459. var endNumber = beginNumber+(this.options.showPages-1);
  460. if (beginNumber>this.pages) endNumber = this.pages;
  461. this.page = endNumber-((this.options.showPages/2).toInt());
  462. this.reload();
  463. }
  464. });
  465. MWF.xApplication.Homepage.TaskContent.TaskCompleted = new Class({
  466. Extends: MWF.xApplication.Homepage.TaskContent.Task,
  467. Implements: [Options, Events],
  468. options: {
  469. "type": "taskCompleted"
  470. },
  471. loadItemsRes: function(){
  472. o2.Actions.load("x_processplatform_assemble_surface").TaskCompletedAction.listMyPaging(this.page, this.pageSize, function(json){
  473. if (json.data && json.data.length){
  474. this.loadItems(json.data);
  475. this.checkLoadPage();
  476. }else{
  477. this.emptyLoadContent();
  478. }
  479. }.bind(this));
  480. },
  481. loadItemRow: function(table, d, i){
  482. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  483. var idx = (this.page-1)*this.pageSize+i+1;
  484. var idxShow = (idx>99) ? "···" : idx;
  485. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  486. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  487. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  488. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  489. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  490. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  491. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  492. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  493. routeName = d.routeName || this.app.lp.nextActivity;
  494. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  495. new Element("div.o2_homepage_task_item_activity", {"text": routeName, "title": this.app.lp.taskRoute + ": " + routeName}).inject(cell);
  496. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  497. 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);
  498. var time = d.completedTime.substr(0,10);
  499. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  500. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.taskCompletedTime + ": " + time}).inject(cell);
  501. return row;
  502. },
  503. addLoadPageEvent: function(){
  504. var loadPage = function(){
  505. this.getPageCount();
  506. this.loadPage();
  507. this.content.removeEvent("loadTaskCompletedCount", loadPage);
  508. }.bind(this);
  509. this.content.addEvent("loadTaskCompletedCount", loadPage);
  510. },
  511. getPageCount:function(){
  512. var n = this.content.itemCounts.taskCompleted/this.pageSize;
  513. var nInt = n.toInt();
  514. this.pages = (nInt===n) ? nInt : nInt+1;
  515. },
  516. open: function(e, d){
  517. // this._getJobByTask(function(data){
  518. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  519. var options = {
  520. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  521. "onAfterProcess": this.reloadTasks.bind(this),
  522. "onAfterReset": this.reloadTasks.bind(this),
  523. "onAfterRetract": this.reloadTasks.bind(this),
  524. "onAfterReroute": this.reloadTasks.bind(this),
  525. "onAfterDelete": this.reloadTasks.bind(this),
  526. "onAfterReaded": this.reloadReads.bind(this),
  527. };
  528. layout.openApplication(e, "process.Work", options);
  529. }
  530. });
  531. MWF.xApplication.Homepage.TaskContent.Read = new Class({
  532. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  533. Implements: [Options, Events],
  534. options: {
  535. "type": "read"
  536. },
  537. loadItemsRes: function(){
  538. o2.Actions.load("x_processplatform_assemble_surface").ReadAction.listMyPaging(this.page, this.pageSize, function(json){
  539. if (json.data && json.data.length){
  540. this.loadItems(json.data);
  541. this.checkLoadPage();
  542. }else{
  543. this.emptyLoadContent();
  544. }
  545. }.bind(this));
  546. },
  547. loadItemRow: function(table, d, i){
  548. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  549. var idx = (this.page-1)*this.pageSize+i+1;
  550. var idxShow = (idx>99) ? "···" : idx;
  551. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  552. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  553. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  554. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  555. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  556. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  557. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  558. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  559. // activity = d.activityName || this.app.lp.completedActivityName;
  560. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  561. // new Element("div.o2_homepage_task_item_activity", {"text": activity, "title": this.app.lp.readActivity + ": " + activity}).inject(cell);
  562. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  563. 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);
  564. var time = d.startTime.substr(0,10);
  565. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  566. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.readStartTime + ": " + time}).inject(cell);
  567. return row;
  568. },
  569. addLoadPageEvent: function(){
  570. var loadPage = function(){
  571. this.getPageCount();
  572. this.loadPage();
  573. this.content.removeEvent("loadReadCount", loadPage);
  574. }.bind(this);
  575. this.content.addEvent("loadReadCount", loadPage);
  576. },
  577. getPageCount:function(){
  578. var n = this.content.itemCounts.read/this.pageSize;
  579. var nInt = n.toInt();
  580. this.pages = (nInt===n) ? nInt : nInt+1;
  581. },
  582. open: function(e, d){
  583. // this._getJobByTask(function(data){
  584. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  585. var options = {
  586. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  587. "onAfterProcess": this.reloadTasks.bind(this),
  588. "onAfterReset": this.reloadTasks.bind(this),
  589. "onAfterRetract": this.reloadTasks.bind(this),
  590. "onAfterReroute": this.reloadTasks.bind(this),
  591. "onAfterDelete": this.reloadTasks.bind(this),
  592. "onAfterReaded": this.reloadReads.bind(this),
  593. };
  594. layout.openApplication(e, "process.Work", options);
  595. // }.bind(this));
  596. },
  597. });
  598. MWF.xApplication.Homepage.TaskContent.ReadCompleted = new Class({
  599. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  600. Implements: [Options, Events],
  601. options: {
  602. "type": "readCompleted"
  603. },
  604. loadItemsRes: function(){
  605. o2.Actions.load("x_processplatform_assemble_surface").ReadCompletedAction.listMyPaging(this.page, this.pageSize, function(json){
  606. if (json.data && json.data.length){
  607. this.loadItems(json.data);
  608. this.checkLoadPage();
  609. }else{
  610. this.emptyLoadContent();
  611. }
  612. }.bind(this));
  613. },
  614. loadItemRow: function(table, d, i){
  615. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  616. var idx = (this.page-1)*this.pageSize+i+1;
  617. var idxShow = (idx>99) ? "···" : idx;
  618. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  619. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  620. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  621. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  622. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  623. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  624. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  625. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  626. // activity = d.activityName || this.app.lp.completedActivityName;
  627. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  628. // new Element("div.o2_homepage_task_item_activity", {"text": activity, "title": this.app.lp.readActivity + ": " + activity}).inject(cell);
  629. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  630. 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);
  631. var time = d.completedTime.substr(0,10);
  632. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  633. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.readCompletedTime + ": " + time}).inject(cell);
  634. return row;
  635. },
  636. addLoadPageEvent: function(){
  637. var loadPage = function(){
  638. this.getPageCount();
  639. this.loadPage();
  640. this.content.removeEvent("loadReadCompletedCount", loadPage);
  641. }.bind(this);
  642. this.content.addEvent("loadReadCompletedCount", loadPage);
  643. },
  644. getPageCount:function(){
  645. var n = this.content.itemCounts.readCompleted/this.pageSize;
  646. var nInt = n.toInt();
  647. this.pages = (nInt===n) ? nInt : nInt+1;
  648. },
  649. open: function(e, d){
  650. // this._getJobByTask(function(data){
  651. //var options = {"workId": d.work, "appId": "process.Work"+d.work};
  652. var options = {
  653. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  654. "onAfterProcess": this.reloadTasks.bind(this),
  655. "onAfterReset": this.reloadTasks.bind(this),
  656. "onAfterRetract": this.reloadTasks.bind(this),
  657. "onAfterReroute": this.reloadTasks.bind(this),
  658. "onAfterDelete": this.reloadTasks.bind(this),
  659. "onAfterReaded": this.reloadReads.bind(this),
  660. };
  661. layout.openApplication(e, "process.Work", options);
  662. // }.bind(this));
  663. },
  664. });
  665. MWF.xApplication.Homepage.TaskContent.Draft = new Class({
  666. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  667. Implements: [Options, Events],
  668. options: {
  669. "type": "draft"
  670. },
  671. loadItemsRes: function(){
  672. o2.Actions.load("x_processplatform_assemble_surface").ReviewAction.V2ListCreatePaging(this.page, this.pageSize, {"relateTask": true}, function(json){
  673. if (json.data && json.data.length){
  674. this.loadItems(json.data);
  675. this.checkLoadPage();
  676. }else{
  677. this.emptyLoadContent();
  678. }
  679. }.bind(this));
  680. },
  681. loadItemRow: function(table, d, i){
  682. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  683. var idx = (this.page-1)*this.pageSize+i+1;
  684. var idxShow = (idx>99) ? "···" : idx;
  685. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  686. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  687. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  688. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  689. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  690. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  691. // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  692. // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
  693. var activitys = [];
  694. var users = [];
  695. d.taskList.each(function(task){
  696. var userName = o2.name.cn(task.person);
  697. if (users.indexOf(userName)==-1) users.push(userName);
  698. if (activitys.indexOf(task.activityName)==-1) activitys.push(task.activityName);
  699. });
  700. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  701. new Element("div.o2_homepage_task_item_activity", {"text": activitys.join(","), "title": this.app.lp.currentActivity+": "+activitys.join(",")}).inject(cell);
  702. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  703. new Element("div.o2_homepage_task_item_creator", {"text": users.join(","), "title": this.app.lp.currentUser+": "+users.join(",")}).inject(cell);
  704. var time = d.createTime.substr(0,10);
  705. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  706. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.draftTime+": "+time}).inject(cell);
  707. return row;
  708. },
  709. addLoadPageEvent: function(){
  710. var loadPage = function(){
  711. this.getPageCount();
  712. this.loadPage();
  713. this.content.removeEvent("loadDraftCount", loadPage);
  714. }.bind(this);
  715. this.content.addEvent("loadDraftCount", loadPage);
  716. },
  717. getPageCount:function(){
  718. var n = this.content.itemCounts.draft/this.pageSize;
  719. var nInt = n.toInt();
  720. this.pages = (nInt===n) ? nInt : nInt+1;
  721. },
  722. open: function(e, d){
  723. // this._getJobByTask(function(data){
  724. var options = {
  725. "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
  726. "onAfterProcess": this.reloadTasks.bind(this),
  727. "onAfterReset": this.reloadTasks.bind(this),
  728. "onAfterRetract": this.reloadTasks.bind(this),
  729. "onAfterReroute": this.reloadTasks.bind(this),
  730. "onAfterDelete": this.reloadTasks.bind(this),
  731. "onAfterReaded": this.reloadReads.bind(this),
  732. };
  733. layout.openApplication(e, "process.Work", options);
  734. // }.bind(this));
  735. },
  736. });
  737. MWF.xApplication.Homepage.TaskContent.ProcessDraft = new Class({
  738. Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
  739. Implements: [Options, Events],
  740. options: {
  741. "type": "processDraft"
  742. },
  743. loadItemsRes: function(){
  744. o2.Actions.load("x_processplatform_assemble_surface").DraftAction.listMyPaging(this.page, this.pageSize, {}, function(json){
  745. if (json.data && json.data.length){
  746. this.loadItems(json.data);
  747. this.checkLoadPage();
  748. }else{
  749. this.emptyLoadContent();
  750. }
  751. }.bind(this));
  752. },
  753. loadItemRow: function(table, d, i){
  754. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  755. var idx = (this.page-1)*this.pageSize+i+1;
  756. var idxShow = (idx>99) ? "···" : idx;
  757. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  758. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  759. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  760. var subject = "["+d.processName+"] "+(d.title || this.app.lp.noSubject);
  761. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  762. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  763. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
  764. new Element("div.o2_homepage_task_item_activity", {"text": this.app.lp.myProcessDraft, "title": this.app.lp.currentActivity+": "+this.app.lp.myProcessDraft}).inject(cell);
  765. var user = o2.name.cn(layout.session.user.name)
  766. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  767. new Element("div.o2_homepage_task_item_creator", {"text": user, "title": this.app.lp.currentUser+": "+user}).inject(cell);
  768. var time = d.createTime.substr(0,10);
  769. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  770. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.draftTime+": "+time}).inject(cell);
  771. return row;
  772. },
  773. addLoadPageEvent: function(){
  774. var loadPage = function(){
  775. this.getPageCount();
  776. this.loadPage();
  777. this.content.removeEvent("loadProcessDraftCount", loadPage);
  778. }.bind(this);
  779. this.content.addEvent("loadProcessDraftCount", loadPage);
  780. },
  781. getPageCount:function(){
  782. var n = this.content.itemCounts.processDraft/this.pageSize;
  783. var nInt = n.toInt();
  784. this.pages = (nInt===n) ? nInt : nInt+1;
  785. },
  786. open: function(e, d){
  787. // this._getJobByTask(function(data){
  788. var options = {
  789. "draftId": d.id, "appId": "process.Work"+ d.id,
  790. "onAfterProcess": this.reloadTasks.bind(this),
  791. "onAfterReset": this.reloadTasks.bind(this),
  792. "onAfterRetract": this.reloadTasks.bind(this),
  793. "onAfterReroute": this.reloadTasks.bind(this),
  794. "onAfterDelete": this.reloadTasks.bind(this),
  795. "onAfterReaded": this.reloadReads.bind(this),
  796. };
  797. layout.openApplication(e, "process.Work", options);
  798. // }.bind(this));
  799. },
  800. });