TaskContent.js 40 KB

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