mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-31 10:12:51 +00:00
feat: enhance data filtering in PermissionSetting component with recursive support
--bug=1057808 --user=刘瑞斌 【资源授权】资源授权界面成员、资源搜索功能无效 https://www.tapd.cn/62980211/s/1724794 --bug=1057547 --user=刘瑞斌 【资源授权】社区&专业&企业版-资源授权-知识库/应用搜索框功能未生效 https://www.tapd.cn/62980211/s/1724805
This commit is contained in:
parent
9172afc476
commit
ad58a86f8e
|
|
@ -227,9 +227,27 @@ const dfsPermission = (arr: any = [], Name: string | number, e: boolean, idArr:
|
|||
|
||||
const filterText = ref('')
|
||||
|
||||
const filterData = computed(() =>
|
||||
props.data.filter((v: any) => v.name.toLowerCase().includes(filterText.value.toLowerCase())),
|
||||
)
|
||||
const filterData = computed(() => {
|
||||
function filterTree(data: any[]): any[] {
|
||||
return data
|
||||
.map(item => {
|
||||
// 递归过滤 children
|
||||
const children = item.children ? filterTree(item.children) : []
|
||||
// 判断当前节点或其子节点是否匹配
|
||||
const isMatch = item.name.toLowerCase().includes(filterText.value.toLowerCase())
|
||||
if (isMatch || children.length) {
|
||||
return {
|
||||
...item,
|
||||
children: children.length ? children : undefined,
|
||||
}
|
||||
}
|
||||
return null
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
return filterTree(props.data)
|
||||
})
|
||||
|
||||
function checkedOperateChange(Name: string | number, row: any, e: boolean) {
|
||||
dfsPermission(props.data, Name, e, [row.id])
|
||||
|
|
|
|||
Loading…
Reference in New Issue