From 43d30da6beae109fea7862ca83663d2df357dfcc Mon Sep 17 00:00:00 2001 From: zhangminghua Date: Tue, 28 Mar 2023 09:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E4=BA=A4=E5=BA=93=E8=A1=A8=E5=85=83?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=96=B0=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metadataManagement/actions/metadata.js | 39 ++++++++++++++++++- .../components/metadataDatabModal.js | 12 ++++-- .../containers/databasesTable.js | 31 +++++++-------- web/client/src/utils/webapi.js | 4 ++ 4 files changed, 66 insertions(+), 20 deletions(-) diff --git a/web/client/src/sections/metadataManagement/actions/metadata.js b/web/client/src/sections/metadataManagement/actions/metadata.js index 3facb45..c2aa252 100644 --- a/web/client/src/sections/metadataManagement/actions/metadata.js +++ b/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: '删除库表元数据', + } + }); } \ No newline at end of file diff --git a/web/client/src/sections/metadataManagement/components/metadataDatabModal.js b/web/client/src/sections/metadataManagement/components/metadataDatabModal.js index 4991dc8..4c26378 100644 --- a/web/client/src/sections/metadataManagement/components/metadataDatabModal.js +++ b/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}> - + } else { return { 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 - < div style={{ marginBottom: 16 } - }> +