TaskContent.js 34 KB

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