zmh
2 years ago
17 changed files with 375 additions and 112 deletions
@ -1,2 +1,10 @@ |
|||
alter table t_metadata_database alter column type type varchar(255) using type::varchar(255); |
|||
alter table t_resource_consumption alter column approve_state type varchar(20) using approve_state::varchar(20); |
|||
DROP TYPE "public"."enum_metadata_type"; |
|||
DROP TYPE "public"."enum_approve_state"; |
|||
alter table t_metadata_database |
|||
add "catalogKey" varchar(255) not null; |
|||
alter table t_metadata_file |
|||
add "catalogKey" varchar(255) not null; |
|||
alter table t_metadata_restapi |
|||
add "catalogKey" varchar(255) not null; |
|||
|
@ -0,0 +1,125 @@ |
|||
import React, { useEffect, useState } from 'react'; |
|||
import { Modal, Input, Form, Select, InputNumber } from 'antd'; |
|||
const { TextArea } = Input; |
|||
const MetadataDatabaseModal = (props) => { |
|||
const { onConfirm, onCancel, editData, metadataModels, modelTypes, resourceCatalogPath } = props; |
|||
const [form] = Form.useForm(); |
|||
useEffect(() => { |
|||
}, []); |
|||
const handleOk = () => { |
|||
form.validateFields().then(values => { |
|||
if (onConfirm) { |
|||
onConfirm(values) |
|||
} |
|||
}) |
|||
} |
|||
const validatorNull = (rule, value, getFieldValue, validateFields, label) => { |
|||
if (!value || !value.trim().length) { |
|||
return Promise.reject(new Error(`${label}不可空字符串`)); |
|||
} |
|||
return Promise.resolve(); |
|||
} |
|||
const renderModel = () => { |
|||
const items = metadataModels.map(m => { |
|||
if (m.control === '文本框') { |
|||
const rules = [{ required: m.nullable, message: '' }, |
|||
{ max: m.length, message: `${m.attributeName}不超过${m.length}个字符` }] |
|||
if (m.nullable) { |
|||
rules.push(({ getFieldValue, validateFields }) => ({ |
|||
validator(_, value) { return validatorNull(_, value, getFieldValue, validateFields, m.attributeName) } |
|||
})) |
|||
} |
|||
return <Form.Item |
|||
label={m.attributeName} |
|||
name={m.attributeCode} |
|||
rules={rules}> |
|||
<Input style={{ width: '90%' }} placeholder={`请输入${m.attributeName}`} /> |
|||
</Form.Item> |
|||
} else if (m.control === '数字输入框') { |
|||
return <Form.Item |
|||
label={m.attributeName} |
|||
name={m.attributeCode} |
|||
rules={[{ required: m.nullable, message: '' }, { max: m.length || 0 }]}> |
|||
<InputNumber style={{ width: '90%' }} placeholder={`请输入${m.attributeName}`} /> |
|||
</Form.Item> |
|||
} else { |
|||
return <Form.Item |
|||
label={m.attributeName} |
|||
name={m.attributeCode} |
|||
rules={[{ required: m.nullable, message: '' }]}> |
|||
<Select |
|||
placeholder={`请选择${m.attributeName}`} |
|||
style={{ width: '90%' }} |
|||
showSearch |
|||
optionFilterProp='children' |
|||
getPopupContainer={triggerNode => triggerNode.parentNode} |
|||
filterOption={(input, option) => option.props.children |
|||
.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
|||
> |
|||
<Select.Option value={'是'} key={'是'}>是</Select.Option> |
|||
<Select.Option value={'否'} key={'否'}>否</Select.Option> |
|||
</Select> |
|||
</Form.Item > |
|||
} |
|||
}) |
|||
return items; |
|||
} |
|||
return ( |
|||
<Modal title={editData.title} open={true} destroyOnClose |
|||
okText='确定' width={800} |
|||
onOk={() => handleOk(null)} |
|||
onCancel={onCancel}> |
|||
<Form form={form} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} initialValues={editData.record || {}}> |
|||
<Form.Item |
|||
label='元数据名称' |
|||
name='name' |
|||
rules={[{ required: true, message: '' }, { max: 50, message: `元数据名称不超过50个字符` }, |
|||
({ getFieldValue, validateFields }) => ({ |
|||
validator(_, value) { return validatorNull(_, value, getFieldValue, validateFields, '元数据名称') } |
|||
})]}> |
|||
<Input style={{ width: '90%' }} placeholder={`请输入元数据名称`} /> |
|||
</Form.Item> |
|||
<Form.Item |
|||
label='元数据代码' |
|||
name='code' |
|||
rules={[{ required: true, message: '' }, { max: 50, message: `元数据代码不超过50个字符` }, |
|||
({ getFieldValue, validateFields }) => ({ |
|||
validator(_, value) { return validatorNull(_, value, getFieldValue, validateFields, '元数据代码') } |
|||
})]}> |
|||
<Input style={{ width: '90%' }} placeholder={`请输入元数据代码`} /> |
|||
</Form.Item> |
|||
<Form.Item |
|||
label="元数据类型" |
|||
name='type' |
|||
rules={[{ required: true, message: '请选择元数据类型' }]}> |
|||
<Select |
|||
placeholder='请选择元数据类型' |
|||
style={{ width: '90%' }} |
|||
showSearch |
|||
optionFilterProp='children' |
|||
getPopupContainer={triggerNode => triggerNode.parentNode} |
|||
filterOption={(input, option) => option.props.children |
|||
.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
|||
> |
|||
{modelTypes.map(m => <Select.Option value={m} key={m}>{m}</Select.Option>)} |
|||
</Select> |
|||
</Form.Item> |
|||
<Form.Item |
|||
label='上下文路径' |
|||
name='path' |
|||
rules={[{ required: true }]} |
|||
> |
|||
<Input disabled style={{ width: '90%' }} /> |
|||
</Form.Item> |
|||
<Form.Item |
|||
label='详情' |
|||
name='description' |
|||
rules={[{ max: 255, message: `描述不超过255个字符` }]}> |
|||
<TextArea rows={4} style={{ width: '90%' }} placeholder={`请输入描述`} /> |
|||
</Form.Item> |
|||
{renderModel()} |
|||
</Form> |
|||
</Modal> |
|||
) |
|||
} |
|||
export default MetadataDatabaseModal; |
@ -0,0 +1,3 @@ |
|||
'use strict'; |
|||
import React from 'react'; |
|||
export const ModelTypes = ['目录', '库', '视图', '表', '字段', '索引', '外键', '主键', '唯一约束']; |
Loading…
Reference in new issue