<重点>更新权限
This commit is contained in:
parent
a48b3f0557
commit
a0dd85cdfd
|
@ -44,10 +44,26 @@
|
|||
<template scope="scope">
|
||||
<el-button size="mini" icon="el-icon-edit" type="primary" @click="edit(scope.row.id)">编辑</el-button>
|
||||
<el-button size="mini" icon="el-icon-delete" type="danger">删除</el-button>
|
||||
<el-button size="mini" icon="el-icon-setting" type="warning">分配权限</el-button>
|
||||
<el-button size="mini" icon="el-icon-setting" @click="setRole(scope.row)" type="warning">分配权限</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-dialog title="分配权限" :visible.sync="dialogVisible" @close="selectKey=[]">
|
||||
<el-tree
|
||||
:data="rights"
|
||||
:props="props"
|
||||
node-key="id"
|
||||
:default-checked-keys="selectKey"
|
||||
default-expand-all
|
||||
show-checkbox
|
||||
ref="treeRef"
|
||||
>
|
||||
</el-tree>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible=false">取消</el-button>
|
||||
<el-button type="primary" @click="sub()">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -57,10 +73,50 @@ export default {
|
|||
name: 'roles',
|
||||
data () {
|
||||
return {
|
||||
data: []
|
||||
data: [],
|
||||
selectKey: [],
|
||||
dialogVisible: false,
|
||||
rights: [],
|
||||
id: 0,
|
||||
props: {
|
||||
children: 'children',
|
||||
label: 'authName'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
sub () {
|
||||
const keys = [...this.$refs.treeRef.getCheckedKeys(),
|
||||
...this.$refs.treeRef.getHalfCheckedKeys()].join(',')
|
||||
this.$http.post(`roles/${this.id}/rights`, { rids: keys }).then(response => {
|
||||
const res = response.data
|
||||
if (res.meta.status !== 200) {
|
||||
return this.$message.error(res.meta.msg)
|
||||
}
|
||||
this.$message.success(res.meta.msg)
|
||||
this.list()
|
||||
this.dialogVisible = false
|
||||
})
|
||||
},
|
||||
select (v) {
|
||||
if (v) {
|
||||
v.forEach(vv => {
|
||||
this.selectKey.push(vv.id)
|
||||
if (vv.children) {
|
||||
this.select(vv.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
setRole (row) {
|
||||
this.id = row.id
|
||||
this.select(row.children)
|
||||
this.dialogVisible = true
|
||||
this.$http.get('rights/tree').then(response => {
|
||||
const res = response.data
|
||||
this.rights = res.data
|
||||
}).catch(error => error)
|
||||
},
|
||||
edit (id) {
|
||||
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user