Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-project
Commits
4d5bd09e
提交
4d5bd09e
authored
10月 15, 2021
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
算法优化
上级
dda9f13d
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
16 行删除
+14
-16
Permissions.vue
src/modules/roles/components/Permissions.vue
+14
-16
没有找到文件。
src/modules/roles/components/Permissions.vue
浏览文件 @
4d5bd09e
...
@@ -44,8 +44,7 @@ export default {
...
@@ -44,8 +44,7 @@ export default {
{
name
:
'学校管理系统'
,
system_tag
:
1
,
permissions
:
[],
value
:
[]
},
{
name
:
'学校管理系统'
,
system_tag
:
1
,
permissions
:
[],
value
:
[]
},
{
name
:
'教师端'
,
system_tag
:
2
,
permissions
:
[],
value
:
[]
},
{
name
:
'教师端'
,
system_tag
:
2
,
permissions
:
[],
value
:
[]
},
{
name
:
'学生端'
,
system_tag
:
3
,
permissions
:
[],
value
:
[]
}
{
name
:
'学生端'
,
system_tag
:
3
,
permissions
:
[],
value
:
[]
}
],
]
idsPath
:
[]
}
}
},
},
async
beforeMount
()
{
async
beforeMount
()
{
...
@@ -108,9 +107,7 @@ export default {
...
@@ -108,9 +107,7 @@ export default {
let
ids
=
[]
let
ids
=
[]
item
.
value
.
forEach
(
id
=>
{
item
.
value
.
forEach
(
id
=>
{
// 通过子节点ID,返回包含父节点ID的数组
// 通过子节点ID,返回包含父节点ID的数组
this
.
getIdPath
(
this
.
permissions
,
id
)
ids
=
ids
.
concat
(
this
.
treeFindPath
(
this
.
permissions
,
id
))
ids
=
ids
.
concat
(
this
.
idsPath
)
this
.
idsPath
=
[]
})
})
result
.
push
({
system_tag
:
item
.
system_tag
,
permission_ids
:
this
.
uniqueIds
(
ids
)
})
result
.
push
({
system_tag
:
item
.
system_tag
,
permission_ids
:
this
.
uniqueIds
(
ids
)
})
}
}
...
@@ -129,19 +126,20 @@ export default {
...
@@ -129,19 +126,20 @@ export default {
})
})
},
},
// 通过子节点ID,返回路径数组
// 通过子节点ID,返回路径数组
getIdPath
(
tree
,
targetId
)
{
// https://segmentfault.com/q/1010000020095550
for
(
let
index
=
0
;
index
<
tree
.
length
;
index
++
)
{
treeFindPath
(
tree
,
targetId
,
path
=
[])
{
if
(
tree
[
index
].
children
)
{
if
(
!
tree
)
return
[]
if
(
this
.
getIdPath
(
tree
[
index
].
children
,
targetId
))
{
for
(
const
data
of
tree
)
{
this
.
idsPath
.
push
(
tree
[
index
].
id
)
// 这里按照你的需求来存放最后返回的内容吧
return
true
path
.
push
(
data
.
id
)
}
if
(
data
.
id
===
targetId
)
return
path
}
if
(
data
.
children
)
{
if
(
tree
[
index
].
id
===
targetId
)
{
const
findChildren
=
this
.
treeFindPath
(
data
.
children
,
targetId
,
path
)
this
.
idsPath
.
push
(
tree
[
index
].
id
)
if
(
findChildren
.
length
)
return
findChildren
return
true
}
}
path
.
pop
()
}
}
return
[]
},
},
// ID去重
// ID去重
uniqueIds
(
ids
)
{
uniqueIds
(
ids
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论