TaskContent.js 43 KB

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