123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995 |
- MWF.xApplication.Homepage.TaskContent = new Class({
- Implements: [Options, Events],
- options: {
- "view": "taskContent.html"
- },
- initialize: function(app, container, options){
- this.setOptions(options);
- this.app = app;
- this.container = container;
- this.viewPath = this.app.path+this.app.options.style+"/"+this.options.view;
- this.load();
- },
- load: function(){
- this.container.loadHtml(this.viewPath, {"bind": {"lp": this.app.lp}, "module": this}, function(){
- this.initSize();
- this.loadCount();
- this.loadTask(function(){
- this.fireEvent("load");
- }.bind(this));
- //是否需要定时自动刷新 @todo
- //this.startProcessAction.addEvent("click", this.startProcess.bind(this));
- }.bind(this));
- },
- startProcess: function(){
- // o2.requireApp("process.TaskCenter", "lp."+o2.language, null, false);
- // o2.requireApp("process.TaskCenter", "", null, false);
- o2.requireApp([["process.TaskCenter", "lp."+o2.language], ["process.TaskCenter", ""]],"", function(){
- var obj = {
- "lp": MWF.xApplication.process.TaskCenter.LP,
- "content": this.app.content,
- "addEvent": function(type, fun){
- this.app.addEvent(type, fun);
- }.bind(this),
- "getAction": function (callback) {
- if (!this.action) {
- this.action = MWF.Actions.get("x_processplatform_assemble_surface");
- if (callback) callback();
- } else {
- if (callback) callback();
- }
- },
- "desktop": layout.desktop,
- "refreshAll": function(){},
- "notice": this.app.notice,
- }
- o2.JSON.get("../x_component_process_TaskCenter/$Main/default/css.wcss", function(data){
- obj.css = data;
- }, false);
- if (!this.processStarter) this.processStarter = new MWF.xApplication.process.TaskCenter.Starter(obj, {
- "onStartProcess": function(){
- if (this.currentTab.options.type == "task" || this.currentTab.options.type == "draft") {
- this.currentTab.reload();
- }
- this.loadTaskCount();
- this.loadDraftCount();
- }.bind(this)
- });
- this.processStarter.load();
- }.bind(this), true, true);
- },
- initSize: function(){
- this.setContentSize();
- this.app.addEvent("resize", this.setContentSize.bind(this));
- },
- setContentSize: function(){
- var total = this.container.getSize().y;
- var titleHeight = this.taskTitleNode.getSize().y+this.taskTitleNode.getEdgeHeight();
- var bottomHeight = this.pageAreaNode.getSize().y+this.pageAreaNode.getEdgeHeight();
- var thisHeight = this.itemContentNode.getEdgeHeight();
- var contentHeight = total-titleHeight-bottomHeight-thisHeight;
- this.itemContentNode.setStyle("height", ""+contentHeight+"px");
- this.contentHeight = contentHeight;
- //this.pageSize = (this.options.itemHeight/this.contentHeight).toInt();
- if (this.noItemNode){
- var m = (this.contentHeight- this.noItemNode.getSize().y)/2;
- this.noItemNode.setStyle("margin-top", ""+m+"px");
- }
- },
- loadCount: function(){
- o2.Actions.load("x_processplatform_assemble_surface").WorkAction.countWithPerson(layout.session.user.id, function(json){
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.task = json.data.task;
- this.itemCounts.taskCompleted = json.data.taskCompleted;
- this.itemCounts.read = json.data.read;
- this.itemCounts.readCompleted = json.data.readCompleted;
- this.showTabCount(this.taskTab, json.data.task);
- this.showTabCount(this.taskCompletedTab, json.data.taskCompleted);
- this.showTabCount(this.readTab, json.data.read);
- this.showTabCount(this.readCompletedTab, json.data.readCompleted);
- this.fireEvent("loadTaskCount");
- this.fireEvent("loadReadCount");
- this.fireEvent("loadTaskCompletedCount");
- this.fireEvent("loadReadCompletedCount");
- }.bind(this));
- o2.Actions.load("x_processplatform_assemble_surface").ReviewAction.V2Count({"creatorPersonList": [layout.session.user.id]}, function(json){
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.draft = json.data.count;
- this.showTabCount(this.draftTab, json.data.count);
- this.fireEvent("loadDraftCount");
- }.bind(this));
- o2.Actions.load("x_processplatform_assemble_surface").DraftAction.listNext("(0)", 1, function(json){
- debugger;
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.processDraft = json.count;
- this.showTabCount(this.processDraftTab, json.count);
- this.fireEvent("loadProcessDraftCount");
- }.bind(this));
- },
- loadTaskCount: function(){
- o2.Actions.load("x_processplatform_assemble_surface").TaskAction.countWithPerson(layout.session.user.id, function(json){
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.task = json.data.count || 0;
- this.showTabCount(this.taskTab, json.data.count || 0);
- this.fireEvent("loadTaskCount");
- }.bind(this));
- },
- loadTaskCompletedCount: function(){
- o2.Actions.load("x_processplatform_assemble_surface").TaskCompletedAction.countWithPerson(layout.session.user.id, function(json){
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.taskCompleted = json.data.count || 0;
- this.showTabCount(this.taskCompletedTab, json.data.count || 0);
- this.fireEvent("loadTaskCompletedCount");
- }.bind(this));
- },
- loadReadCount: function(){
- o2.Actions.load("x_processplatform_assemble_surface").ReadAction.countWithPerson(layout.session.user.id, function(json){
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.read = json.data.count || 0;
- this.showTabCount(this.readTab, json.data.count || 0);
- this.fireEvent("loadReadCount");
- }.bind(this));
- },
- loadReadCompletedCount: function(){
- o2.Actions.load("x_processplatform_assemble_surface").ReadCompletedAction.countWithPerson(layout.session.user.id, function(json){
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.readCompleted = json.data.count || 0;
- this.showTabCount(this.readCompletedTab, json.data.count || 0);
- this.fireEvent("loadReadCompletedCount");
- }.bind(this));
- },
- loadDraftCount: function(){
- o2.Actions.load("x_processplatform_assemble_surface").ReviewAction.V2Count({"creatorPersonList": [layout.session.user.id]}, function(json){
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.draft = json.data.count || 0;
- this.showTabCount(this.draftTab, json.data.count || 0);
- this.fireEvent("loadDraftCount");
- }.bind(this));
- },
- loadProcessDraftCount: function(){
- o2.Actions.load("x_processplatform_assemble_surface").DraftAction.listNext("(0)", 1, function(json){
- if (!this.itemCounts) this.itemCounts = {};
- this.itemCounts.processDraft = json.count || 0;
- this.showTabCount(this.processDraftTab, json.count || 0);
- this.fireEvent("loadProcessDraftCount");
- }.bind(this));
- },
- showTabCount: function(node, count){
- var text = node.get("text");
- if( text.indexOf( "(" ) > -1 ){
- node.set("text", text.split("(")[0] +"("+count+")");
- }else{
- node.set("text", text+"("+count+")");
- }
- },
- tabover: function(e){
- e.currentTarget.addClass("o2_homepage_title_tab_over");
- },
- tabout: function(e){
- e.currentTarget.removeClass("o2_homepage_title_tab_over");
- //e.currentTarget.removeClass("mainColor_border").removeClass("mainColor_color");
- },
- loadTask: function(callback){
- if (!this.isLoading){
- if (!this.taskContentTab){
- this.taskContentTab = new MWF.xApplication.Homepage.TaskContent.Task(this, this.taskTab, {
- "onLoad": function(){ if (callback) callback(); }
- });
- }else{
- this.taskContentTab.reload();
- }
- this.loadTaskCount();
- this.currentTab = this.taskContentTab;
- }
- },
- loadTaskCompleted: function(){
- if (!this.isLoading){
- if (!this.taskCompletedContentTab){
- this.taskCompletedContentTab = new MWF.xApplication.Homepage.TaskContent.TaskCompleted(this, this.taskCompletedTab);
- }else{
- this.taskCompletedContentTab.reload();
- }
- this.loadTaskCompletedCount();
- this.currentTab = this.taskCompletedContentTab;
- }
- },
- loadRead: function(){
- if (!this.isLoading){
- if (!this.readContentTab){
- this.readContentTab = new MWF.xApplication.Homepage.TaskContent.Read(this, this.readTab);
- }else{
- this.readContentTab.reload();
- }
- this.loadReadCount();
- this.currentTab = this.readContentTab;
- }
- },
- loadReadCompleted: function(){
- if (!this.isLoading){
- if (!this.readCompletedContentTab){
- this.readCompletedContentTab = new MWF.xApplication.Homepage.TaskContent.ReadCompleted(this, this.readCompletedTab);
- }else{
- this.readCompletedContentTab.reload();
- }
- this.loadReadCompletedCount();
- this.currentTab = this.readCompletedContentTab;
- }
- },
- loadDraft: function(){
- if (!this.isLoading){
- if (!this.draftContentTab){
- this.draftContentTab = new MWF.xApplication.Homepage.TaskContent.Draft(this, this.draftTab);
- }else{
- this.draftContentTab.reload();
- }
- this.loadDraftCount();
- this.currentTab = this.draftContentTab;
- }
- },
- loadProcessDraft: function(){
- if (!this.isLoading){
- if (!this.processDraftContentTab){
- this.processDraftContentTab = new MWF.xApplication.Homepage.TaskContent.ProcessDraft(this, this.processDraftTab);
- }else{
- this.processDraftContentTab.reload();
- this.loadProcessDraftCount();
- }
- this.currentTab = this.processDraftContentTab;
- }
- }
- });
- MWF.xApplication.Homepage.TaskContent.Task = new Class({
- Implements: [Options, Events],
- options: {
- "itemHeight": 40,
- "showPages": 5,
- "type": "task"
- },
- initialize: function(content, tab, options){
- this.setOptions(options);
- this.content = content;
- this.app = this.content.app;
- this.container = this.content.itemContentNode;
- this.tab = tab;
- this.load();
- },
- load: function(){
- this.beginLoadContent();
- this.showTab();
- this.initItemCount();
- this.loadItemsRes();
- },
- loadItemsRes: function(){
- o2.Actions.load("x_processplatform_assemble_surface").TaskAction.listMyPaging(this.page, this.pageSize, function(json){
- if (json.data && json.data.length){
- this.loadItems(json.data);
- this.checkLoadPage();
- }else{
- this.emptyLoadContent();
- }
- this.fireEvent("load");
- }.bind(this));
- },
- reload: function(){
- if (!this.content.isLoading) {
- this.beginLoadContent();
- this.showTab();
- this.initItemCount(this.page);
- this.loadItemsRes();
- }
- },
- initItemCount: function(count){
- this.page = count || 1;
- this.pageSize = (this.container.getSize().y/this.options.itemHeight).toInt();
- },
- beginLoadContent: function(){
- if (this.content.currentTab) this.content.currentTab.hideTab();
- this.container.empty();
- this.content.noItemNode = null;
- this.container.addClass("o2_homepage_area_content_loading").addClass("icon_loading");
- this.content.isLoading = true;
- },
- endLoadContent: function(){
- if (this.content.noItemNode){
- this.content.noItemNode.destroy();
- this.content.noItemNode = null;
- }
- this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
- this.content.isLoading = false;
- },
- emptyLoadContent: function(){
- this.container.empty();
- this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
- this.content.pageAreaNode.empty();
- //this.itemContentNode.addClass("o2_homepage_task_area_content_empty").addClass("icon_notask");
- this.content.noItemNode = new Element("div.o2_homepage_task_area_content_empty_node", {"text": this.app.lp.noWork}).inject(this.container);
- var m = (this.content.contentHeight- this.content.noItemNode.getSize().y)/2;
- this.content.noItemNode.setStyle("margin-top", ""+m+"px");
- this.content.isLoading = false;
- },
- hideTab: function(){
- this.container.empty();
- this.content.currentTab = null;
- this.tab.removeClass("mainColor_color").removeClass("mainColor_border").removeClass("o2_homepage_title_tab_current").removeClass("o2_homepage_title_tab_over");
- // if (this.destroy) this.destroy();
- // o2.release(this);
- },
- showTab: function(){
- this.content.currentTab = this;
- this.tab.addClass("mainColor_color").addClass("mainColor_border").addClass("o2_homepage_title_tab_current").removeClass("o2_homepage_title_tab_over");
- },
- loadItems: function(data){
- var table = new Element("table", { "width": "100%", "border": 0, "cellpadding": 0, "cellspacing": 0 }).inject(this.container);
- data.each(function(d, i){
- this.loadItem(table, d, i);
- }.bind(this));
- this.endLoadContent();
- },
- loadItemRow: function(table, d, i){
- var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
- var idx = (this.page-1)*this.pageSize+i+1;
- var idxShow = (idx>99) ? "···" : idx;
- var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
- var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
- //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
- var unit = o2.name.cn(d.unit);
- var subject = "["+d.processName+"] "+o2.txt(d.title || this.app.lp.noSubject);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
- new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":"("+unit+") "+subject}).inject(cell);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title": this.app.lp.currentActivity + ": " + d.activityName}).inject(cell);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
- 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);
- var time = d.startTime.substr(0,10);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
- new Element("div.o2_homepage_task_item_time", {"text": time, "title":this.app.lp.taskStartTime + ": " + time}).inject(cell);
- return row;
- },
- loadItem: function(table, d, i){
- var row = this.loadItemRow(table, d, i)
- var _self = this;
- row.store("data", d);
- row.addEvents({
- "mouseover": function(){
- this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
- this.getElement("div").addClass("mainColor_bg").addClass("o2_homepage_task_item_number_over");
- },
- "mouseout": function(){
- this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
- this.getElement("div").removeClass("mainColor_bg").removeClass("o2_homepage_task_item_number_over");
- },
- "click": function(e){
- var d = this.retrieve("data");
- if (d) {
- _self.open(e, d);
- }
- }
- })
- },
- reloadTasks: function(){
- var type = this.content.currentTab.options.type;
- if (type=="task" || type=="taskCompleted"){
- this.content.currentTab.reload();
- }
- this.content.loadTaskCount();
- this.content.loadTaskCompletedCount();
- },
- reloadReads: function(){
- var type = this.content.currentTab.options.type;
- if (type=="read" || type=="readCompleted"){
- this.content.currentTab.reload();
- }
- this.content.loadReadCount();
- this.content.loadReadCompletedCount();
- },
- open: function(e, d){
- // this._getJobByTask(function(data){
- var options = {
- "taskId": d.id,
- "workId": d.work, "appId": "process.Work"+d.work,
- "onAfterProcess": this.reloadTasks.bind(this),
- "onAfterReset": this.reloadTasks.bind(this),
- "onAfterRetract": this.reloadTasks.bind(this),
- "onAfterReroute": this.reloadTasks.bind(this),
- "onAfterDelete": this.reloadTasks.bind(this),
- "onAfterReaded": this.reloadReads.bind(this),
- };
- layout.openApplication(e, "process.Work", options);
- // }.bind(this));
- },
- checkLoadPage: function(){
- if (this.content.itemCounts && this.content.itemCounts.task){
- this.getPageCount();
- this.loadPage();
- }else{
- this.addLoadPageEvent();
- }
- },
- addLoadPageEvent: function(){
- var loadPage = function(){
- this.getPageCount();
- this.loadPage();
- this.content.removeEvent("loadTaskCount", loadPage);
- }.bind(this);
- this.content.addEvent("loadTaskCount", loadPage);
- },
- getPageCount:function(){
- var n = this.content.itemCounts.task/this.pageSize;
- var nInt = n.toInt();
- this.pages = (nInt===n) ? nInt : nInt+1;
- },
- loadPage: function(node){
- var pageNode = node || this.content.pageAreaNode;
- pageNode.empty();
- if (this.pages>1){
- this.pageNode = new Element("div.o2_homepage_task_page_area").inject(pageNode);
- this.prevPageNode = new Element("div.o2_homepage_task_page_prev", {"text": this.app.lp.prevPage}).inject(this.pageNode);
- this.itemsPageAreaNode = new Element("div.o2_homepage_task_page_items").inject(this.pageNode);
- this.nextPageNode = new Element("div.o2_homepage_task_page_next", {"text": this.app.lp.nextPage}).inject(this.pageNode);
- this.prevPageNode.addEvents({
- "mouseover": function () { this.addClass("o2_homepage_task_page_prev_over").addClass("mainColor_bg"); },
- "mouseout": function () { this.removeClass("o2_homepage_task_page_prev_over").removeClass("mainColor_bg"); },
- "click": function () { this.prevPage(); }.bind(this),
- });
- this.nextPageNode.addEvents({
- "mouseover": function () { this.addClass("o2_homepage_task_page_next_over").addClass("mainColor_bg"); },
- "mouseout": function () { this.removeClass("o2_homepage_task_page_next_over").removeClass("mainColor_bg"); },
- "click": function () { this.nextPage(); }.bind(this),
- });
- var size = this.pageNode.getSize();
- var w1 = this.prevPageNode.getEdgeWidth();
- var w2 = this.nextPageNode.getEdgeWidth();
- var x1 = this.prevPageNode.getSize().x;
- var x2 = this.nextPageNode.getSize().x;
- var x = size.x - w1 - w2 - x1 - x2;
- var count = (x/30).toInt()-2;
- if (count<3) count = 3;
- this.options.showPages = count;
- this.loadPageNumber();
- }else{
- }
- },
- getCurrentPageRange: function(){
- var beginNumber = 1;
- var endNumber = this.pages;
- var reverse = false;
- var forward = false;
- if (this.pages > this.options.showPages){
- beginNumber = this.page-((this.options.showPages/2).toInt());
- if (beginNumber<1) beginNumber = 1;
- endNumber = beginNumber+(this.options.showPages-1);
- if (endNumber>this.pages){
- endNumber = this.pages;
- beginNumber = endNumber-(this.options.showPages-1);
- if (beginNumber<1) beginNumber = 1;
- }
- if (beginNumber>1) reverse = true;
- if (endNumber<this.pages) forward = true;
- }
- return {"beginNumber": beginNumber, "endNumber": endNumber, "reverse": reverse, "forward": forward};
- },
- loadPageNumber: function(){
- var range = this.getCurrentPageRange();
- this.itemsPageAreaNode.empty();
- if (range.reverse){
- this.reverseNode = new Element("div.o2_homepage_task_page_reverse", {"text": "..."}).inject(this.itemsPageAreaNode);
- this.reverseNode.addEvents({
- "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
- "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
- "click": function () {
- this.reversePage();
- }.bind(this),
- });
- }
- for (var i=range.beginNumber; i<=range.endNumber; i++){
- var pageNode = new Element("div.o2_homepage_task_page_item", {"text": i}).inject(this.itemsPageAreaNode);
- if (this.page===i) pageNode.addClass("o2_homepage_task_page_item_current").addClass("mainColor_bg");
- pageNode.addEvents({
- "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
- "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
- "click": function (e) {
- this.gotoPage(e.target.get("text"));
- }.bind(this),
- });
- }
- if (range.forward){
- this.forwardNode = new Element("div.o2_homepage_task_page_forward", {"text": "..."}).inject(this.itemsPageAreaNode);
- this.forwardNode.addEvents({
- "mouseover": function () { this.addClass("o2_homepage_task_page_item_over"); },
- "mouseout": function () { this.removeClass("o2_homepage_task_page_item_over"); },
- "click": function () {
- this.forwardPage();
- }.bind(this),
- });
- }
- },
- prevPage: function(){
- if (this.page>1){
- this.page--;
- //this.loadPageNumber();
- this.reload();
- }
- },
- nextPage: function(){
- if (this.page<this.pages){
- this.page++;
- //this.loadPageNumber();
- this.reload();
- }
- },
- gotoPage: function(i){
- this.page = i.toInt();
- //this.loadPageNumber();
- this.reload();
- },
- reversePage: function(){
- var range = this.getCurrentPageRange();
- var endNumber = range.beginNumber-1;
- var beginNumber = endNumber-(this.options.showPages-1);
- if (beginNumber<1) beginNumber = 1;
- this.page = beginNumber+((this.options.showPages/2).toInt());
- this.reload();
- },
- forwardPage: function(){
- var range = this.getCurrentPageRange();
- var beginNumber = range.endNumber+1;
- var endNumber = beginNumber+(this.options.showPages-1);
- if (beginNumber>=this.pages) endNumber = this.pages;
- this.page = endNumber-((this.options.showPages/2).toInt());
- this.reload();
- }
- });
- MWF.xApplication.Homepage.TaskContent.TaskCompleted = new Class({
- Extends: MWF.xApplication.Homepage.TaskContent.Task,
- Implements: [Options, Events],
- options: {
- "type": "taskCompleted"
- },
- loadItemsRes: function(){
- o2.Actions.load("x_processplatform_assemble_surface").TaskCompletedAction.listMyPaging(this.page, this.pageSize, function(json){
- if (json.data && json.data.length){
- this.loadItems(json.data);
- this.checkLoadPage();
- }else{
- this.emptyLoadContent();
- }
- }.bind(this));
- },
- loadItemRow: function(table, d, i){
- var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
- var idx = (this.page-1)*this.pageSize+i+1;
- var idxShow = (idx>99) ? "···" : idx;
- var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
- var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
- //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
- var subject = "["+d.processName+"] "+o2.txt(d.title || this.app.lp.noSubject);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
- new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
- // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
- routeName = d.routeName || this.app.lp.nextActivity;
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- new Element("div.o2_homepage_task_item_activity", {"text": routeName, "title": this.app.lp.taskRoute + ": " + routeName}).inject(cell);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
- 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);
- var time = d.completedTime.substr(0,10);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
- new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.taskCompletedTime + ": " + time}).inject(cell);
- return row;
- },
- checkLoadPage: function(){
- if (this.content.itemCounts && this.content.itemCounts.taskCompleted){
- this.getPageCount();
- this.loadPage();
- }else{
- this.addLoadPageEvent();
- }
- },
- addLoadPageEvent: function(){
- var loadPage = function(){
- this.getPageCount();
- this.loadPage();
- this.content.removeEvent("loadTaskCompletedCount", loadPage);
- }.bind(this);
- this.content.addEvent("loadTaskCompletedCount", loadPage);
- },
- getPageCount:function(){
- var n = this.content.itemCounts.taskCompleted/this.pageSize;
- var nInt = n.toInt();
- this.pages = (nInt===n) ? nInt : nInt+1;
- },
- open: function(e, d){
- // this._getJobByTask(function(data){
- //var options = {"workId": d.work, "appId": "process.Work"+d.work};
- var options = {
- "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
- "onAfterProcess": this.reloadTasks.bind(this),
- "onAfterReset": this.reloadTasks.bind(this),
- "onAfterRetract": this.reloadTasks.bind(this),
- "onAfterReroute": this.reloadTasks.bind(this),
- "onAfterDelete": this.reloadTasks.bind(this),
- "onAfterReaded": this.reloadReads.bind(this),
- };
- layout.openApplication(e, "process.Work", options);
- }
- });
- MWF.xApplication.Homepage.TaskContent.Read = new Class({
- Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
- Implements: [Options, Events],
- options: {
- "type": "read"
- },
- loadItemsRes: function(){
- o2.Actions.load("x_processplatform_assemble_surface").ReadAction.listMyPaging(this.page, this.pageSize, function(json){
- if (json.data && json.data.length){
- this.loadItems(json.data);
- this.checkLoadPage();
- }else{
- this.emptyLoadContent();
- }
- }.bind(this));
- },
- loadItemRow: function(table, d, i){
- var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
- var idx = (this.page-1)*this.pageSize+i+1;
- var idxShow = (idx>99) ? "···" : idx;
- var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
- var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
- //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
- var subject = "["+d.processName+"] "+o2.txt(d.title || this.app.lp.noSubject);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
- new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
- // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
- // activity = d.activityName || this.app.lp.completedActivityName;
- // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- // new Element("div.o2_homepage_task_item_activity", {"text": activity, "title": this.app.lp.readActivity + ": " + activity}).inject(cell);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
- 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);
- var time = d.startTime.substr(0,10);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
- new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.readStartTime + ": " + time}).inject(cell);
- return row;
- },
- checkLoadPage: function(){
- if (this.content.itemCounts && this.content.itemCounts.read){
- this.getPageCount();
- this.loadPage();
- }else{
- this.addLoadPageEvent();
- }
- },
- addLoadPageEvent: function(){
- var loadPage = function(){
- this.getPageCount();
- this.loadPage();
- this.content.removeEvent("loadReadCount", loadPage);
- }.bind(this);
- this.content.addEvent("loadReadCount", loadPage);
- },
- getPageCount:function(){
- var n = this.content.itemCounts.read/this.pageSize;
- var nInt = n.toInt();
- this.pages = (nInt===n) ? nInt : nInt+1;
- },
- open: function(e, d){
- // this._getJobByTask(function(data){
- //var options = {"workId": d.work, "appId": "process.Work"+d.work};
- var options = {
- "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
- "onAfterProcess": this.reloadTasks.bind(this),
- "onAfterReset": this.reloadTasks.bind(this),
- "onAfterRetract": this.reloadTasks.bind(this),
- "onAfterReroute": this.reloadTasks.bind(this),
- "onAfterDelete": this.reloadTasks.bind(this),
- "onAfterReaded": this.reloadReads.bind(this),
- };
- layout.openApplication(e, "process.Work", options);
- // }.bind(this));
- },
- });
- MWF.xApplication.Homepage.TaskContent.ReadCompleted = new Class({
- Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
- Implements: [Options, Events],
- options: {
- "type": "readCompleted"
- },
- loadItemsRes: function(){
- o2.Actions.load("x_processplatform_assemble_surface").ReadCompletedAction.listMyPaging(this.page, this.pageSize, function(json){
- if (json.data && json.data.length){
- this.loadItems(json.data);
- this.checkLoadPage();
- }else{
- this.emptyLoadContent();
- }
- }.bind(this));
- },
- loadItemRow: function(table, d, i){
- var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
- var idx = (this.page-1)*this.pageSize+i+1;
- var idxShow = (idx>99) ? "···" : idx;
- var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
- var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
- //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
- var subject = "["+d.processName+"] "+o2.txt(d.title || this.app.lp.noSubject);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
- new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
- // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
- // activity = d.activityName || this.app.lp.completedActivityName;
- // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- // new Element("div.o2_homepage_task_item_activity", {"text": activity, "title": this.app.lp.readActivity + ": " + activity}).inject(cell);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
- 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);
- var time = d.completedTime.substr(0,10);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
- new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.readCompletedTime + ": " + time}).inject(cell);
- return row;
- },
- checkLoadPage: function(){
- if (this.content.itemCounts && this.content.itemCounts.readCompleted){
- this.getPageCount();
- this.loadPage();
- }else{
- this.addLoadPageEvent();
- }
- },
- addLoadPageEvent: function(){
- var loadPage = function(){
- this.getPageCount();
- this.loadPage();
- this.content.removeEvent("loadReadCompletedCount", loadPage);
- }.bind(this);
- this.content.addEvent("loadReadCompletedCount", loadPage);
- },
- getPageCount:function(){
- var n = this.content.itemCounts.readCompleted/this.pageSize;
- var nInt = n.toInt();
- this.pages = (nInt===n) ? nInt : nInt+1;
- },
- open: function(e, d){
- // this._getJobByTask(function(data){
- //var options = {"workId": d.work, "appId": "process.Work"+d.work};
- var options = {
- "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
- "onAfterProcess": this.reloadTasks.bind(this),
- "onAfterReset": this.reloadTasks.bind(this),
- "onAfterRetract": this.reloadTasks.bind(this),
- "onAfterReroute": this.reloadTasks.bind(this),
- "onAfterDelete": this.reloadTasks.bind(this),
- "onAfterReaded": this.reloadReads.bind(this),
- };
- layout.openApplication(e, "process.Work", options);
- // }.bind(this));
- },
- });
- MWF.xApplication.Homepage.TaskContent.Draft = new Class({
- Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
- Implements: [Options, Events],
- options: {
- "type": "draft"
- },
- loadItemsRes: function(){
- o2.Actions.load("x_processplatform_assemble_surface").ReviewAction.V2ListCreatePaging(this.page, this.pageSize, {"relateTask": true}, function(json){
- if (json.data && json.data.length){
- this.loadItems(json.data);
- this.checkLoadPage();
- }else{
- this.emptyLoadContent();
- }
- }.bind(this));
- },
- loadItemRow: function(table, d, i){
- var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
- var idx = (this.page-1)*this.pageSize+i+1;
- var idxShow = (idx>99) ? "···" : idx;
- var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
- var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
- //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
- var subject = "["+d.processName+"] "+o2.txt(d.title || this.app.lp.noSubject);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
- new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
- // cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- // new Element("div.o2_homepage_task_item_activity", {"text": d.activityName, "title":d.activityName}).inject(cell);
- var activitys = [];
- var users = [];
- d.taskList.each(function(task){
- var userName = o2.name.cn(task.person);
- if (users.indexOf(userName)==-1) users.push(userName);
- if (activitys.indexOf(task.activityName)==-1) activitys.push(task.activityName);
- });
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- new Element("div.o2_homepage_task_item_activity", {"text": activitys.join(","), "title": this.app.lp.currentActivity+": "+activitys.join(",")}).inject(cell);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
- new Element("div.o2_homepage_task_item_creator", {"text": users.join(","), "title": this.app.lp.currentUser+": "+users.join(",")}).inject(cell);
- var time = d.createTime.substr(0,10);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
- new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.draftTime+": "+time}).inject(cell);
- return row;
- },
- checkLoadPage: function(){
- if (this.content.itemCounts && this.content.itemCounts.draft){
- this.getPageCount();
- this.loadPage();
- }else{
- this.addLoadPageEvent();
- }
- },
- addLoadPageEvent: function(){
- var loadPage = function(){
- this.getPageCount();
- this.loadPage();
- this.content.removeEvent("loadDraftCount", loadPage);
- }.bind(this);
- this.content.addEvent("loadDraftCount", loadPage);
- },
- getPageCount:function(){
- var n = this.content.itemCounts.draft/this.pageSize;
- var nInt = n.toInt();
- this.pages = (nInt===n) ? nInt : nInt+1;
- },
- open: function(e, d){
- // this._getJobByTask(function(data){
- var options = {
- "jobId": d.job, "appId": "process.Work"+d.job, "priorityWork": d.work,
- "onAfterProcess": this.reloadTasks.bind(this),
- "onAfterReset": this.reloadTasks.bind(this),
- "onAfterRetract": this.reloadTasks.bind(this),
- "onAfterReroute": this.reloadTasks.bind(this),
- "onAfterDelete": this.reloadTasks.bind(this),
- "onAfterReaded": this.reloadReads.bind(this),
- };
- layout.openApplication(e, "process.Work", options);
- // }.bind(this));
- },
- });
- MWF.xApplication.Homepage.TaskContent.ProcessDraft = new Class({
- Extends: MWF.xApplication.Homepage.TaskContent.TaskCompleted,
- Implements: [Options, Events],
- options: {
- "type": "processDraft"
- },
- loadItemsRes: function(){
- o2.Actions.load("x_processplatform_assemble_surface").DraftAction.listMyPaging(this.page, this.pageSize, {}, function(json){
- if (json.data && json.data.length){
- this.loadItems(json.data);
- this.checkLoadPage();
- }else{
- this.emptyLoadContent();
- }
- }.bind(this));
- },
- loadItemRow: function(table, d, i){
- var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
- var idx = (this.page-1)*this.pageSize+i+1;
- var idxShow = (idx>99) ? "···" : idx;
- var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
- var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
- //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
- var subject = "["+d.processName+"] "+o2.txt(d.title || this.app.lp.noSubject);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
- new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_activity");
- new Element("div.o2_homepage_task_item_activity", {"text": this.app.lp.myProcessDraft, "title": this.app.lp.currentActivity+": "+this.app.lp.myProcessDraft}).inject(cell);
- var user = o2.name.cn(layout.session.user.name)
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
- new Element("div.o2_homepage_task_item_creator", {"text": user, "title": this.app.lp.currentUser+": "+user}).inject(cell);
- var time = d.createTime.substr(0,10);
- cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
- new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.draftTime+": "+time}).inject(cell);
- return row;
- },
- checkLoadPage: function(){
- if (this.content.itemCounts && this.content.itemCounts.processDraft){
- this.getPageCount();
- this.loadPage();
- }else{
- this.addLoadPageEvent();
- }
- },
- addLoadPageEvent: function(){
- var loadPage = function(){
- this.getPageCount();
- this.loadPage();
- this.content.removeEvent("loadProcessDraftCount", loadPage);
- }.bind(this);
- this.content.addEvent("loadProcessDraftCount", loadPage);
- },
- getPageCount:function(){
- var n = this.content.itemCounts.processDraft/this.pageSize;
- var nInt = n.toInt();
- this.pages = (nInt===n) ? nInt : nInt+1;
- },
- open: function(e, d){
- // this._getJobByTask(function(data){
- var options = {
- "draftId": d.id, "appId": "process.Work"+ d.id,
- "onAfterProcess": this.reloadTasks.bind(this),
- "onAfterReset": this.reloadTasks.bind(this),
- "onAfterRetract": this.reloadTasks.bind(this),
- "onAfterReroute": this.reloadTasks.bind(this),
- "onAfterDelete": this.reloadTasks.bind(this),
- "onAfterReaded": this.reloadReads.bind(this),
- };
- layout.openApplication(e, "process.Work", options);
- // }.bind(this));
- },
- });
|