部门权限与角色权限分配

This commit is contained in:
2022-12-19 17:15:20 +08:00
parent 4a2736219c
commit 2b57c787b5

View File

@@ -214,7 +214,7 @@
:data="deptsDatas"
:default-checked-keys="depChecked"
:props="deptProps"
:node-key="nodeKey"
node-key="deptId"
highlight-current
check-strictly
@check="handCheck"
@@ -337,7 +337,7 @@ import '@riophae/vue-treeselect/dist/vue-treeselect.css'
let userRoles = []
const defaultForm = {
dept_id: null,
deptId: null,
depts: [],
username: null,
personName: null,
@@ -389,7 +389,6 @@ export default {
deptsDatas: [],
rolesDatas: [],
drawerTitle: '',
nodeKey: 'dept_id',
flag: true,
dataPerm: false,
dataDialog: {},
@@ -458,10 +457,10 @@ export default {
// 新增与编辑前做的操作
[CRUD.HOOK.afterToCU](crud, form) {
this.getRoles()
if (form.dept_id == null) {
if (form.deptId == null) {
crudDept.getDepts()
} else {
this.getSupDepts(form.dept_id)
this.getSupDepts(form.deptId)
}
// this.getRoleLevel() 暂时不用
form.isUsed = form.enabled.toString()
@@ -633,28 +632,36 @@ export default {
})
})
},
// 部门权限
openDeptDrawer(row) {
crudDept.getDeptTree().then(res => {
this.deptsDatas = res.content
})
this.nodeKey = 'dept_id'
this.openDrawer()
this.drawerTitle = '分配部门权限'
this.flag = true
// 默认选中
this.depChecked = row.depts
const deptIds = []
for (var index in row.depts) {
deptIds.push(row.depts[index].deptId)
}
this.$nextTick(() => {
this.$refs.deptUser.setCheckedKeys(deptIds)
})
this.giveValue(row)
},
// 角色权限
openRoleDrawer(row) {
this.rolesDatas = []
getAll().then(res => {
this.rolesDatas = res
// 回显默认选中
this.$nextTick(function() {
for (let i = 0; i < this.rolesDatas.length; i++) {
for (let j = 0; j < row.roles.length; j++) {
if (this.rolesDatas[i].role_id == row.roles[j]) {
for (let j = 0; j < row.roles.length; j++) {
for (let i = 0; i < this.rolesDatas.length; i++) {
if (this.rolesDatas[i].roleId == row.roles[j].roleId) {
this.$refs.roleTable.toggleRowSelection(this.rolesDatas[i], true)
break
}
}
}
@@ -772,9 +779,9 @@ export default {
this.depChecked = []
},
giveValue(row) {
this.depCheckedId = row.user_id
this.depCheckedId = row.userId
},
clearCheck() {
clearCheck() { // 清空选中
if (this.flag) this.$refs.deptUser.setCheckedKeys([])
},
handleClose(done) {
@@ -790,12 +797,12 @@ export default {
},
saveChecked() {
const user = {
user_id: this.depCheckedId
userId: this.depCheckedId
}
if (this.flag) {
user.depts = this.$refs.deptUser.getCheckedKeys()
} else {
user.roles = this.crud.selections.map(item => (item.role_id))
user.roles = this.crud.selections.map(item => (item.roleId))
}
crudUser.edit(user).then(res => {
this.cancelForm()
@@ -852,9 +859,9 @@ export default {
user_id: this.dataDialog.user_id,
permission_scope_type: row.value
}
crudDataPermission.getDataDetail(param).then(res => {
this.dataPermissions = res
})
// crudDataPermission.getDataDetail(param).then(res => {
// this.dataPermissions = res
// })
this.showData = true
}
}