优化多角色数据权限匹配规则

This commit is contained in:
RuoYi
2022-08-21 22:54:25 +08:00
parent 1d2f37bfe1
commit 2952cb2c4f
5 changed files with 25 additions and 38 deletions

View File

@@ -262,9 +262,8 @@
</template>
<script setup name="Role">
import { addRole, changeRoleStatus, dataScope, delRole, getRole, listRole, updateRole } from "@/api/system/role";
import { addRole, changeRoleStatus, dataScope, delRole, getRole, listRole, updateRole, deptTreeSelect } from "@/api/system/role";
import { roleMenuTreeselect, treeselect as menuTreeselect } from "@/api/system/menu";
import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept";
const router = useRouter();
const { proxy } = getCurrentInstance();
@@ -462,8 +461,8 @@ function getRoleMenuTreeselect(roleId) {
});
}
/** 根据角色ID查询部门树结构 */
function getRoleDeptTreeselect(roleId) {
return roleDeptTreeselect(roleId).then(response => {
function getDeptTree(roleId) {
return deptTreeSelect(roleId).then(response => {
deptOptions.value = response.depts;
return response;
});
@@ -543,12 +542,12 @@ function dataScopeSelectChange(value) {
/** 分配数据权限操作 */
function handleDataScope(row) {
reset();
const roleDeptTreeselect = getRoleDeptTreeselect(row.roleId);
const deptTreeSelect = getDeptTree(row.roleId);
getRole(row.roleId).then(response => {
form.value = response.data;
openDataScope.value = true;
nextTick(() => {
roleDeptTreeselect.then(res => {
deptTreeSelect.then(res => {
nextTick(() => {
if (deptRef.value) {
deptRef.value.setCheckedKeys(res.checkedKeys);