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:
CaptainB 2025-07-07 17:43:16 +08:00
parent 9172afc476
commit ad58a86f8e

View File

@ -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])