Commit 7ba19260 by zhaochengxiang

增加模型导出

parent 4ed8fb32
...@@ -3,16 +3,12 @@ import { Modal, Radio, Button } from 'antd'; ...@@ -3,16 +3,12 @@ import { Modal, Radio, Button } from 'antd';
const modes = [ const modes = [
{ {
title: '导出DDL',
},
{
title: '导出Erwin',
},
{
title: '导出Excel', title: '导出Excel',
key: 'excel',
}, },
{ {
title: '导出模型文档' title: '导出Word',
key: 'word',
}, },
] ]
...@@ -21,36 +17,47 @@ class ExportModal extends React.Component { ...@@ -21,36 +17,47 @@ class ExportModal extends React.Component {
constructor() { constructor() {
super(); super();
this.state = { this.state = {
confirmLoading: false selectedKey: '',
} }
} }
onModeClick = (index) => { onModeClick = (e) => {
this.setState({ selectedKey: e.target.value });
} }
handleOk = () => { handleOk = () => {
const { onCancel } = this.props; const { onCancel, ids } = this.props;
const { selectedKey } = this.state;
if (selectedKey === 'excel') {
window.open(`/api/datamodeler/easyDataModelerExport/excel?ids=${ids.join(',')}`);
} else if (selectedKey === 'word') {
window.open(`/api/datamodeler/easyDataModelerExport/word?ids=${ids.join(',')}`);
}
if (onCancel) { this.reset();
onCancel(); onCancel && onCancel();
} }
reset = () => {
this.setState({ selectedKey: '' });
} }
render() { render() {
const { visible, onCancel } = this.props; const { visible, onCancel } = this.props;
const { confirmLoading } = this.state; const { selectedKey } = this.state;
return ( return (
<Modal <Modal
visible={visible} visible={visible}
title={"导出方式"} title={"导出方式"}
destroyOnClose
onOk={this.handleOk} onOk={this.handleOk}
onCancel={onCancel} onCancel={() => {
this.reset();
onCancel && onCancel();
}}
footer={[ footer={[
<Button <Button
key="0" key="0"
loading={confirmLoading}
type="primary" type="primary"
onClick={this.handleOk} onClick={this.handleOk}
> >
...@@ -58,11 +65,11 @@ class ExportModal extends React.Component { ...@@ -58,11 +65,11 @@ class ExportModal extends React.Component {
</Button> </Button>
]} ]}
> >
<Radio.Group> <Radio.Group value={selectedKey} onChange={this.onModeClick}>
{ {
modes && modes.map((mode, index) => { modes && modes.map((mode, index) => {
return ( return (
<Radio key={index} value={index}> <Radio key={mode.key||''} value={mode.key||''}>
{ mode.title||'' } { mode.title||'' }
</Radio> </Radio>
); );
......
import React, { useState } from "react"; import React, { useState, useEffect } from "react";
import { Table, Space, Button, Tooltip, Modal } from 'antd'; import { Table, Space, Button, Tooltip, Modal } from 'antd';
import { EditOutlined, CheckOutlined, ReconciliationOutlined, DeleteOutlined } from '@ant-design/icons'; import { EditOutlined, CheckOutlined, ReconciliationOutlined, DeleteOutlined } from '@ant-design/icons';
...@@ -8,11 +8,19 @@ import './ModelTable.less'; ...@@ -8,11 +8,19 @@ import './ModelTable.less';
const ModelTable = (props) => { const ModelTable = (props) => {
const { data, onChange, loading, onItemAction } = props; const { data, onChange, loading, onItemAction, onSelect, catalogId } = props;
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]); const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const [modal, contextHolder] = Modal.useModal(); const [modal, contextHolder] = Modal.useModal();
useEffect(() => {
setSelectedRowKeys([]);
onSelect && onSelect([]);
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ catalogId ]);
const columns = [ const columns = [
{ {
title: '模型名称', title: '模型名称',
...@@ -82,6 +90,7 @@ const ModelTable = (props) => { ...@@ -82,6 +90,7 @@ const ModelTable = (props) => {
const onSelectChange = keys => { const onSelectChange = keys => {
setSelectedRowKeys(keys); setSelectedRowKeys(keys);
onSelect && onSelect(keys);
}; };
const rowSelection = { const rowSelection = {
......
...@@ -89,7 +89,7 @@ const UpdateTreeItemModal = (props) => { ...@@ -89,7 +89,7 @@ const UpdateTreeItemModal = (props) => {
_action = item ? 'sub' : 'root'; _action = item ? 'sub' : 'root';
} }
form.setFields([{ name: 'name', errors: [] }, { name: 'remark', error: [] }]) form.setFields([{ name: 'name', errors: [] }, { name: 'remark', errors: [] }]);
if (type === 'add') { if (type === 'add') {
form.setFieldsValue({ action: _action, name: '', remark: '' }); form.setFieldsValue({ action: _action, name: '', remark: '' });
......
...@@ -19,11 +19,12 @@ class Model extends React.Component { ...@@ -19,11 +19,12 @@ class Model extends React.Component {
importModalAction: '', importModalAction: '',
tableData: [], tableData: [],
loadingTableData: false, loadingTableData: false,
selectModelerIds: [],
} }
} }
onTreeSelect = (key) => { onTreeSelect = (key) => {
this.setState({ catalogId: key }, () => { this.setState({ catalogId: key, selectModelerIds: [] }, () => {
if (!key || key==='') { if (!key || key==='') {
this.setState({ tableData: [] }); this.setState({ tableData: [] });
} else { } else {
...@@ -51,6 +52,10 @@ class Model extends React.Component { ...@@ -51,6 +52,10 @@ class Model extends React.Component {
}) })
} }
onTableSelect = (ids) => {
this.setState({ selectModelerIds: ids });
}
onTableItemAction = (id, action) => { onTableItemAction = (id, action) => {
this.setState({ importModalVisible: true, importModalAction: action, modelerId: id }); this.setState({ importModalVisible: true, importModalAction: action, modelerId: id });
} }
...@@ -66,6 +71,12 @@ class Model extends React.Component { ...@@ -66,6 +71,12 @@ class Model extends React.Component {
} }
onExportBtnClick = () => { onExportBtnClick = () => {
const { selectModelerIds } = this.state;
if ((selectModelerIds||[]).length === 0) {
showMessage('info', '请先选择模型');
return;
}
this.setState({ exportModalVisible: true }); this.setState({ exportModalVisible: true });
} }
...@@ -79,7 +90,7 @@ class Model extends React.Component { ...@@ -79,7 +90,7 @@ class Model extends React.Component {
} }
render() { render() {
const { importModalVisible, exportModalVisible, catalogId, importModalAction, tableData, loadingTableData, modelerId } = this.state; const { importModalVisible, exportModalVisible, catalogId, importModalAction, tableData, loadingTableData, modelerId, selectModelerIds } = this.state;
return ( return (
<div style={{ backgroundColor: '#ECEEF3', height: '100%' }}> <div style={{ backgroundColor: '#ECEEF3', height: '100%' }}>
...@@ -103,7 +114,7 @@ class Model extends React.Component { ...@@ -103,7 +114,7 @@ class Model extends React.Component {
<Button type="primary" className='ml-3' onClick={this.onExportBtnClick}>模型导出</Button> <Button type="primary" className='ml-3' onClick={this.onExportBtnClick}>模型导出</Button>
</div> </div>
<div className='p-3'> <div className='p-3'>
<ModelTable loading={loadingTableData} data={tableData} onChange={this.onTableChange} onItemAction={this.onTableItemAction} /> <ModelTable loading={loadingTableData} catalogId={catalogId} data={tableData} onChange={this.onTableChange} onSelect={this.onTableSelect} onItemAction={this.onTableItemAction} />
</div> </div>
</div> </div>
</Col> </Col>
...@@ -119,6 +130,7 @@ class Model extends React.Component { ...@@ -119,6 +130,7 @@ class Model extends React.Component {
<ExportModal <ExportModal
visible={exportModalVisible} visible={exportModalVisible}
ids={selectModelerIds}
onCancel={this.onExportModalCancel} onCancel={this.onExportModalCancel}
/> />
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment