Commit b2a56000 by zhaochengxiang

模型版本对比

parent aab96e06
import React from 'react';
import { Drawer, Tabs } from 'antd';
import VersionCompare from './VersionCompare';
const { TabPane } = Tabs;
const HistoryAndVersionDrawer = (props) => {
const { onCancel, visible, id } = props;
return (
<Drawer
title=''
placement="right"
closable={true}
width={1200}
onClose={() => {
onCancel && onCancel();
}}
visible={visible}
>
<Tabs defaultActiveKey="1" type="card" size='small'>
<TabPane tab="版本历史" key="1">
</TabPane>
<TabPane tab="版本对比" key="2">
<VersionCompare />
</TabPane>
</Tabs>
</Drawer>
);
}
export default HistoryAndVersionDrawer;
\ No newline at end of file
import React, { useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import { Space, Button, Tooltip, Modal, Divider, Pagination, Table } from 'antd'; import { Space, Button, Tooltip, Modal, Divider, Pagination, Table } from 'antd';
import { EditOutlined, DeleteOutlined } from '@ant-design/icons'; import { EditOutlined, DeleteOutlined, DownOutlined, UpOutlined, HistoryOutlined } from '@ant-design/icons';
import SmoothScroll from 'smooth-scroll'; import SmoothScroll from 'smooth-scroll';
import classnames from 'classnames';
import { dispatchLatest } from '../../../../model'; import { dispatchLatest } from '../../../../model';
import { showMessage, getQueryParam, paginate } from '../../../../util'; import { showMessage, getQueryParam, paginate } from '../../../../util';
...@@ -11,7 +12,7 @@ import './ModelTable.less'; ...@@ -11,7 +12,7 @@ import './ModelTable.less';
const ModelTable = (props) => { const ModelTable = (props) => {
const { data, onChange, onItemAction, onSelect, catalogId, keyword, onAutoCreateTable, offset = null } = props; const { data, onChange, onItemAction, onSelect, onHistory , catalogId, keyword, onAutoCreateTable, offset = null, modelId = null } = props;
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]); const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const columns = [ const columns = [
...@@ -80,16 +81,17 @@ const ModelTable = (props) => { ...@@ -80,16 +81,17 @@ const ModelTable = (props) => {
return ( return (
<Space size='small'> <Space size='small'>
{ {
record.editable && ( <React.Fragment>
<React.Fragment> <Tooltip placement='bottom' title={'修改'}>
<Tooltip placement='bottom' title={'修改'}> <Button icon={<EditOutlined />} size='small' disabled={!record.editable} onClick={() => { editItem(record); }} />
<Button icon={<EditOutlined />} size='small' onClick={() => { editItem(record); }} /> </Tooltip>
</Tooltip> <Tooltip placement='bottom' title={'删除'}>
<Tooltip placement='bottom' title={'删除'}> <Button icon={<DeleteOutlined />} size='small' disabled={!record.editable} onClick={() => { deleteItem(record); }} />
<Button icon={<DeleteOutlined />} size='small' onClick={() => { deleteItem(record); }} /> </Tooltip>
</Tooltip> <Tooltip placement='bottom' title={'版本历史'}>
</React.Fragment> <Button icon={<HistoryOutlined />} size='small' onClick={() => { historyItem(record); }} />
) </Tooltip>
</React.Fragment>
} }
{ {
(record?.state?.supportedActions||[]).length>0 && record?.state?.supportedActions.map((item, index) => { (record?.state?.supportedActions||[]).length>0 && record?.state?.supportedActions.map((item, index) => {
...@@ -234,6 +236,10 @@ const ModelTable = (props) => { ...@@ -234,6 +236,10 @@ const ModelTable = (props) => {
}); });
} }
const historyItem = (record) => {
onHistory && onHistory(record.id);
}
const onSelectChange = keys => { const onSelectChange = keys => {
setSelectedRowKeys(keys); setSelectedRowKeys(keys);
onSelect && onSelect(keys); onSelect && onSelect(keys);
...@@ -244,49 +250,63 @@ const ModelTable = (props) => { ...@@ -244,49 +250,63 @@ const ModelTable = (props) => {
onChange: onSelectChange, onChange: onSelectChange,
}; };
const AnchorRow = (props) => {
const id = props['data-row-key']||'';
return (
<tr id={`data-model-${id}`} {...props} style={{ backgroundColor: (id===anchorId)?'#e7f7ff':'transparent' }} />
);
}
const _data = paginate(data||[], pageNum, pageSize); const _data = paginate(data||[], pageNum, pageSize);
const classes = classnames('model-table', {
'model-table-sub': modelId
});
return ( return (
<div className='model-table'> <div className={classes}>
<Table <Table
components={{ rowSelection={modelId?null:rowSelection}
body: {
row: AnchorRow
}
}}
rowSelection={rowSelection}
columns={columns||[]} columns={columns||[]}
rowKey={'id'} rowKey={'id'}
dataSource={_data||[]} dataSource={_data||[]}
pagination={false} pagination={false}
sticky onRow={(record) => {
/> return {
<Pagination id: `data-model-${record.id}`,
className="text-center mt-3" style: { backgroundColor: (record.id===anchorId)?'#e7f7ff':'transparent' }
showSizeChanger }
showQuickJumper
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum, pageSize: _pageSize || 20 });
}} }}
onShowSizeChange={(_pageNum, _pageSize) => { expandable={{
setPagination({ pageNum: _pageNum || 1, pageSize: _pageSize }); expandedRowRender: record => <ModelTable
modelId={record.id}
{...props}
/>,
expandIcon: ({ expanded, onExpand, record }) => {
if (modelId) return null;
return expanded ? <UpOutlined onClick={e => onExpand(record, e)} /> : <DownOutlined onClick={e => onExpand(record, e)} />
},
rowExpandable: record => {
if (modelId) return false;
return true;
}
}} }}
current={pageNum} sticky={!modelId}
pageSize={pageSize}
defaultCurrent={1}
total={(data||[]).length}
pageSizeOptions={[10,20]}
showTotal={total => `共 ${total} 条`}
/> />
{
!modelId && <Pagination
className="text-center mt-3"
showSizeChanger
showQuickJumper
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum, pageSize: _pageSize || 20 });
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum || 1, pageSize: _pageSize });
}}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={(data||[]).length}
pageSizeOptions={[10,20]}
showTotal={total => `共 ${total} 条`}
/>
}
{ contextHolder } { contextHolder }
</div> </div>
); );
......
...@@ -14,4 +14,10 @@ ...@@ -14,4 +14,10 @@
.yy-divider-vertical { .yy-divider-vertical {
margin: 0 2px !important; margin: 0 2px !important;
} }
}
.model-table-sub {
.yy-table {
height: auto !important;
}
} }
\ No newline at end of file
import React, { useState } from 'react';
import { Form, Select } from 'antd';
const { Option } = Select;
const versions = [
't_branch-2021-09-24_08-49(当前版本)',
't_branch-2021-09-23_08-49',
't_branch-2021-09-22_08-49',
't_branch-2021-09-21_08-49',
];
const VersionCompare = (props) => {
const [ basicVersion, setBasicVersion ] = useState('');
const [ incVersion, setIncVersion ] = useState('');
const [ incVersions, setIncVersions ] = useState([]);
const onBasicChange = (value) => {
setBasicVersion(value);
setIncVersion('');
const index = (versions||[]).indexOf(value);
setIncVersions((versions||[]).slice(0, index));
}
const onIncChange = (value) => {
setIncVersion(value);
}
return (
<div>
<Form layout='inline'>
<Form.Item label='基线版本'>
<Select value={basicVersion} style={{ width: 300 }} onChange={onBasicChange} >
{
(versions||[]).map((version, index) => {
return (
<Option key={index} value={version||''} disabled={index===0}>{version||''}</Option>
);
})
}
</Select>
</Form.Item>
<Form.Item label='增量版本'>
<Select value={incVersion} style={{ width: 300 }} disabled={basicVersion===''} onChange={onIncChange}>
{
(incVersions||[]).map((version, index) => {
return (
<Option key={index} value={version||''}>{version||''}</Option>
);
})
}
</Select>
</Form.Item>
</Form>
</div>
);
}
export default VersionCompare;
\ No newline at end of file
...@@ -13,6 +13,7 @@ import ImportWordModal from './Component/ImportWordModal'; ...@@ -13,6 +13,7 @@ import ImportWordModal from './Component/ImportWordModal';
import ImportStockWordDrawer from './Component/ImportStockWordDrawer'; import ImportStockWordDrawer from './Component/ImportStockWordDrawer';
import ExportDDLModal from './Component/ExportDDLModal'; import ExportDDLModal from './Component/ExportDDLModal';
import RecatalogModal from './Component/RecatalogModal'; import RecatalogModal from './Component/RecatalogModal';
import HistoryAndVersionDrawer from './Component/HistoryAndVersionDrawer';
import { showMessage, showNotifaction } from '../../../util'; import { showMessage, showNotifaction } from '../../../util';
import { dispatch, dispatchLatest } from '../../../model'; import { dispatch, dispatchLatest } from '../../../model';
import { Action, CatalogId, ModelerId, Hints, ModelerData } from '../../../util/constant'; import { Action, CatalogId, ModelerId, Hints, ModelerData } from '../../../util/constant';
...@@ -35,6 +36,7 @@ class Model extends React.Component { ...@@ -35,6 +36,7 @@ class Model extends React.Component {
importStockWordDrawerVisible: false, importStockWordDrawerVisible: false,
exportDDLModalVisible: false, exportDDLModalVisible: false,
recatalogModalVisible: false, recatalogModalVisible: false,
historyAndVersionDrawerVisible: false,
catalogId: '', catalogId: '',
importModalAction: '', importModalAction: '',
importModalAddMode: '', importModalAddMode: '',
...@@ -67,7 +69,9 @@ class Model extends React.Component { ...@@ -67,7 +69,9 @@ class Model extends React.Component {
callback: data => { callback: data => {
this.setState({ this.setState({
loadingStates: false, loadingStates: false,
modelStates: [{ name: 'all', id: '', cnName: '所有状态' }, ...(data?.subCatalogs||[])] // modelStates: [{ name: 'all', id: '', cnName: '所有状态' }, ...(data?.subCatalogs||[])]
modelStates: data?.subCatalogs||[],
currentModelState: (data?.subCatalogs||[]).length>1?data?.subCatalogs[0].id:''
}); });
}, },
error: () => { error: () => {
...@@ -83,7 +87,7 @@ class Model extends React.Component { ...@@ -83,7 +87,7 @@ class Model extends React.Component {
onModelStateChange = (value) => { onModelStateChange = (value) => {
this.setState({ currentModelState: value }, () => { this.setState({ currentModelState: value }, () => {
this.setFilterData(); this.onTableChange();
}) })
} }
...@@ -99,7 +103,7 @@ class Model extends React.Component { ...@@ -99,7 +103,7 @@ class Model extends React.Component {
} }
onTableChange = () => { onTableChange = () => {
const { currentView, catalogId, keyword } = this.state; const { currentView, catalogId, keyword, currentModelState } = this.state;
this.setState({ loadingTableData: true }, () => { this.setState({ loadingTableData: true }, () => {
if (keyword === '') { if (keyword === '') {
...@@ -107,12 +111,11 @@ class Model extends React.Component { ...@@ -107,12 +111,11 @@ class Model extends React.Component {
dispatch({ dispatch({
type: 'datamodel.getCurrentDataModelCatalog', type: 'datamodel.getCurrentDataModelCatalog',
payload: { payload: {
easyDataModelerCatalogId: catalogId easyDataModelerCatalogId: catalogId,
stateId: currentModelState
}, },
callback: data => { callback: data => {
this.setState({ loadingTableData: false, tableData: data.easyDataModelerDataModels||[] }, () => { this.setState({ loadingTableData: false, tableData: data.easyDataModelerDataModels||[], filterTableData: data.easyDataModelerDataModels||[] });
this.setFilterData();
});
}, },
error: () => { error: () => {
this.setState({ loadingTableData: false }); this.setState({ loadingTableData: false });
...@@ -139,11 +142,10 @@ class Model extends React.Component { ...@@ -139,11 +142,10 @@ class Model extends React.Component {
type: 'datamodel.searchModel', type: 'datamodel.searchModel',
payload: { payload: {
term: keyword, term: keyword,
stateId: currentModelState
}, },
callback: data => { callback: data => {
this.setState({ loadingTableData: false, tableData: data||[] }, () => { this.setState({ loadingTableData: false, tableData: data||[], filterTableData: data||[] });
this.setFilterData();
});
}, },
error: () => { error: () => {
this.setState({ loadingTableData: false }); this.setState({ loadingTableData: false });
...@@ -166,6 +168,10 @@ class Model extends React.Component { ...@@ -166,6 +168,10 @@ class Model extends React.Component {
}); });
} }
onHistory = (id) => {
this.setState({ historyAndVersionDrawerVisible: true, modelerId: id });
}
onSearchInputChange = (e) => { onSearchInputChange = (e) => {
this.setState({ keyword: e.target.value||'', catalogId: '' }, () => { this.setState({ keyword: e.target.value||'', catalogId: '' }, () => {
if (e.target.value !== '') { if (e.target.value !== '') {
...@@ -389,6 +395,10 @@ class Model extends React.Component { ...@@ -389,6 +395,10 @@ class Model extends React.Component {
} }
} }
onHistoryAndVersionDrawerCancel = () => {
this.setState({ historyAndVersionDrawerVisible: false });
}
importStockModel = () => { importStockModel = () => {
this.setState({ importStockWordDrawerVisible: true }); this.setState({ importStockWordDrawerVisible: true });
} }
...@@ -433,7 +443,7 @@ class Model extends React.Component { ...@@ -433,7 +443,7 @@ class Model extends React.Component {
} }
render() { render() {
const { importModalVisible, catalogId, loadingTableData, selectModelerIds, keyword, filterTableData, selectModelerNames, importModalAddMode, exportDDLModalVisible, templateCURDDrawerVisible, wordTemplateModalVisible, constraintDetailDrawerVisible, importWordModalVisible, importStockWordDrawerVisible , loadingStates, modelStates, currentModelState, currentView, recatalogModalVisible, exportDDLModalReference, currentModel, offset } = this.state; const { importModalVisible, catalogId, loadingTableData, selectModelerIds, keyword, filterTableData, selectModelerNames, importModalAddMode, exportDDLModalVisible, templateCURDDrawerVisible, wordTemplateModalVisible, constraintDetailDrawerVisible, importWordModalVisible, importStockWordDrawerVisible , loadingStates, modelStates, currentModelState, currentView, recatalogModalVisible, exportDDLModalReference, currentModel, offset, historyAndVersionDrawerVisible, modelerId } = this.state;
const content = ( const content = (
<ModelTable <ModelTable
...@@ -445,6 +455,7 @@ class Model extends React.Component { ...@@ -445,6 +455,7 @@ class Model extends React.Component {
onSelect={this.onTableSelect} onSelect={this.onTableSelect}
onItemAction={this.onTableItemAction} onItemAction={this.onTableItemAction}
onAutoCreateTable={this.onAutoCreateTable} onAutoCreateTable={this.onAutoCreateTable}
onHistory={this.onHistory}
{...this.props} /> {...this.props} />
); );
...@@ -637,14 +648,17 @@ class Model extends React.Component { ...@@ -637,14 +648,17 @@ class Model extends React.Component {
} }
</AppContext.Consumer> </AppContext.Consumer>
<RecatalogModal <RecatalogModal
visible={recatalogModalVisible} visible={recatalogModalVisible}
ids={selectModelerIds} ids={selectModelerIds}
onCancel={this.onRecatalogModalCancel} onCancel={this.onRecatalogModalCancel}
> />
</RecatalogModal> <HistoryAndVersionDrawer
id={modelerId}
visible={historyAndVersionDrawerVisible}
onCancel={this.onHistoryAndVersionDrawerCancel}
/>
</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