-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(form): fix ModalForm ref less error
close #7004
- Loading branch information
1 parent
b540053
commit 06721c3
Showing
7 changed files
with
484 additions
and
70 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
packages/form/src/components/SchemaForm/demos/ModalAndDrawerForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import type { ProFormColumnsType, ProFormLayoutType } from '@ant-design/pro-components'; | ||
import { BetaSchemaForm, ProFormSelect } from '@ant-design/pro-components'; | ||
import { Alert, Button, DatePicker, Space } from 'antd'; | ||
import dayjs from 'dayjs'; | ||
import { useState } from 'react'; | ||
|
||
const valueEnum = { | ||
all: { text: '全部', status: 'Default' }, | ||
open: { | ||
text: '未解决', | ||
status: 'Error', | ||
}, | ||
closed: { | ||
text: '已解决', | ||
status: 'Success', | ||
disabled: true, | ||
}, | ||
processing: { | ||
text: '解决中', | ||
status: 'Processing', | ||
}, | ||
}; | ||
|
||
type DataItem = { | ||
name: string; | ||
state: string; | ||
}; | ||
|
||
export default () => { | ||
const [layoutType, setLayoutType] = useState<ProFormLayoutType>('ModalForm'); | ||
return ( | ||
<> | ||
<Space | ||
style={{ | ||
width: '100%', | ||
}} | ||
direction="vertical" | ||
> | ||
<Alert | ||
type="warning" | ||
message="QueryFilter 和 lightFilter 暂不支持grid模式" | ||
style={{ | ||
marginBlockEnd: 24, | ||
}} | ||
/> | ||
<ProFormSelect | ||
label="布局方式" | ||
options={['ModalForm', 'DrawerForm']} | ||
fieldProps={{ | ||
value: layoutType, | ||
onChange: (e) => setLayoutType(e), | ||
}} | ||
/> | ||
</Space> | ||
<BetaSchemaForm<DataItem> | ||
trigger={<Button>点击我</Button>} | ||
layoutType={layoutType as 'ModalForm'} | ||
onFinish={async (values) => { | ||
console.log(values); | ||
}} | ||
{...(layoutType === 'ModalForm' | ||
? { | ||
modalProps: { destroyOnClose: true }, | ||
} | ||
: { | ||
drawerProps: { destroyOnClose: true }, | ||
})} | ||
columns={[ | ||
{ | ||
title: '标题', | ||
dataIndex: 'title', | ||
formItemProps: { | ||
rules: [ | ||
{ | ||
required: true, | ||
message: '此项为必填项', | ||
}, | ||
], | ||
}, | ||
width: 'md', | ||
}, | ||
]} | ||
/> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.