feat: 基本信息
This commit is contained in:
@@ -2,7 +2,12 @@ import type { ProFormColumnsType } from '@ant-design/pro-components';
|
||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||
import { Button, type ColProps, Drawer, Space } from 'antd';
|
||||
import type { FormInstance } from 'antd/lib';
|
||||
import React, { forwardRef, useImperativeHandle } from 'react';
|
||||
import React, {
|
||||
Children,
|
||||
cloneElement,
|
||||
forwardRef,
|
||||
useImperativeHandle,
|
||||
} from 'react';
|
||||
|
||||
interface ConfigurableDrawerFormProps {
|
||||
title?: string;
|
||||
@@ -56,7 +61,17 @@ const ConfigurableDrawerForm = forwardRef<
|
||||
},
|
||||
close: () => setOpen(false),
|
||||
}));
|
||||
|
||||
const renderChildren = () => {
|
||||
return Children.map(children, (child) => {
|
||||
if (React.isValidElement(child)) {
|
||||
// 使用更安全的方式传递属性,避免 TypeScript 错误
|
||||
return cloneElement(child, {
|
||||
...formData,
|
||||
} as any);
|
||||
}
|
||||
return child;
|
||||
});
|
||||
};
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
if (onSubmit) {
|
||||
@@ -75,7 +90,7 @@ const ConfigurableDrawerForm = forwardRef<
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
console.log(footer);
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
title={title}
|
||||
@@ -122,7 +137,8 @@ const ConfigurableDrawerForm = forwardRef<
|
||||
submitter={false}
|
||||
/>
|
||||
) : (
|
||||
children
|
||||
renderChildren()
|
||||
// children
|
||||
)}
|
||||
</Drawer>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user