Browse Source

权限设置

hy 7 years ago
parent
commit
84f8553858

+ 8 - 2
frontend/saas-web/app/view/document/bom/FormPanel.js

@@ -128,14 +128,20 @@ Ext.define('saas.view.document.bom.FormPanel', {
                 dataIndex : "pr_detail",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             }, {
                 text : "物料规格", 
                 dataIndex : "pr_spec",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             }, {
                 allowBlank:false,

+ 25 - 0
frontend/saas-web/app/view/document/kind/ChildForm.js

@@ -63,6 +63,31 @@ Ext.define('KitchenSink.view.binding.ChildForm', {
                 maxLength: 20
             }]
         },
+        personpower:{
+            items:[{
+                xtype:'hidden',
+                name:'id'
+            },{
+                xtype:'textfield',
+                name:'name',
+                allowBlank:false,
+                fieldLabel:'角色名称',
+                maxLength: 20
+            },{
+                xtype:'textfield',
+                name:'description',
+                allowBlank:false,
+                fieldLabel:'角色描述',
+                maxLength: 20
+            },{
+                xtype:'textfield',
+                hidden:true,
+                name:'code',
+                allowBlank:true,
+                fieldLabel:'角色编号',
+                maxLength: 20
+            }]
+        },
         bankinformation:{
             items:[{
                 xtype:'hidden',

+ 23 - 0
frontend/saas-web/app/view/document/kind/Kind.js

@@ -208,6 +208,29 @@ Ext.define('saas.view.document.kind.Kind', {
             keyField:'id',
             reqUrl:'/api/commons/number/save'
         },
+        personpower:{
+            columns: [{
+                text : "角色名称", 
+                width : 200.0, 
+                dataIndex : "name", 
+                xtype : "", 
+            }, 
+            {
+                text : "角色描述", 
+                dataIndex : "description", 
+                width : 120.0, 
+                xtype : "", 
+            },
+            {
+                text : "编号", 
+                dataIndex : "code", 
+                width : 120.0, 
+                xtype : "", 
+            }],
+            keyField:'id',
+            reqUrl:'/api/account/role/save',
+            updateUrl:'/api/account/role/update',
+        },
         warehouse:{
             columns: [{
                 text: '仓库编号',

+ 13 - 3
frontend/saas-web/app/view/purchase/purchase/FormPanel.js

@@ -118,7 +118,11 @@ Ext.define('saas.view.purchase.purchase.FormPanel', {
                 dataIndex : "pr_detail",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    debugger
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null; 
+                    }                     
+                    return v;
                 }
             },
             {
@@ -126,7 +130,10 @@ Ext.define('saas.view.purchase.purchase.FormPanel', {
                 dataIndex : "pr_spec",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null; 
+                    }                     
+                    return v;    
                 }
             },
             {
@@ -134,7 +141,10 @@ Ext.define('saas.view.purchase.purchase.FormPanel', {
                 dataIndex : "pr_zxbzs",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null; 
+                    }                     
+                    return v; 
                 }
             },            
             {

+ 8 - 2
frontend/saas-web/app/view/purchase/purchaseIn/FormPanel.js

@@ -151,7 +151,10 @@ Ext.define('saas.view.purchase.purchaseIn.FormPanel', {
                 dataIndex : "pr_detail",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {
@@ -159,7 +162,10 @@ Ext.define('saas.view.purchase.purchaseIn.FormPanel', {
                 dataIndex : "pr_spec",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {

+ 8 - 2
frontend/saas-web/app/view/purchase/purchaseOut/FormPanel.js

@@ -143,7 +143,10 @@ Ext.define('saas.view.purchase.purchaseOut.FormPanel', {
                 dataIndex : "pr_detail",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {
@@ -151,7 +154,10 @@ Ext.define('saas.view.purchase.purchaseOut.FormPanel', {
                 dataIndex : "pr_spec",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {

+ 10 - 4
frontend/saas-web/app/view/sale/sale/FormPanel.js

@@ -102,16 +102,22 @@ Ext.define('saas.view.sale.sale.FormPanel', {
                 ignore:true,
                 width : 150.0, 
                 renderer: function (v, m, r) {
-				    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
-				}
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
+                }
             }, {
                 text : "规格", 
                 dataIndex : "pr_spec",
                 ignore:true,
                 width : 150.0, 
                 renderer: function (v, m, r) {
-				    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
-				}
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
+                }
             }, {
                 text : "数量", 
                 dataIndex : "sd_qty",

+ 9 - 3
frontend/saas-web/app/view/sale/saleIn/FormPanel.js

@@ -94,15 +94,21 @@ Ext.define('saas.view.sale.saleIn.FormPanel', {
                 ignore:true,
                 width : 150.0, 
                 renderer: function (v, m, r) {
-				    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
-				}
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
+                }
             }, {
                 text : "规格", 
                 dataIndex : "pr_spec",
                 ignore:true,
                 width : 150.0, 
                 renderer: function (v, m, r) {
-				    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             }, {
                 text : "数量", 

+ 10 - 4
frontend/saas-web/app/view/sale/saleOut/FormPanel.js

@@ -104,16 +104,22 @@ Ext.define('saas.view.sale.saleout.FormPanel', {
                 ignore:true,
                 width : 150.0, 
                 renderer: function (v, m, r) {
-				    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
-				}
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
+                }
             }, {
                 text : "规格", 
                 dataIndex : "pr_spec",
                 ignore:true,
                 width : 150.0, 
                 renderer: function (v, m, r) {
-				    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
-				}
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
+                }
             },  {
                 text : "出货数量", 
                 dataIndex : "pd_outqty", 

+ 8 - 2
frontend/saas-web/app/view/stock/appropriationInOut/FormPanel.js

@@ -148,7 +148,10 @@ Ext.define('saas.view.stock.appropriationInOut.FormPanel', {
                 dataIndex : "pr_detail",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {
@@ -156,7 +159,10 @@ Ext.define('saas.view.stock.appropriationInOut.FormPanel', {
                 dataIndex : "pr_spec",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {

+ 8 - 2
frontend/saas-web/app/view/stock/make/FormPanel.js

@@ -159,7 +159,10 @@ Ext.define('saas.view.stock.make.FormPanel', {
                 width : 100.0,
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {
@@ -168,7 +171,10 @@ Ext.define('saas.view.stock.make.FormPanel', {
                 width : 100.0,
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {

+ 8 - 2
frontend/saas-web/app/view/stock/otherIn/FormPanel.js

@@ -144,7 +144,10 @@ Ext.define('saas.view.stock.otherIn.FormPanel', {
                 dataIndex : "pr_detail",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {
@@ -152,7 +155,10 @@ Ext.define('saas.view.stock.otherIn.FormPanel', {
                 dataIndex : "pr_spec",
                 ignore:true,
                 renderer: function (v, m, r) {
-                    return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:v;
+                    if(!v){
+                        return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
+                    }
+                    return v;
                 }
             },
             {

+ 3 - 15
frontend/saas-web/app/view/sys/power/FormPanel.js

@@ -10,8 +10,6 @@ Ext.define('saas.view.sys.power.FormPanel', {
     
     //字段属性
     _idField: 'id',
-    _readUrl:'/api/commons/enterprise/read',
-    _saveUrl:'/api/commons/enterprise/save',
 
     //基础属性
     frame:true,
@@ -24,25 +22,15 @@ Ext.define('saas.view.sys.power.FormPanel', {
         xtype: 'sys-power-treepanel',
         layout:'fit',
         height:'100%',
-        width: '15%',
-        rootVisible: false,
-        useArrows: true,
-        store : Ext.create('Ext.data.TreeStore', {
-            fields : ['NAME', 'ID'],
-            autoLoad:false,
-            root : {
-                text : 'Root',
-                id : 0,
-                expanded : true
-            }
-        }),
+        width: '20%',
+        useArrows: true
     },{
         title:'权限列表',
         margin:'0 0 0 5',
         region:'center',
         layout:'fit',
         height:'100%',
-        width: '85%',
+        width: '80%',
         xtype:'power-grid'
     }],
 

+ 123 - 48
frontend/saas-web/app/view/sys/power/GroupGrid.js

@@ -4,7 +4,6 @@
 Ext.define('saas.view.sys.power.GroupGrid', {
     extend: 'Ext.grid.Panel',
     requires: [
-      //  'Ext.selection.CellModel',
         'saas.view.sys.power.OtherField'
     ],
     xtype: 'power-grid',
@@ -13,25 +12,16 @@ Ext.define('saas.view.sys.power.GroupGrid', {
             clicksToEdit: 1
         }
     },
-    store:Ext.create('Ext.data.Store',{
-        fields:[
-            {name: 'query',type:'bool'},
-            {name: 'add', type: 'bool'},
-            {name: 'save', type: 'bool'},
-            {name: 'delete', type: 'bool'},
-            {name: 'audit', type: 'bool'},
-            {name: 'resAudit', type: 'bool'},
-            {name: 'import', type: 'bool'},
-            {name: 'export', type: 'bool'},
-            {name: 'others', calculate: function(data) {
-                var others = data['others'];
-                return others;
-            }}
-        ],
-        data: [{"query":true,"add":false,"delete":false,"audit":true,"resAudit":true,"import":true,"export":true},{"query":true,"add":false,"delete":false,"audit":true,"resAudit":true,"import":true,"export":true,"others":[{'resouceId':1,'text':'权限1','value':'true'}]},
-            {"query":true,"add":false,"delete":false,"audit":true,"resAudit":true,"import":true,"export":true,"others":[{'resouceId':100,'text':'权限2','value':true},{'resouceId':101,'text':'权限2.1','value':true}]},
-            {"query":true,"add":false,"delete":false,"audit":true,"resAudit":true,"import":true,"export":true,"others":[{'resouceId':1000,text:'权限3','value':true},{'resouceId':1001,'text':'权限3.1','value':true},{'resouceId':1002,'text':'权限1','value':true},{'resouceId':100,'text':'权限3.2','value':true}]}]
-}),
+    bind:{
+        store: '{powergrid}'
+    },
+    features : [Ext.create('Ext.grid.feature.Grouping',{
+		showSummaryRow: true,
+        startCollapsed: false,
+        groupHeaderTpl: '{name}'+'模块'
+	})],
+    initId:0,
+    dataUrl:'http://192.168.253.31:8560/api/account/role/power/resource',
     selModel:Ext.create('Ext.selection.CheckboxModel', {
         checkOnly: true,
         listeners: {
@@ -43,83 +33,154 @@ Ext.define('saas.view.sys.power.GroupGrid', {
             }
         }
     }),
-    height: 350,
     viewConfig: {
      stripeRows: false,
      enableTextSelection: false,
      markDirty: false
     },
     trackMouseOver: false,
-    //disableSelection: true,
     columns: [{
+        header: '单据名称',
+        dataIndex: 'groupName',
+        xtype: '',
+        flex: 1.5,
+        stopSelection: false
+    },{
         header: '查询',
         dataIndex: 'query',
         xtype: 'checkcolumn',
         headerCheckbox: true,
-        width: 90,
+        menuDisabled:true,
+        flex: 1,
         stopSelection: false
     }, {
-        header: '新增',
+        header: '保存',
         dataIndex: 'add',
         xtype: 'checkcolumn',
         headerCheckbox: true,
-        width: 90,
+        menuDisabled:true,
+        flex: 1,
         stopSelection: false
     }, {
         header: '修改',
-        dataIndex: 'save',
+        dataIndex: 'update',
         xtype: 'checkcolumn',
         headerCheckbox: true,
-        width: 90,
+        menuDisabled:true,
+        flex: 1,
         stopSelection: false
     }, {
         header: '删除',
         dataIndex: 'delete',
         xtype: 'checkcolumn',
         headerCheckbox: true,
-        width: 90,
+        menuDisabled:true,
+        flex: 1,
         stopSelection: false
     }, {
         header: '审核',
         dataIndex: 'audit',
         xtype: 'checkcolumn',
         headerCheckbox: true,
-        width: 90,
+        menuDisabled:true,
+        flex: 1,
         stopSelection: false
     }, {
         header: '反审核',
-        dataIndex: 'resAudit',
+        dataIndex: 'unAudit',
         xtype: 'checkcolumn',
         headerCheckbox: true,
-        width: 90,
+        menuDisabled:true,
+        flex: 1,
         stopSelection: false
     }, {
         header: '导入',
-        dataIndex: 'import',
+        dataIndex: 'fileImport',
         xtype: 'checkcolumn',
         headerCheckbox: true,
-        width: 90,
+        menuDisabled:true,
+        flex: 1,
         stopSelection: false
     }, {
         header: '导出',
-        dataIndex: 'export',
+        dataIndex: 'fileExport',
         xtype: 'checkcolumn',
         headerCheckbox: true,
-        width: 90,
+        menuDisabled:true,
+        flex: 1,
         stopSelection: false
     }, {
+        header: '打印',
+        dataIndex: 'print',
+        xtype: 'checkcolumn',
+        headerCheckbox: true,
+        menuDisabled:true,
+        flex: 1,
+        stopSelection: false
+    },{
         text: '其它',
-        width: 160,
-        dataIndex:'others',
+        flex: 2.7,
+        dataIndex:'other',
         xtype: 'widgetcolumn',
+        menuDisabled:true,
         producesHTML: false,
         widget: {
             xtype: 'powerotherfield',
-            bind:'{record.others}'
+            bind:'{record.other}'
         }
     }],
 
-    // Dispatch named listener and handler methods to this instance
+    initComponent: function () {
+        var me = this;
+        var formModel = me.$initParent.getViewModel();
+        me.store = Ext.create('Ext.data.Store',{
+            fields:[
+                {name: 'groupId',type:'int'},
+                {name: 'groupName',type:'string'},
+                {name: 'moduleName',type:'string'},
+                {name: 'query',type:'bool'},
+                {name: 'add', type: 'bool'},
+                {name: 'delete', type: 'bool'},
+                {name: 'audit', type: 'bool'},
+                {name: 'update', type: 'bool'},
+                {name: 'unAudit', type: 'bool'},
+                {name: 'fileExport', type: 'bool'},
+                {name: 'fileImport', type: 'bool'},
+                {name: 'print', type: 'bool'},
+                {name: 'other', calculate: function(data) {
+                    var other = data['other'];
+                    return other;
+                }}
+            ],
+            groupField:'moduleName',
+            proxy: {
+                timeout:8000,
+                type: 'ajax',
+                url: me.dataUrl,
+                actionMethods: {
+                    read: 'GET'
+                },
+                reader: {
+                    type: 'json',
+                    rootProperty: 'data',
+                }
+            },
+            listeners:{
+                beforeload: function (store, op) {
+                    var id = me.initId;
+                    Ext.apply(store.proxy.extraParams, {
+                        id:id
+                    });
+                }
+            }
+            // data: [{"query":true,"add":false,"delete":false,"audit":true,"resAudit":true,"import":true,"export":true},{"query":true,"add":false,"delete":false,"audit":true,"resAudit":true,"import":true,"export":true,"others":[{'resouceId':1,'text':'权限1','value':'true'}]},
+            //     {"query":true,"add":false,"delete":false,"audit":true,"resAudit":true,"import":true,"export":true,"others":[{'resouceId':100,'text':'权限2','value':true},{'resouceId':101,'text':'权限2.1','value':true}]},
+            //     {"query":true,"add":false,"delete":false,"audit":true,"resAudit":true,"import":true,"export":true,"others":[{'resouceId':1000,text:'权限3','value':true},{'resouceId':1001,'text':'权限3.1','value':true},{'resouceId':1002,'text':'权限1','value':true},{'resouceId':100,'text':'权限3.2','value':true}]}]
+        }),
+        formModel.set('powergrid', me.store);
+        me.callParent(arguments);
+    },
+
     defaultListenerScope: true,
 
     listeners: {
@@ -127,20 +188,34 @@ Ext.define('saas.view.sys.power.GroupGrid', {
         columnhide: 'onColumnToggle'
     },
     selectAllPower: function(record){
-        var me = this;data={"query":true,"add":true,"save":true,"delete":true,"audit":true,"resAudit":true,"import":true,"export":true};
-        me.setAllOthers(record,true,data);
+        var me = this;
+        me.setAllOthers(record,true);
 
     },
     deselectAllPower:function(record){
-        var me = this;data={"query":false,"add":false,"save":false,"delete":false,"audit":false,"resAudit":false,"import":false,"export":false};
-        me.setAllOthers(record,false,data);
+        var me = this;
+        me.setAllOthers(record,false);
     },
-    setAllOthers:function(record,bool,data){
-        var others=record.get('others');
-        Ext.Array.each(others,function(o){
-            o.value=bool;
+    setAllOthers:function(record,bool){
+        var data = {};
+        data.add = bool;
+        data.query = bool;
+        data.delete = bool;
+        data.audit = bool;
+        data.update = bool;
+        data.unAudit= bool;
+        data.fileExport= bool;
+        data.fileImport= bool;
+        data.print= bool;
+        var other=record.get('other');
+        Ext.Array.each(other,function(o){
+            o.checked=bool;
         })
-        data.others = others
+        data.other = other;
+        data.id = record.get('id');
+        data.groupId = record.get('groupId');
+        data.groupName = record.get('groupName');
+        data.moduleName =  record.get('moduleName');
         record.set(data);
     }
 });

+ 2 - 2
frontend/saas-web/app/view/sys/power/OtherField.js

@@ -23,8 +23,8 @@ Ext.define('saas.view.sys.power.OtherField', {
             if(this.items.length>0)this.removeAll(true);
             for (i = 0; i < len; i++) {
                 items.push({
-                   boxLabel:v[i].text,
-                   checked:v[i].value
+                   boxLabel:v[i].name,
+                   checked:v[i].checked
                 });
             }
             this.add(items);

+ 205 - 19
frontend/saas-web/app/view/sys/power/TreePanel.js

@@ -5,31 +5,217 @@ Ext.define('saas.view.sys.power.TreePanel', {
     //工具类
     FormUtil: Ext.create('saas.util.FormUtil'),
     BaseUtil: Ext.create('saas.util.BaseUtil'),
+    dataUrl:'/api/account/role/list',
+    deleteUrl:'/api/account/role/delete/',
 
     initComponent: function () {
         var me = this;
+        me.store = Ext.create('Ext.data.TreeStore', {
+            fields : ['name', 'id', 'description','code'],
+            autoLoad:false,
+            root : {
+                text : 'Root',
+                id : 0,
+                expanded : true
+            }
+        }),
+        me.columns =[{
+            xtype: 'treecolumn',
+            dataIndex: 'text',
+            flex: 1
+        }, {
+            xtype: 'actioncolumn',
+            width: 28,
+            iconCls: 'x-hidden icon x-fa fa-plus',
+            getClass: function(v, meta, rec) {
+                if(rec.get('code')=='ROLE_ADMIN'){
+                    return 'x-hidden icon x-fa fa-key';
+                }else if(rec.get('leaf')){
+                     return 'x-hidden icon x-fa fa-pencil';
+                }else{
+                     return 'x-hidden icon x-fa fa-plus';
+                }
+            },
+            handler: function(treeview, rowIdx, colIdx, e) {
+                var record = treeview.store.data.getAt(rowIdx);
+                me.addItem(record);
+            }
+        }, {
+            xtype: 'actioncolumn',
+            width: 36,
+            iconCls: 'x-hidden icon x-fa fa-trash-o',
+            getClass: function(v, meta, rec) {
+                if(rec.get('code')=='ROLE_ADMIN'){
+                    return '';
+                }else if(rec.get('leaf')){
+                     return 'x-hidden icon x-fa fa-trash-o';
+                }else {
+                    return '';
+                }
+            },
+            handler: function(treeview, rowIdx, colIdx, e) {
+                var record = treeview.store.data.getAt(rowIdx);
+                me.deleteItem(record);
+            }
+        }];
+        me.setTree();
+        me.callParent(arguments);
+    },
+    listeners: {
+		itemmouseenter: function(th, record, item, index, e, eOpts) {
+			var imgs = item.getElementsByClassName('icon x-fa');
+			Ext.Array.each(imgs, function(img) {
+				img.classList.remove('x-hidden');
+			});
+		},
+		itemmouseleave: function(th, record, item, index, e, eOpts) {
+			var imgs = item.getElementsByClassName('icon x-fa');
+			Ext.Array.each(imgs, function(img) {
+				img.classList.add('x-hidden');
+			});
+        },
+        itemclick:function(view,record,index,d,e){
+            if(!record.get('leaf')){
+                return;
+            }
+            var classList = e.target.classList;
+            var clickIcon = false;
+            Ext.Array.each(classList, function(item) {
+				if(item.indexOf('x-action-col')>-1){
+                    clickIcon = true;
+                }
+            });
+            if(clickIcon){return;}
+            //加载右边的grid
+            var id = record.get('id');
+            if(id&&id!=0){
+                var grid = view.ownerCt.ownerCt.query('power-grid')[0];
+                grid.initId = id;
+                grid.store.load();
+                grid.store.group('moduleName', 'ASC');
+            }
+        }
+    },
+    getData:function(){
+        var me = this;
+        var data = [];
+        Ext.Ajax.request({
+            url: me.dataUrl,
+            params: '',
+            method: 'GET',
+            async:false,
+            success: function(response, opts) {
+                var _data = Ext.decode(response.responseText);
+                if(_data&&_data.data){
+                    _data = _data.data;
+                    for (let index = 0; index < _data.length; index++) {
+                        var o = {
+                            code:_data[index].code,
+                            id: _data[index].id,
+                            text: _data[index].name,
+                            name:_data[index].name,
+                            description:_data[index].description,
+                            leaf:true,
+                            iconCls: 'x-fa fa-user',
+                        }
+                        data.push(o);
+                    }
+                }
+            },
+            failure: function(response, opts) {}
+        }); 
+        return data; 
+    },
+    setTree:function(){
+        var me = this;
+        var data = me.getData();
         me.getStore().setRootNode({
-            text: 'root',
+            text: '角色列表',
             id: '0',
+            iconCls: 'x-fa fa-list',
             expanded: true,
-            children: [{
-                text: '测试',
-                iconCls: 'x-fa fa-wrench',
-                children: [{
-                    text: '叶子1',
-                    iconCls: 'x-fa fa-share-alt',
-                    leaf: true
-                },{
-                    text: '叶子2',
-                    iconCls: 'x-fa fa-flag',
-                    leaf: true
-                },{
-                    text: '叶子3',
-                    iconCls: 'x-fa fa-signal',
-                    leaf: true
-                }]
-            }]
+            children: data
+        });
+    },
+    addItem:function(rec){
+        var me=this;
+        var isleaf = rec.get('leaf');
+        var record = isleaf?rec:null;
+        var view = this.ownerCt.getController().getView();
+        var document = Ext.create('saas.view.document.kind.Kind',{});
+        this.dialog = view.add({
+            xtype: 'document-kind-childwin',
+            bind: {
+                title: (record?'修改':'新增')+'角色'
+            },
+            dataKind:'personpower',
+            belong:document.etc['personpower'],
+            _parent:this,
+            record:record,
+            session: true,
+            onSave:function(){
+                var me = this;
+                var belong = this.belong;
+                me.setLoading(true);
+                var form=this.down('form');
+                var params = {};
+                var names = belong.columns.map(column => column.dataIndex);
+                Ext.Array.each(names,function(name) {
+                    if(name){
+                        var dataField = form.down('[name='+name+']');
+                        if(dataField&&dataField.value){
+                            params[name] = dataField.value;
+                            params._value = dataField.value;
+                        }
+                    }
+                });
+                var idField = form.down('[name='+belong.keyField+']');
+                params[belong.keyField] = idField.value || 0;
+                //保存接口
+                this.BaseUtil.request({
+                    url: idField.value?belong.updateUrl:belong.reqUrl,
+                    params: JSON.stringify(params),
+                    method: 'POST'
+                })
+                .then(function(localJson) {
+                    me.setLoading(false);
+                    if(localJson.success){
+                        showToast('保存成功');
+                        me._parent.setTree();
+                        form.ownerCt.close();
+                    }
+                })
+                .catch(function(res) {
+                    me.setLoading(false);
+                    console.error(res);
+                    showToast('保存失败: ' + res.message);
+                });
+            }
+        });
+        this.dialog.show();
+    },
+    deleteItem:function(rec){
+        if(rec&&(rec.get('code')=='ROLE_ADMIN'||!rec.get('leaf'))){
+            return;
+        }
+        var me = this;
+        me.setLoading(true);
+        me.BaseUtil.request({
+            url: me.deleteUrl + rec.get('id'),
+            params: '',
+            method: 'POST'
+        })
+        .then(function(localJson) {
+            me.setLoading(false);
+            if(localJson.success){
+                showToast('删除成功');
+                me.setTree();
+            }
+        })
+        .catch(function(res) {
+            me.setLoading(false);
+            console.error(res);
+            showToast('删除失败: ' + res.message);
         });
-        me.callParent(arguments);
     }
 });