import { FormItem, Input } from '@formily/antd'; import { Field } from '@formily/core'; import { ISchema, observer, useField, useForm } from '@formily/react'; import { Action, Form, SchemaComponent, SchemaComponentProvider, useActionContext } from '@nocobase/client'; import { Select } from 'antd'; import React, { useRef } from 'react'; const useCloseAction = () => { const { setVisible } = useActionContext(); const form = useForm(); return { async run() { setVisible(false); form.submit((values) => { console.log(values); }); }, }; }; const Editable = observer((props) => { const field = useField(); return (
打开方式:
{props.children}
); }); const schema: ISchema = { type: 'object', properties: { action1: { 'x-decorator': 'Editable', 'x-component': 'Action', 'x-component-props': { type: 'primary', openMode: 'modal', containerRefKey: 'containerRef', }, type: 'void', title: 'Open', properties: { drawer1: { 'x-component': 'Action.Container', 'x-component-props': {}, type: 'void', title: 'Modal Title', properties: { hello1: { title: 'T1', 'x-content': 'Hello', }, footer1: { 'x-component': 'Action.Container.Footer', type: 'void', properties: { close1: { title: 'Close', 'x-component': 'Action', 'x-component-props': { useAction: '{{ useCloseAction }}', }, }, submit: { title: 'Submit', 'x-component': 'Action', 'x-component-props': { type: 'primary', useAction: '{{ useCloseAction }}', }, }, }, }, }, }, }, }, }, }; export default observer(() => { const containerRef = useRef(); return (
); });