123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- Ext.define('erp.view.hr.emplmana.HrOrgStrTree',{
- extend: 'Ext.tree.Panel',
- alias: 'widget.hrOrgStrTree',
- id: 'tree-panel',
- border : false,
- enableDD : false,
- split: true,
- width : '100%',
- height: '100%',
- expandedNodes: [],
- title: "<font color=#a1a1a1; size=2>员工组织架构</font>",
- toggleCollapse: function() {
- if (this.collapsed) {
- this.expand(this.animCollapse);
- } else {
- this.title = '员工组织架构';
- this.collapse(this.collapseDirection, this.animCollapse);
- }
- return this;
- },
- rootVisible: false,
- singleExpand: true,
- containerScroll : true,
- collapsible : true,
- autoScroll: true,
- store: Ext.create('Ext.data.TreeStore', {
- root : {
- text: 'root',
- id: 'root',
- expanded: true
- }
- }),
- tools: [{
- id: 'refresh',
- type: 'refresh',
- tooltip: '刷新',
- handler: function(){
-
- }
- },{
- id: 'search',
- type: 'search',
- tooltip: '查找',
- handler: function(){
-
- }
- }],
- bodyStyle:'background-color:#f1f1f1;',
- initComponent : function(){
- this.getTreeRootNode(0);
- this.callParent(arguments);
- },
- getTreeRootNode: function(parentId){
- Ext.Ajax.request({//拿到tree数据
- url : basePath + 'hr/employee/getAllHrOrgsTree.action',
- params: {
- parentId: parentId
- },
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.tree){
- var tree = res.tree;
- Ext.getCmp('tree-panel').store.setRootNode({
- text: 'root',
- id: 'root',
- expanded: true,
- children: tree
- });
- } else if(res.exceptionInfo){
- showError(res.exceptionInfo);
- }
- }
- });
- },
- openCloseFun: function(){
- var o = Ext.getCmp("open");
- var c = Ext.getCmp("close");
- var tree = Ext.getCmp('tree-panel');
- if(o.hidden==false&&c.hidden==true){
- tree.expandAll();
- o.hide();
- c.show();
- }else{
- tree.collapseAll();
- o.show();
- c.hide();
- }
- },
- listeners: {//滚动条有时候没反应,添加此监听器
- scrollershow: function(scroller) {
- if (scroller && scroller.scrollEl) {
- scroller.clearManagedListeners();
- scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
- }
- },
- },
- /**
- * 找到所有已展开的节点,包括当前被选中的节点
- * @param record 当前被选中的节点
- */
- getExpandedItems: function(record){
- var me = this;
- me.getRecordParents(record);
- if(record.isLeaf()){
- me.expandedNodes.push(record);
- }
- },
- getRecordParents: function(record, parent){
- var me = this;
- if(!parent){
- parent = me.store.tree.root;
- me.expandedNodes = [];
- }
- if(parent.childNodes.length > 0){
- Ext.each(parent.childNodes, function(){
- if(this.isExpanded()){
- me.expandedNodes.push(this);
- if(this.childNodes.length > 0){
- me.getRecordParents(record, this);
- }
- }
- });
- }
- },
- getExpandItem: function(root){
- var me = this;
- if(!root){
- root = this.store.tree.root;
- }
- var node = null;
- if(root.childNodes.length > 0){
- Ext.each(root.childNodes, function(){
- if(this.isExpanded()){
- node = this;
- if(this.childNodes.length > 0){
- var n = me.getExpandItem(this);
- node = n == null ? node : n;
- }
- }
- });
- }
- return node;
- }
- });
|