Browse Source

暂交库表元数据新建

master
zmh 2 years ago
parent
commit
43d30da6be
  1. 39
      web/client/src/sections/metadataManagement/actions/metadata.js
  2. 12
      web/client/src/sections/metadataManagement/components/metadataDatabModal.js
  3. 31
      web/client/src/sections/metadataManagement/containers/databasesTable.js
  4. 4
      web/client/src/utils/webapi.js

39
web/client/src/sections/metadataManagement/actions/metadata.js

@ -22,7 +22,7 @@ export function postResourceCatalog(data) {
dispatch: dispatch, dispatch: dispatch,
actionType: 'POST_RESOURCE_CATALOG', actionType: 'POST_RESOURCE_CATALOG',
url: ApiTable.postResourceCatalog, url: ApiTable.postResourceCatalog,
msg: { option: '新资源目录' }, msg: { option: '新资源目录' },
reducer: {} reducer: {}
}); });
} }
@ -98,4 +98,41 @@ export function getMetadataModels(params) {
msg: { error: '获取元数据模型失败' }, msg: { error: '获取元数据模型失败' },
reducer: { name: 'metadataModels' } reducer: { name: 'metadataModels' }
}); });
}
export function postMeatadataDatabases(data) {
return dispatch => basicAction({
type: 'post',
data: data,
dispatch: dispatch,
actionType: 'POST_METADATA_DATABASES',
url: ApiTable.postMeatadataDatabases,
msg: { option: '新建库表元数据' },
reducer: {}
});
}
export function putMeatadataDatabases(id, data) {
return dispatch => basicAction({
type: 'put',
data: data,
dispatch,
actionType: 'PUT_METADATA_DATABASES',
url: ApiTable.putMeatadataDatabases.replace('{id}', id),
msg: {
option: '修改库表元数据',
}
});
}
export function delMeatadataDatabases(id) {
return dispatch => basicAction({
type: 'del',
dispatch,
actionType: 'DELETE_METADATA_DATABASES',
url: ApiTable.delMeatadataDatabases.replace('{id}', id),
msg: {
option: '删除库表元数据',
}
});
} }

12
web/client/src/sections/metadataManagement/components/metadataDatabModal.js

@ -2,14 +2,20 @@ import React, { useEffect, useState } from 'react';
import { Modal, Input, Form, Select, InputNumber } from 'antd'; import { Modal, Input, Form, Select, InputNumber } from 'antd';
const { TextArea } = Input; const { TextArea } = Input;
const MetadataDatabaseModal = (props) => { const MetadataDatabaseModal = (props) => {
const { onConfirm, onCancel, editData, metadataModels, modelTypes, resourceCatalogPath } = props; const { onConfirm, onCancel, editData, metadataModels, modelTypes } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
useEffect(() => { useEffect(() => {
}, []); }, []);
const handleOk = () => { const handleOk = () => {
form.validateFields().then(values => { form.validateFields().then(values => {
if (onConfirm) { if (onConfirm) {
onConfirm(values) let dataSave = JSON.parse(JSON.stringify(values));
dataSave.attributesParam = {};
metadataModels.map(m => {
dataSave.attributesParam[m.attributeCode] = values[m.attributeCode];
delete dataSave[m.attributeCode];
})
onConfirm(dataSave);
} }
}) })
} }
@ -48,7 +54,7 @@ const MetadataDatabaseModal = (props) => {
label={m.attributeName} label={m.attributeName}
name={m.attributeCode} name={m.attributeCode}
rules={rules}> rules={rules}>
<InputNumber min={0} max={maxValue ? parseInt(maxValue) : 0} style={{ width: '90%' }} placeholder={`请输入${m.attributeName}`} /> <InputNumber min={0} max={maxValue ? parseInt(maxValue) : 0} precision={0} style={{ width: '90%' }} placeholder={`请输入${m.attributeName}`} />
</Form.Item> </Form.Item>
} else { } else {
return <Form.Item return <Form.Item

31
web/client/src/sections/metadataManagement/containers/databasesTable.js

@ -42,7 +42,7 @@ const DatabaseTable = (props) => {
const onEdit = (record) => { const onEdit = (record) => {
dispatch(metadataManagement.getMetadataModels({ modelTypes: ModelTypes })).then(res => { dispatch(metadataManagement.getMetadataModels({ modelTypes: ModelTypes })).then(res => {
if (res.success) { if (res.success) {
setEditData({ title: '修改库表元数据', record: { path: '/' + resourceCatalogPath.join('/'), ...record } }); setEditData({ title: '修改库表元数据', record: { path: '/' + resourceCatalogPath.join('/'), ...record, ...record.attributesParam } });
setModalVisible(true); setModalVisible(true);
} }
}) })
@ -178,25 +178,25 @@ const DatabaseTable = (props) => {
} }
//新建、修改 //新建、修改
const onConfirm = (values) => { const onConfirm = (values) => {
let obj = { ...values } let obj = {}
// if (editData.add) { if (editData.add) {
// obj = { ...values, ...editData.record || {} } obj = { createBy: user.id, catalog: resourceCatalogId, catalogKey: resourceCatalogKey, ...values }
// dispatch(metadataManagement.postResourceCatalog(obj)).then(() => { dispatch(metadataManagement.postMeatadataDatabases(obj)).then(() => {
// onSearch(); setModalVisible(false); onSearch(); setModalVisible(false);
// }); });
// } else { } else {
// dispatch(metadataManagement.putResourceCatalog(editData.record.id, obj)).then(() => { obj = { catalog: resourceCatalogId, catalogKey: resourceCatalogKey, ...values }
// onSearch(); setModalVisible(false); dispatch(metadataManagement.putMeatadataDatabases(editData.record.id, obj)).then(() => {
// }); onSearch(); setModalVisible(false);
// } });
}
} }
return <Spin spinning={isRequesting}> return <Spin spinning={isRequesting}>
< div style={{ marginBottom: 16 } <div style={{ marginBottom: 16 }}>
}>
<Button type='primary' onClick={() => { <Button type='primary' onClick={() => {
dispatch(metadataManagement.getMetadataModels({ modelTypes: ModelTypes })).then(res => { dispatch(metadataManagement.getMetadataModels({ modelTypes: ModelTypes })).then(res => {
if (res.success) { if (res.success) {
setEditData({ title: '新建库表元数据', record: { path: '/' + resourceCatalogPath.join('/') } }); setEditData({ add: true, title: '新建库表元数据', record: { path: '/' + resourceCatalogPath.join('/') } });
setModalVisible(true); setModalVisible(true);
} }
}) })
@ -255,7 +255,6 @@ const DatabaseTable = (props) => {
{ {
modalVisible ? modalVisible ?
<MetadataDatabaseModal <MetadataDatabaseModal
resourceCatalogPath={resourceCatalogPath}
modelTypes={ModelTypes.filter(m => m === '目录')} modelTypes={ModelTypes.filter(m => m === '目录')}
metadataModels={metadataModels.filter(m => m.modelType === '目录')} metadataModels={metadataModels.filter(m => m.modelType === '目录')}
editData={editData} editData={editData}

4
web/client/src/utils/webapi.js

@ -27,6 +27,10 @@ export const ApiTable = {
getMetadataFiles: 'metadata/files', getMetadataFiles: 'metadata/files',
getMetadataRestapis: 'metadata/restapis', getMetadataRestapis: 'metadata/restapis',
getMetadataModels: 'metadata/models', getMetadataModels: 'metadata/models',
//库表元数据增删改
postMeatadataDatabases: 'meatadata/databases',
putMeatadataDatabases: 'meatadata/databases/{id}',
delMeatadataDatabases: 'meatadata/databases/{id}',
//元数据采集-数据源管理 //元数据采集-数据源管理
pgCheckConnect: 'adapter/check/connect', pgCheckConnect: 'adapter/check/connect',

Loading…
Cancel
Save