|
@ -19,15 +19,15 @@ const MetadataDatabaseModal = (props) => { |
|
|
} |
|
|
} |
|
|
return Promise.resolve(); |
|
|
return Promise.resolve(); |
|
|
} |
|
|
} |
|
|
const renderModel = () => { |
|
|
const renderModelItems = () => { |
|
|
const items = metadataModels.map(m => { |
|
|
const items = metadataModels.map(m => { |
|
|
if (m.control === '文本框') { |
|
|
if (m.control === '文本框') { |
|
|
const rules = [{ required: m.nullable, message: '' }, |
|
|
const rules = [{ required: !m.nullable, message: '' }] |
|
|
{ max: m.length, message: `${m.attributeName}不超过${m.length}个字符` }] |
|
|
if (!m.nullable) { |
|
|
if (m.nullable) { |
|
|
|
|
|
rules.push(({ getFieldValue, validateFields }) => ({ |
|
|
rules.push(({ getFieldValue, validateFields }) => ({ |
|
|
validator(_, value) { return validatorNull(_, value, getFieldValue, validateFields, m.attributeName) } |
|
|
validator(_, value) { return validatorNull(_, value, getFieldValue, validateFields, m.attributeName) } |
|
|
})) |
|
|
})) |
|
|
|
|
|
rules.push({ max: m.length, message: `${m.attributeName}不超过${m.length}个字符` }) |
|
|
} |
|
|
} |
|
|
return <Form.Item |
|
|
return <Form.Item |
|
|
label={m.attributeName} |
|
|
label={m.attributeName} |
|
@ -36,17 +36,25 @@ const MetadataDatabaseModal = (props) => { |
|
|
<Input style={{ width: '90%' }} placeholder={`请输入${m.attributeName}`} /> |
|
|
<Input style={{ width: '90%' }} placeholder={`请输入${m.attributeName}`} /> |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
} else if (m.control === '数字输入框') { |
|
|
} else if (m.control === '数字输入框') { |
|
|
|
|
|
const rules = [{ required: !m.nullable, message: `${m.attributeName}不可空` }] |
|
|
|
|
|
let maxValue = ''; |
|
|
|
|
|
if (m.length) { |
|
|
|
|
|
while (m.length > 0) { |
|
|
|
|
|
maxValue += '9' |
|
|
|
|
|
m.length--; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return <Form.Item |
|
|
return <Form.Item |
|
|
label={m.attributeName} |
|
|
label={m.attributeName} |
|
|
name={m.attributeCode} |
|
|
name={m.attributeCode} |
|
|
rules={[{ required: m.nullable, message: '' }, { max: m.length || 0 }]}> |
|
|
rules={rules}> |
|
|
<InputNumber style={{ width: '90%' }} placeholder={`请输入${m.attributeName}`} /> |
|
|
<InputNumber min={0} max={maxValue ? parseInt(maxValue) : 0} style={{ width: '90%' }} placeholder={`请输入${m.attributeName}`} /> |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
} else { |
|
|
} else { |
|
|
return <Form.Item |
|
|
return <Form.Item |
|
|
label={m.attributeName} |
|
|
label={m.attributeName} |
|
|
name={m.attributeCode} |
|
|
name={m.attributeCode} |
|
|
rules={[{ required: m.nullable, message: '' }]}> |
|
|
rules={[{ required: !m.nullable, message: `${m.attributeName}不可空` }]}> |
|
|
<Select |
|
|
<Select |
|
|
placeholder={`请选择${m.attributeName}`} |
|
|
placeholder={`请选择${m.attributeName}`} |
|
|
style={{ width: '90%' }} |
|
|
style={{ width: '90%' }} |
|
@ -109,7 +117,7 @@ const MetadataDatabaseModal = (props) => { |
|
|
name='path' |
|
|
name='path' |
|
|
rules={[{ required: true }]} |
|
|
rules={[{ required: true }]} |
|
|
> |
|
|
> |
|
|
<Input disabled style={{ width: '90%' }} /> |
|
|
<TextArea disabled rows={1} style={{ width: '90%' }} /> |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
<Form.Item |
|
|
<Form.Item |
|
|
label='详情' |
|
|
label='详情' |
|
@ -117,7 +125,7 @@ const MetadataDatabaseModal = (props) => { |
|
|
rules={[{ max: 255, message: `描述不超过255个字符` }]}> |
|
|
rules={[{ max: 255, message: `描述不超过255个字符` }]}> |
|
|
<TextArea rows={4} style={{ width: '90%' }} placeholder={`请输入描述`} /> |
|
|
<TextArea rows={4} style={{ width: '90%' }} placeholder={`请输入描述`} /> |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
{renderModel()} |
|
|
{renderModelItems()} |
|
|
</Form> |
|
|
</Form> |
|
|
</Modal> |
|
|
</Modal> |
|
|
) |
|
|
) |
|
|