| 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.DepartmentMinder=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{id:"",year:"",style:"default",template:"default",theme:"fresh-blue-compat"},initialize:function(t,i,e,n){this.setOptions(n);this.app=i;this.path="/x_component_Report/$DepartmentMinder/";this.cssPath="/x_component_Report/$DepartmentMinder/"+this.options.style+"/css.wcss";this._loadCss();this.lp=this.app.lp;this.actions=e;this.node=$(t)},load:function(){this.departmentCN=this.options.department.split("@")[0];this.app.setTitle(this.options.year+"年"+this.departmentCN+"工作汇报");this.data={root:{data:{text:this.departmentCN,isRoot:true,watch:true},children:[]}};this.app.strategyActions.listMeasureByYearDepartment(this.options.year,this.options.department,function(t){var e=this.data.root.children;var n=t.data||[];var o=0;n.each(function(t){t.text=t.measuresinfotitle;t.note=" ";t.isMeasure=true;t.watch=true;var i={data:t,children:[]};this.app.strategyActions.listPriorityByUnitMeasure(this.options.year,t.id,this.options.department,function(t){if(!t.data)t.data=[];t.data.each(function(t){if(t.keyworktitle){t.text=t.keyworktitle;t.note=" ";t.isPriority=true;t.watch=true;i.children.push({data:t,children:[{data:{text:"加载中..."}}]})}});o++;if(o==n.length){this.createMinder(this.data)}}.bind(this));e.push(i)}.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 i=t.getData();var e=t.getRenderer("NoteIconRenderer");if(e&&e.getRenderShape()){var o=e.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(i.isPriority){var s=t.getRenderer("ExpanderRenderer").getRenderShape();if(s){s.addEventListener("mousedown",function(t){var i=this.getData();if(!i.loaded){setTimeout(function(){n.expendPriority(this,i,function(){}.bind(this))}.bind(this),100)}}.bind(t))}}var r=t.getRenderContainer().node;r.addEventListener("click",function(t){var i=this.getData();if(i.isPriority){if(!i.loaded){setTimeout(function(){n.expendPriority(this,i,function(){}.bind(this))}.bind(this),100)}else{var e=this.getRenderer("ExpanderRenderer");e.expander.fire("mousedown")}}else{}}.bind(t))}},expendPriority:function(a,d,t){var i=this;if(this.isLoaddingChildren)return;this.isLoaddingChildren=true;this.actions.listWithPriority(this.options.year,{workIds:[d.id],unitList:[this.options.department]},function(t){d.loaded=true;var i={};var e=t.data;e.sort(function(t,i){return t.month.localeCompare(i.month)});e.each(function(t){if(!i[t.month])i[t.month]=[];i[t.month].push(t)});var n={data:d,children:[]};for(var o in i){var s=[];i[o].each(function(t){var i=[];t.progList.each(function(t){i.push(this.app.common.splitWithLength(t.targetPerson.split("@")[0]+":"+t.progressContent,35))}.bind(this));s.push(i.join("\n"))}.bind(this));n.children.push({data:{text:parseInt(o)+"月"},children:[{data:{text:s.join("\n")}}]})}while(a.getChildren().length){var r=a.getChildren()[0];this.minder.km.removeNode(r)}this.minder.km.importNode(a,n);a.expand();this.minder.km.refresh();this.isLoaddingChildren=false}.bind(this))},loadTooltip:function(t,i){if(!this.tooltips)this.tooltips={};if(this.tooltips[t.id]){var e=this.currentTooltip=this.tooltips[t.id];e.targetCoordinates=i;e.load()}else{if(t.isRoot){var e=this.currentTooltip=new MWF.xApplication.Report.KeyWorkTooltip(this.node,null,this.app,t,{},i)}else if(t.isMeasure){var e=this.currentTooltip=new MWF.xApplication.Report.MeasureTooltip(this.node,null,this.app,t,{},i)}else if(t.isPriority){var e=this.currentTooltip=new MWF.xApplication.Report.PriorityTooltip(this.node,null,this.app,t,{},i)}if(e){e.load();this.tooltips[t.id]=e}}},hideTooltip:function(){if(this.currentTooltip){this.currentTooltip.hide()}}});
|