Skip to content

Commit ad58a86

Browse files
committed
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
1 parent 9172afc commit ad58a86

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

ui/src/views/system/resource-authorization/component/PermissionSetting.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,27 @@ const dfsPermission = (arr: any = [], Name: string | number, e: boolean, idArr:
227227
228228
const filterText = ref('')
229229
230-
const filterData = computed(() =>
231-
props.data.filter((v: any) => v.name.toLowerCase().includes(filterText.value.toLowerCase())),
232-
)
230+
const filterData = computed(() => {
231+
function filterTree(data: any[]): any[] {
232+
return data
233+
.map(item => {
234+
// 递归过滤 children
235+
const children = item.children ? filterTree(item.children) : []
236+
// 判断当前节点或其子节点是否匹配
237+
const isMatch = item.name.toLowerCase().includes(filterText.value.toLowerCase())
238+
if (isMatch || children.length) {
239+
return {
240+
...item,
241+
children: children.length ? children : undefined,
242+
}
243+
}
244+
return null
245+
})
246+
.filter(Boolean)
247+
}
248+
249+
return filterTree(props.data)
250+
})
233251
234252
function checkedOperateChange(Name: string | number, row: any, e: boolean) {
235253
dfsPermission(props.data, Name, e, [row.id])

0 commit comments

Comments
 (0)