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,
actionType: 'POST_RESOURCE_CATALOG',
url: ApiTable.postResourceCatalog,
msg: { option: '新资源目录' },
msg: { option: '新资源目录' },
reducer: {}
});
}
@ -98,4 +98,41 @@ export function getMetadataModels(params) {
msg: { error: '获取元数据模型失败' },
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';
const { TextArea } = Input;
const MetadataDatabaseModal = (props) => {
const { onConfirm, onCancel, editData, metadataModels, modelTypes, resourceCatalogPath } = props;
const { onConfirm, onCancel, editData, metadataModels, modelTypes } = props;
const [form] = Form.useForm();
useEffect(() => {
}, []);
const handleOk = () => {
form.validateFields().then(values => {
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}
name={m.attributeCode}
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>
} else {
return <Form.Item

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

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

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

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

Loading…
Cancel
Save