Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李宁
/
Activity
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit dd3bdb7a
authored
Nov 21, 2025
by
李宁
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
dd3fce0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
10 deletions
channelBusiManage/src/components/RoleManagement.vue
channelBusiManage/src/components/RoleManagement.vue
View file @
dd3bdb7
...
...
@@ -253,7 +253,7 @@ const roleStatusEnabled = ref(true)
const
expandedPermissions
=
ref
<
Set
<
string
>>
(
new
Set
())
// 计算属性
const
roleStatus
=
computed
(():
RoleStatus
=>
roleStatusEnabled
.
value
?
'1'
:
'0'
)
const
roleStatus
=
computed
(():
RoleStatus
=>
roleStatusEnabled
.
value
?
1
:
0
)
const
topLevelPermissions
=
computed
(()
=>
props
.
permissions
.
filter
(
p
=>
!
p
.
parentId
)
...
...
@@ -263,11 +263,26 @@ const filteredRoles = ref([])
// 获取角色的权限ID列表,兼容不同的字段名
const
getRolePermissionIds
=
async
(
role
:
Role
)
=>
{
const
response
=
await
$api
.
queryRolePermission
({
id
:
role
.
id
})
try
{
const
response
=
await
$api
.
queryRolePermission
({
id
:
role
.
id
})
return
[
'1'
,
'2'
,
'3'
,
'4'
]
return
[
1
,
2
,
3
,
4
]
if
(
response
.
c
===
0
&&
response
.
d
)
{
// 假设返回的数据结构是 { functionIds: ['id1', 'id2', ...] }
return
response
.
d
.
functionIds
||
response
.
d
.
permissionIds
||
[]
}
else
{
console
.
warn
(
'获取角色权限失败:'
,
response
.
msg
)
return
role
.
permissionIds
||
role
.
permissions
||
[]
}
}
catch
(
error
)
{
console
.
error
(
'获取角色权限出错:'
,
error
)
// 如果API调用失败,使用角色对象中已有的权限数据
return
role
.
permissionIds
||
role
.
permissions
||
[]
}
}
// 打开新增对话框
...
...
@@ -275,10 +290,11 @@ const handleOpenAddDialog = () => {
editingRole
.
value
=
null
roleName
.
value
=
''
roleDescription
.
value
=
''
roleStatusEnabled
.
value
=
true
selectedPermissions
.
value
=
[]
roleStatusEnabled
.
value
=
true
expandedPermissions
.
value
=
new
Set
(
props
.
permissions
.
filter
(
p
=>
!
p
.
parentId
).
map
(
p
=>
p
.
id
))
isDialogOpen
.
value
=
true
}
...
...
@@ -289,11 +305,25 @@ const handleOpenEditDialog = async (role: Role) => {
roleDescription
.
value
=
role
.
remark
||
''
roleStatusEnabled
.
value
=
role
.
status
===
1
selectedPermissions
.
value
=
await
getRolePermissionIds
(
role
)
// 获取角色权限并设置选中状态
const
permissionIds
=
await
getRolePermissionIds
(
role
)
selectedPermissions
.
value
=
permissionIds
// 展开顶级权限以便用户能看到选中的权限
expandedPermissions
.
value
=
new
Set
(
props
.
permissions
.
filter
(
p
=>
!
p
.
parentId
).
map
(
p
=>
p
.
id
))
console
.
log
(
selectedPermissions
)
console
.
log
(
expandedPermissions
)
// 如果有选中的权限,也展开其父级权限
permissionIds
.
forEach
(
permissionId
=>
{
const
permission
=
findPermissionById
(
permissionId
)
if
(
permission
&&
permission
.
parentId
)
{
// 向上展开所有父级
let
currentPermission
=
permission
while
(
currentPermission
.
parentId
)
{
expandedPermissions
.
value
.
add
(
currentPermission
.
parentId
)
currentPermission
=
findPermissionById
(
currentPermission
.
parentId
)
!
}
}
})
isDialogOpen
.
value
=
true
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment