| 1 |
- MWF.xApplication.Execution=MWF.xApplication.Execution||{};MWF.xDesktop.requireApp("Template","MForm",null,false);MWF.xDesktop.requireApp("Template","Minder",null,false);MWF.xDesktop.requireApp("Report","Common",null,false);MWF.xApplication.Report.KeyWorkMinder=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{id:"",year:"",style:"default",template:"default",theme:"fresh-blue-compat"},initialize:function(t,e,i,n){this.setOptions(n);this.app=e;this.path="/x_component_Report/$KeyWorkMinder/";this.cssPath="/x_component_Report/$KeyWorkMinder/"+this.options.style+"/css.wcss";this._loadCss();this.lp=this.app.lp;this.actions=i;this.node=$(t)},load:function(){this.data={root:{data:{},children:[]}};this.app.strategyActions.getKeyWorkById(this.options.id,function(t){this.app.setTitle(t.data.strategydeploytitle);t.data.text=t.data.strategydeploytitle;t.data.note=" ";t.data.isRoot=true;t.data.watch=true;this.data.root.data=t.data;this.app.strategyActions.listMeasuresWidthKeyWork(this.options.id,function(t){var n=this.data.root.children;t.data.each(function(e){e.text=e.measuresinfotitle;e.note=" ";e.isMeasure=true;e.watch=true;var i={data:e,children:[]};e.deptlist.each(function(t){i.children.push({data:{text:t.split("@")[0],department:t,measureId:e.id,isDepartment:true,watch:true},children:[{data:{text:"加载中..."}}]})});n.push(i)});this.createMinder(this.data)}.bind(this))}.bind(this));this.refreshFun=this.refresh.bind(this);this.app.addEvent("resize",this.refreshFun)},destroy:function(){if(this.minder)this.minder.destroy();for(var t in this.tooltips){this.tooltips[t].destroy()}if(this.refreshFun){this.app.removeEvent("resize",this.refreshFun)}delete this},refresh:function(){if(this.minder)this.minder.refresh()},reload:function(){if(this.minder)this.minder.destroy();this.node.empty();this.load()},createMinder:function(t){this.minder=new MWF.xApplication.Template.Minder(this.node,this.app,t,{hasNavi:false,onPostLoad:function(){this.minder.km.execCommand("ExpandToLevel",2);this.minder.loadNavi(this.node)}.bind(this),onPostLoadNode:function(t){this.setMinderNode(t)}.bind(this)});this.minder.load()},setMinderNode:function(t){var n=this;if(!t.getData().watch){}else{var e=t.getData();var i=t.getRenderer("NoteIconRenderer");if(i&&i.getRenderShape()){var o=i.getRenderShape();o.addEventListener("mouseover",function(t){n.tooltipTimer=setTimeout(function(){var t=this.getRenderBox("screen");n.loadTooltip(this.getData(),t)}.bind(this),300)}.bind(t));o.addEventListener("mouseout",function(t){clearTimeout(n.tooltipTimer);n.hideTooltip()}.bind(t))}if(e.isDepartment){var r=t.getRenderer("ExpanderRenderer").getRenderShape();if(r){r.addEventListener("mousedown",function(t){var e=this.getData();if(!e.loaded){setTimeout(function(){n.expendDepartment(this,e,function(){}.bind(this))}.bind(this),100)}}.bind(t))}}var s=t.getRenderContainer().node;s.addEventListener("click",function(t){var e=this.getData();if(e.isDepartment){if(!e.loaded){setTimeout(function(){n.expendDepartment(this,e,function(){}.bind(this))}.bind(this),100)}else{var i=this.getRenderer("ExpanderRenderer");i.expander.fire("mousedown")}}else{}}.bind(t))}},expendDepartment:function(o,r,t){var e=this;if(this.isLoaddingChildren)return;this.isLoaddingChildren=true;this.actions.listPriorityByUnitMeasure(this.options.year,r.measureId,r.department,function(t){r.loaded=true;if(!t.data)t.data=[];this.proiorityLength=t.data.length;this.proiorityLoadedLength=0;var e={data:r,children:[]};t.data.each(function(t){if(t.keyworktitle){t.text=t.keyworktitle;t.note=" ";t.department=r.department;t.isPriority=true;t.watch=true;e.children.push({data:t})}});while(o.getChildren().length){var i=o.getChildren()[0];this.minder.km.removeNode(i)}this.minder.km.importNode(o,e);var n=o.getChildren();if(n.length){n.forEach(function(t){this.expendPriority(o,t,t.getData(),null)}.bind(this))}else{this.minder.km.refresh()}this.isLoaddingChildren=false}.bind(this))},expendPriority:function(a,d,h,t){var e=this;this.actions.listWithPriority(this.options.year,{workIds:[h.id],unitList:[h.department]},function(t){var e={};var i=t.data;i.sort(function(t,e){return t.month.localeCompare(e.month)});i.each(function(t){if(!e[t.month])e[t.month]=[];e[t.month].push(t)});var n={data:h,children:[]};for(var o in e){var r=[];e[o].each(function(t){var e=[];t.progList.each(function(t){e.push(this.app.common.splitWithLength(t.targetPerson.split("@")[0]+":"+t.progressContent,35))}.bind(this));r.push(e.join("\n"))}.bind(this));n.children.push({data:{text:parseInt(o)+"月"},children:[{data:{text:r.join("\n")}}]})}this.minder.km.importNode(d,n);this.proiorityLoadedLength++;if(this.proiorityLoadedLength==this.proiorityLength){a.expand();this.minder.km.refresh();var s=a.getChildren();s.forEach(function(t){this.setMinderNode(t)}.bind(this))}}.bind(this))},loadTooltip:function(t,e){if(!this.tooltips)this.tooltips={};if(this.tooltips[t.id]){var i=this.currentTooltip=this.tooltips[t.id];i.targetCoordinates=e;i.load()}else{if(t.isRoot){var i=this.currentTooltip=new MWF.xApplication.Report.KeyWorkTooltip(this.node,null,this.app,t,{},e)}else if(t.isMeasure){var i=this.currentTooltip=new MWF.xApplication.Report.MeasureTooltip(this.node,null,this.app,t,{},e)}else if(t.isPriority){var i=this.currentTooltip=new MWF.xApplication.Report.PriorityTooltip(this.node,null,this.app,t,{},e)}if(i){i.load();this.tooltips[t.id]=i}}},hideTooltip:function(){if(this.currentTooltip){this.currentTooltip.hide()}}});
|