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