Compare commits

...
1 Commits
Author SHA1 Message Date
wc24 e789f8a1f7 feat(filter): filterableFields 递归收集嵌套 filterable,key=点路径
ShrimpTable 把 filterableFields 从'顶层 filter'改成'递归收集 object/tab 嵌套叶子',
生成 key=点路径的合成字段。抽屉/buildFilter/URL 同步全按 field.key 走即可,无需改。
版本与 shrimp-server 对齐 0.7.5。
2026-06-30 16:01:23 +08:00
2 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "shrimp-admin", "name": "shrimp-admin",
"version": "0.7.1", "version": "0.7.5",
"private": true, "private": true,
"description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现", "description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现",
"main": "src/index.ts", "main": "src/index.ts",
+16 -1
View File
@@ -212,9 +212,24 @@ const formFields = computed(() => {
return list.filter(f => f.editable !== 'readonly') return list.filter(f => f.editable !== 'readonly')
}) })
const searchableFields = computed(() => fields.value.filter(f => f.searchable)) const searchableFields = computed(() => fields.value.filter(f => f.searchable))
// 递归收集 filterable 字段(含 object/tab 嵌套叶子),生成 key=点路径的"合成字段"。
// 这样筛选抽屉/buildFilter/URL 同步全按 field.key 走即可——key 就是 condition.level 这种路径。
function collectFilterablePaths(list: IFieldConfig[], base: string[], out: any[]) {
for (const f of list) {
const path = [...base, f.key]
if (f.filterable) out.push({ ...f, key: path.join('.') })
if (f.type === 'tab' && Array.isArray((f as any).tabs)) {
for (const t of (f as any).tabs) collectFilterablePaths(t.fields, path, out)
} else if (f.type === 'object' && Array.isArray((f as any).fields)) {
collectFilterablePaths((f as any).fields, path, out)
}
}
}
const filterableFields = computed(() => { const filterableFields = computed(() => {
const lockedKeys = new Set(Object.keys(props.baseFilter || {})) const lockedKeys = new Set(Object.keys(props.baseFilter || {}))
return fields.value.filter(f => f.filterable && !lockedKeys.has(f.key)) const out: any[] = []
collectFilterablePaths(fields.value, [], out)
return out.filter(f => !lockedKeys.has(f.key))
}) })
const formSlotNames = computed(() => Object.keys(slots).filter(name => name.startsWith('form-'))) const formSlotNames = computed(() => Object.keys(slots).filter(name => name.startsWith('form-')))