vueとelementUIの権限制御と割り当て
5673 ワード
vueとelementUIの権限制御と割り当て
表のレンダリング
import {getRoleList, deleteRoleRight, getRightList, grantRoleRight} from '@/api'
export default {
data () {
return {
roleList: [],
dialogFormVisible: false,
rightList: [],
defaultProps: {
children: 'children',
label: 'authName'
},
selectedRights: [], // id
currentRole: {} //
}
},
created () {
this.initList()
},
methods: {
initList () {
getRoleList().then(res => {
if (res.meta.status === 200) {
console.log(res)
this.roleList = res.data
}
})
},
/* deleteRight (row, rightId) {
deleteRoleRight({roleId: row.id, rightId: rightId}).then(res => {
if (res.meta.status === 200) {
row.children = res.data
} else {
this.$message({
type: 'error',
message: res.meta.msg
})
}
})
}, */
/* showDialog (row) {
this.dialogFormVisible = true
this.currentRole = row
getRightList({type: 'tree'}).then(res => {
if (res.meta.status === 200) {
console.log(res.data)
this.rightList = res.data
} else {
this.$message({
type: 'error',
message: res.meta.msg
})
}
})
//
this.selectedRights.length = 0
// , children, id, selectedRights
this.currentRole.children.forEach(first => {
if (first.children && first.children.length !== 0) {
first.children.forEach(second => {
if (second.children && second.children.length !== 0) {
second.children.forEach(third => {
this.selectedRights.push(third.id)
})
}
})
}
})
}, */
//
/* submitGrant () {
let rids = this.$refs.tree.getCheckedKeys().join(',')
grantRoleRight(this.currentRole.id, {rids: rids}).then(res => {
if (res.meta.status === 200) {
this.$message({
type: 'success',
message: res.meta.msg
})
this.dialogFormVisible = false
this.initList()
}
})
} */
}
}
表のレンダリング