Browse Source

(*)模型管理编辑删除功能提交

master
peng.peng 2 years ago
parent
commit
9bfba37bb6
  1. 22
      web/client/src/sections/metadataManagement/components/modelModal.js
  2. 93
      web/client/src/sections/metadataManagement/containers/metaModelManagement.js

22
web/client/src/sections/metadataManagement/components/modelModal.js

@ -40,20 +40,22 @@ export default (props) => {
onFinish && await onFinish(values, editData) onFinish && await onFinish(values, editData)
return true; return true;
}} }}
submitter={!readOnly} // submitter={!readOnly}
width={500} width={500}
> >
<ProFormText <ProFormText
rules={[{ required: true, message: '请输入属性名称' }]} rules={[{ required: true, message: '请输入属性名称' },
disabled={readOnly || editData} { max: 255, message: '属性名称长度不能大于255个字符' }
]}
name="attributeName" name="attributeName"
label="属性名称" label="属性名称"
/> />
<ProFormText <ProFormText
rules={[{ required: true, message: '请输入属性代码' }]} rules={[{ required: true, message: '请输入属性代码' },
disabled={readOnly || editData} { max: 255, message: '属性代码长度不能大于255个字符' }
]}
name="attributeCode" name="attributeCode"
label="属性代码" label="属性代码"
/> />
@ -64,28 +66,26 @@ export default (props) => {
{ label: '整型', value: '整型' }, { label: '整型', value: '整型' },
{ label: '字符型', value: '字符型' }, { label: '字符型', value: '字符型' },
{ label: '布尔型', value: '布尔型' },]} { label: '布尔型', value: '布尔型' },]}
disabled={readOnly || editData}
name="dataType" name="dataType"
label="数据类型" label="数据类型"
fieldProps={{ fieldProps={{
showSearch: true showSearch: true
}} }}
/> />
<ProFormDigit <ProFormDigit
disabled={readOnly || editData}
name="length" name="length"
label="长度" label="长度"
fieldProps={{ precision: 0 }} fieldProps={{ precision: 0 }}
/> />
<ProFormSelect <ProFormSelect
rules={[{ required: true, message: '请选择输入控件' }]} rules={[{ required: true, message: '请选择输入控件' }]}
options={[ options={[
{ label: '数字输入框', value: '数字输入框' }, { label: '数字输入框', value: '数字输入框' },
{ label: '文本框', value: '文本框' }, { label: '文本框', value: '文本框' },
{ label: '下拉框', value: '下拉框' }, { label: '下拉框', value: '下拉框' },
]} ]}
disabled={readOnly || editData}
name="control" name="control"
label="输入控件" label="输入控件"
/> />
@ -95,7 +95,6 @@ export default (props) => {
options={[ options={[
{ label: '是', value: true }, { label: '是', value: true },
{ label: '否', value: false }]} { label: '否', value: false }]}
disabled={readOnly || editData}
name="nullable" name="nullable"
label="是否允许为空" label="是否允许为空"
/> />
@ -105,15 +104,14 @@ export default (props) => {
options={[ options={[
{ label: '是', value: true }, { label: '是', value: true },
{ label: '否', value: false }]} { label: '否', value: false }]}
disabled={readOnly || editData}
name="readOnly" name="readOnly"
label="是否只读" label="是否只读"
/> />
<ProFormTextArea <ProFormTextArea
disabled={readOnly || editData}
name="description" name="description"
label="描述" label="描述"
rules={[{ max: 255, message: '描述长度不能大于255个字符' }]}
/> />
</ModalForm> </ModalForm>

93
web/client/src/sections/metadataManagement/containers/metaModelManagement.js

@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react' 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 { connect } from 'react-redux';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
import MetaModelModal from '../components/modelModal' import MetaModelModal from '../components/modelModal'
@ -11,6 +11,44 @@ function MetaModelManagement(props) {
const [pageSize, setPageSize] = useState(10); const [pageSize, setPageSize] = useState(10);
const [currentPage, setCurrentPage] = useState(1); 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 = [ const columns = [
{ {
title: '属性名称', title: '属性名称',
@ -69,45 +107,31 @@ function MetaModelManagement(props) {
valueType: 'option', valueType: 'option',
render: (text, record) => { render: (text, record) => {
const options = []; const options = [];
options.push(<MetaModelModal
triggerRender={<a>编辑</a>}
editData={record}
title="编辑模型"
onFinish={onFinish}
key="editModel"
/>)
options.push(
<Popconfirm
key="del"
placement="top"
title="是否确认删除该模型?"
onConfirm={() => handleDelete(record.id)}
okText="是"
cancelText="否"
>
<a>删除</a>
</Popconfirm>)
options.push(<a>删除</a>)
return options; 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 <Spin spinning={loading}> return <Spin spinning={loading}>
<Row> <Row>
<Col style={{ width: 240 }}> <Col style={{ width: 240 }}>
@ -117,6 +141,7 @@ function MetaModelManagement(props) {
selectedKeys={selectedKeys} selectedKeys={selectedKeys}
onSelect={(keys, e) => { onSelect={(keys, e) => {
if (e.selected) { if (e.selected) {
setCurrentPage(1);
setSelectKeys(keys) setSelectKeys(keys)
} }
}} }}

Loading…
Cancel
Save