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

93
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(<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;
},
},
];
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}>
<Row>
<Col style={{ width: 240 }}>
@ -117,6 +141,7 @@ function MetaModelManagement(props) {
selectedKeys={selectedKeys}
onSelect={(keys, e) => {
if (e.selected) {
setCurrentPage(1);
setSelectKeys(keys)
}
}}

Loading…
Cancel
Save