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) } }}