feat: expand and collapse are only displayed in the tree table

This commit is contained in:
katherinehhh 2023-03-14 15:41:58 +08:00
parent b28b8ba536
commit 42aba5e50b
2 changed files with 64 additions and 53 deletions

View File

@ -47,7 +47,11 @@ SchemaInitializer.Button = observer((props: SchemaInitializerButtonProps) => {
} }
}; };
const renderItems = (items: any) => { const renderItems = (items: any) => {
return items?.map((item, indexA) => { return items
.filter((v) => {
return v?.visible ? v.visible() : true;
})
?.map((item, indexA) => {
if (item.type === 'divider') { if (item.type === 'divider') {
return <Menu.Divider key={item.key || `item-${indexA}`} />; return <Menu.Divider key={item.key || `item-${indexA}`} />;
} }

View File

@ -1,4 +1,5 @@
import { Schema } from '@formily/react'; import { Schema, useFieldSchema } from '@formily/react';
import { useCollection } from '../../';
// 表格操作配置 // 表格操作配置
export const TableActionInitializers = { export const TableActionInitializers = {
@ -56,6 +57,12 @@ export const TableActionInitializers = {
schema: { schema: {
'x-align': 'right', 'x-align': 'right',
}, },
visible: () => {
const schema = useFieldSchema();
const collection = useCollection();
const { treeTable } = schema?.parent?.['x-decorator-props'];
return (collection as any).template === 'tree' && treeTable !== false;
},
}, },
], ],
}, },