|
@ -1,13 +1,21 @@ |
|
|
import React from 'react'; |
|
|
import React, { useRef } from 'react'; |
|
|
import { Button, Form } from 'antd'; |
|
|
import { Button, Form } from 'antd'; |
|
|
import { |
|
|
import { |
|
|
ModalForm, |
|
|
ModalForm, |
|
|
ProFormSelect, |
|
|
ProFormSelect, |
|
|
ProFormTextArea, |
|
|
ProFormTextArea, |
|
|
ProFormDigit, |
|
|
ProFormDigit, |
|
|
ProFormText |
|
|
ProFormText, |
|
|
|
|
|
ProFormDependency |
|
|
} from '@ant-design/pro-form'; |
|
|
} from '@ant-design/pro-form'; |
|
|
|
|
|
const DATA_TYPES = { |
|
|
|
|
|
"整型": "数字输入框", |
|
|
|
|
|
"字符型": "文本框", |
|
|
|
|
|
"布尔型": "下拉框", |
|
|
|
|
|
"数字输入框": "整型", |
|
|
|
|
|
"文本框": "字符型", |
|
|
|
|
|
"下拉框": "布尔型", |
|
|
|
|
|
} |
|
|
export default (props) => { |
|
|
export default (props) => { |
|
|
const { title, triggerRender, editData = null, onFinish, readOnly, models } = props; |
|
|
const { title, triggerRender, editData = null, onFinish, readOnly, models } = props; |
|
|
const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 16 } }; |
|
|
const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 16 } }; |
|
@ -15,9 +23,10 @@ export default (props) => { |
|
|
...editData, |
|
|
...editData, |
|
|
} : {}; |
|
|
} : {}; |
|
|
const [form] = Form.useForm(); |
|
|
const [form] = Form.useForm(); |
|
|
|
|
|
const formRef = useRef(); |
|
|
return ( |
|
|
return ( |
|
|
<ModalForm |
|
|
<ModalForm |
|
|
form={form} |
|
|
formRef={formRef} |
|
|
title={title || ''} |
|
|
title={title || ''} |
|
|
initialValues={initialValues} |
|
|
initialValues={initialValues} |
|
|
trigger={ |
|
|
trigger={ |
|
@ -63,18 +72,18 @@ export default (props) => { |
|
|
name="dataType" |
|
|
name="dataType" |
|
|
label="数据类型" |
|
|
label="数据类型" |
|
|
fieldProps={{ |
|
|
fieldProps={{ |
|
|
showSearch: true |
|
|
showSearch: true, |
|
|
|
|
|
onChange: value => { |
|
|
|
|
|
formRef?.current?.setFieldsValue({ |
|
|
|
|
|
control: DATA_TYPES[value] |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
}} |
|
|
}} |
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
<ProFormDigit |
|
|
|
|
|
name="length" |
|
|
|
|
|
label="长度" |
|
|
|
|
|
fieldProps={{ precision: 0, max: 99999999, }} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<ProFormSelect |
|
|
<ProFormSelect |
|
|
rules={[{ required: true, message: '请选择输入控件' }]} |
|
|
rules={[{ required: true, message: '请选择输入控件' }]} |
|
|
|
|
|
disabled={true} |
|
|
options={[ |
|
|
options={[ |
|
|
{ label: '数字输入框', value: '数字输入框' }, |
|
|
{ label: '数字输入框', value: '数字输入框' }, |
|
|
{ label: '文本框', value: '文本框' }, |
|
|
{ label: '文本框', value: '文本框' }, |
|
@ -82,6 +91,19 @@ export default (props) => { |
|
|
]} |
|
|
]} |
|
|
name="control" |
|
|
name="control" |
|
|
label="输入控件" |
|
|
label="输入控件" |
|
|
|
|
|
fieldProps={{ |
|
|
|
|
|
showSearch: true, |
|
|
|
|
|
onChange: value => { |
|
|
|
|
|
formRef?.current?.setFieldsValue({ |
|
|
|
|
|
dataType: DATA_TYPES[value] |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
<ProFormDigit |
|
|
|
|
|
name="length" |
|
|
|
|
|
label="长度" |
|
|
|
|
|
fieldProps={{ precision: 0, max: 99999999, }} |
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
<ProFormSelect |
|
|
<ProFormSelect |
|
@ -92,7 +114,7 @@ export default (props) => { |
|
|
name="nullable" |
|
|
name="nullable" |
|
|
label="是否允许为空" |
|
|
label="是否允许为空" |
|
|
/> |
|
|
/> |
|
|
|
|
|
{/* |
|
|
<ProFormSelect |
|
|
<ProFormSelect |
|
|
rules={[{ required: true, message: '请选是否只读' }]} |
|
|
rules={[{ required: true, message: '请选是否只读' }]} |
|
|
options={[ |
|
|
options={[ |
|
@ -100,7 +122,7 @@ export default (props) => { |
|
|
{ label: '否', value: false }]} |
|
|
{ label: '否', value: false }]} |
|
|
name="readOnly" |
|
|
name="readOnly" |
|
|
label="是否只读" |
|
|
label="是否只读" |
|
|
/> |
|
|
/> */} |
|
|
|
|
|
|
|
|
<ProFormTextArea |
|
|
<ProFormTextArea |
|
|
name="description" |
|
|
name="description" |
|
|