diff --git a/api/app/lib/controllers/model-management/index.js b/api/app/lib/controllers/model-management/index.js
index 9d04d6f..1b4f0ce 100644
--- a/api/app/lib/controllers/model-management/index.js
+++ b/api/app/lib/controllers/model-management/index.js
@@ -7,7 +7,7 @@ function getModelManagementList(opts) {
const models = ctx.fs.dc.models;
const { page, limit, modelType } = ctx.query;
const Op = ctx.fs.dc.ORM.Op;
- let errMsg = { message: '获取监察任务失败' }
+ let errMsg = { message: '获取模型失败' }
try {
let searchWhere = {}
let option = {
@@ -40,7 +40,7 @@ function getModelManagementList(opts) {
}
}
-// 新增监察任务
+// 新增模型
function addModelManagement(opts) {
return async function (ctx, next) {
@@ -49,16 +49,16 @@ function addModelManagement(opts) {
let rslt = ctx.request.body;
await models.MetaModel.create(Object.assign({}, rslt))
ctx.status = 204;
- ctx.body = { message: '新建监察任务成功' }
+ ctx.body = { message: '新建模型成功' }
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
- ctx.body = { message: '新建监察任务失败' }
+ ctx.body = { message: '新建模型失败' }
}
}
}
-// 修改监察任务
+// 修改模型
function editModelManagement(opts) {
return async function (ctx, next) {
@@ -71,16 +71,16 @@ function editModelManagement(opts) {
{ where: { id: id, } }
)
ctx.status = 204;
- ctx.body = { message: '修改监察任务成功' }
+ ctx.body = { message: '修改模型成功' }
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
- ctx.body = { message: '修改监察任务失败' }
+ ctx.body = { message: '修改模型失败' }
}
}
}
-// 删除监察任务
+// 删除模型
function deleteModelManagement(opts) {
return async function (ctx, next) {
@@ -93,11 +93,11 @@ function deleteModelManagement(opts) {
}
})
ctx.status = 204;
- ctx.body = { message: '删除监察任务成功' }
+ ctx.body = { message: '删除模型成功' }
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
- ctx.body = { message: '删除监察任务失败' }
+ ctx.body = { message: '删除模型失败' }
}
}
}
diff --git a/web/client/src/sections/metadataManagement/actions/model.js b/web/client/src/sections/metadataManagement/actions/model.js
index 5dd01fb..16496e0 100644
--- a/web/client/src/sections/metadataManagement/actions/model.js
+++ b/web/client/src/sections/metadataManagement/actions/model.js
@@ -11,7 +11,7 @@ export function getMetaModelList(query) {
actionType: 'GET_METAMODEL_REPORT',
url: `${ApiTable.getMetaModelList}`,
msg: { error: '获取模型列表失败' },
- reducer: { name: 'rectification' }
+ reducer: { name: 'metaModel' }
});
}
diff --git a/web/client/src/sections/metadataManagement/components/modelModal.js b/web/client/src/sections/metadataManagement/components/modelModal.js
new file mode 100644
index 0000000..24efabc
--- /dev/null
+++ b/web/client/src/sections/metadataManagement/components/modelModal.js
@@ -0,0 +1,121 @@
+import React, { useState, useRef } from 'react';
+import { Button, Form, Row, Col, Table, Popconfirm, Input, message } from 'antd';
+import {
+ ModalForm,
+ ProFormRadio,
+ ProFormSelect,
+ ProFormTextArea,
+ ProFormDigit,
+ ProFormDependency,
+ ProFormText
+} from '@ant-design/pro-form';
+
+import moment from 'moment';
+
+export default (props) => {
+ const { title, triggerRender, editData = null, onFinish, readOnly, } = props;
+ const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 16 } };
+ const initialValues = editData ? {
+ ...editData,
+ } : {};
+
+ return (
+
+ {title || ''}
+
+ }
+ layout="horizontal"
+ grid={true}
+ {...formItemLayout}
+ modalProps={{
+ destroyOnClose: true,
+ onCancel: () => { },
+ // bodyStyle: { height: 800, overflowY: 'auto' }
+ }}
+ onFinish={async (values) => {
+ onFinish && await onFinish(values, editData)
+ return true;
+ }}
+ submitter={!readOnly}
+ width={500}
+
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
\ No newline at end of file
diff --git a/web/client/src/sections/metadataManagement/containers/metaModelManagement.js b/web/client/src/sections/metadataManagement/containers/metaModelManagement.js
index 4e2d7dd..d9bd0c0 100644
--- a/web/client/src/sections/metadataManagement/containers/metaModelManagement.js
+++ b/web/client/src/sections/metadataManagement/containers/metaModelManagement.js
@@ -2,11 +2,11 @@ import React, { useEffect, useState } from 'react'
import { Spin, Select, Tree, Row, Col, Button } from 'antd';
import { connect } from 'react-redux';
import ProTable from '@ant-design/pro-table';
-
+import MetaModelModal from '../components/modelModal'
const TreeNode = Tree.TreeNode;
const DATABASE_TYPE = ['目录', '库', '表', '字段', '主键', '外键', '索引'];
function MetaModelManagement(props) {
- const { loading, clientHeight } = props;
+ const { loading, clientHeight, actions, dispatch, metaModel } = props;
const [selectedKeys, setSelectKeys] = useState([DATABASE_TYPE[0]])
const [pageSize, setPageSize] = useState(10);
const [currentPage, setCurrentPage] = useState(1);
@@ -42,23 +42,19 @@ function MetaModelManagement(props) {
ellipsis: true,
search: false,
},
- {
- title: '小数位数',
- dataIndex: 'company',
- ellipsis: true,
- search: false,
- },
{
title: '允许为空',
- dataIndex: 'readOnly',
+ dataIndex: 'nullable',
ellipsis: true,
search: false,
+ render: (text, record) => record?.nullable ? '是' : '否'
},
{
title: '是否只读',
dataIndex: 'readOnly',
ellipsis: true,
search: false,
+ render: (text, record) => record?.readOnly ? '是' : '否'
},
{
title: '描述',
@@ -66,8 +62,6 @@ function MetaModelManagement(props) {
ellipsis: true,
search: false,
},
-
-
{
title: '操作',
width: 160,
@@ -83,6 +77,36 @@ function MetaModelManagement(props) {
},
];
+ const queryData = (search) => {
+ const query = {
+ limit: search ? 10 : pageSize || 10,
+ page: search ? 1 : currentPage || 1,
+ modelType: selectedKeys[0]
+ }
+
+ dispatch(actions.metadataManagement.getMetaModelList(query));
+ }
+
+ useEffect(() => {
+ queryData();
+ }, [pageSize, currentPage, selectedKeys]);
+
+ const onFinish = async (values, editData) => {
+ if (editData) {
+ return dispatch(
+ actions.metadataManagement.modifyMetaModel(editData.id, dataToSave, values?.msg || ''),
+ ).then(() => {
+ queryData();
+ });
+ }
+
+ return dispatch(actions.metadataManagement.addMetaModel({
+ modelType: selectedKeys[0],
+ ...values,
+ })).then(() => {
+ queryData();
+ });
+ };
return
@@ -123,7 +147,7 @@ function MetaModelManagement(props) {
}
}
pagination={{
- total: 0,
+ total: metaModel?.count,
showSizeChanger: true,
showQuickJumper: true,
current: currentPage,
@@ -143,8 +167,15 @@ function MetaModelManagement(props) {
}
}}
- dataSource={[]}
- headerTitle={}
+ dataSource={metaModel?.rows || []}
+ headerTitle={[
+ 新建}
+ title="新建模型"
+ onFinish={onFinish}
+ key="addModel"
+ />
+ ]}
options={false}
/>
@@ -155,12 +186,13 @@ function MetaModelManagement(props) {
function mapStateToProps(state) {
const {
- auth, global,
+ auth, global, metaModel
} = state;
return {
loading: auth.isRequesting,
clientHeight: global.clientHeight,
-
+ actions: global.actions,
+ metaModel: metaModel?.data || {}
};
}