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