From 9bfba37bb65c6a4a5440fef404ba0ba8335519c9 Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Tue, 14 Mar 2023 10:56:50 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E6=A8=A1=E5=9E=8B=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/modelModal.js | 22 ++--- .../containers/metaModelManagement.js | 93 ++++++++++++------- 2 files changed, 69 insertions(+), 46 deletions(-) diff --git a/web/client/src/sections/metadataManagement/components/modelModal.js b/web/client/src/sections/metadataManagement/components/modelModal.js index 24efabc..e07ad64 100644 --- a/web/client/src/sections/metadataManagement/components/modelModal.js +++ b/web/client/src/sections/metadataManagement/components/modelModal.js @@ -40,20 +40,22 @@ export default (props) => { onFinish && await onFinish(values, editData) return true; }} - submitter={!readOnly} + // submitter={!readOnly} width={500} > @@ -64,28 +66,26 @@ export default (props) => { { label: '整型', value: '整型' }, { label: '字符型', value: '字符型' }, { label: '布尔型', value: '布尔型' },]} - disabled={readOnly || editData} name="dataType" label="数据类型" fieldProps={{ showSearch: true }} /> + - @@ -95,7 +95,6 @@ export default (props) => { options={[ { label: '是', value: true }, { label: '否', value: false }]} - disabled={readOnly || editData} name="nullable" label="是否允许为空" /> @@ -105,15 +104,14 @@ export default (props) => { options={[ { label: '是', value: true }, { label: '否', value: false }]} - disabled={readOnly || editData} name="readOnly" label="是否只读" /> diff --git a/web/client/src/sections/metadataManagement/containers/metaModelManagement.js b/web/client/src/sections/metadataManagement/containers/metaModelManagement.js index d9bd0c0..63d8be9 100644 --- a/web/client/src/sections/metadataManagement/containers/metaModelManagement.js +++ b/web/client/src/sections/metadataManagement/containers/metaModelManagement.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react' -import { Spin, Select, Tree, Row, Col, Button } from 'antd'; +import { Spin, Popconfirm, Tree, Row, Col, Button } from 'antd'; import { connect } from 'react-redux'; import ProTable from '@ant-design/pro-table'; import MetaModelModal from '../components/modelModal' @@ -11,6 +11,44 @@ function MetaModelManagement(props) { const [pageSize, setPageSize] = useState(10); const [currentPage, setCurrentPage] = useState(1); + 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 handleDelete = (id) => { + dispatch(actions.metadataManagement.deleteMetaModel(id)).then(() => { + queryData(); + }); + }; + + const onFinish = async (values, editData) => { + if (editData) { + const dataToSave = { ...values } + return dispatch( + actions.metadataManagement.modifyMetaModel(editData.id, dataToSave, values?.msg || ''), + ).then(() => { + queryData(); + }); + } + + return dispatch(actions.metadataManagement.addMetaModel({ + modelType: selectedKeys[0], + ...values, + })).then(() => { + queryData(); + }); + }; + const columns = [ { title: '属性名称', @@ -69,45 +107,31 @@ function MetaModelManagement(props) { valueType: 'option', render: (text, record) => { const options = []; + options.push(编辑} + editData={record} + title="编辑模型" + onFinish={onFinish} + key="editModel" + />) + + options.push( + handleDelete(record.id)} + okText="是" + cancelText="否" + > + 删除 + ) - options.push(删除) return options; }, }, ]; - - 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 @@ -117,6 +141,7 @@ function MetaModelManagement(props) { selectedKeys={selectedKeys} onSelect={(keys, e) => { if (e.selected) { + setCurrentPage(1); setSelectKeys(keys) } }}