Commit 61325f2f by zhaochengxiang

地图主题变更

parent f9643645
...@@ -7,9 +7,10 @@ const maxTextWidth = 160; ...@@ -7,9 +7,10 @@ const maxTextWidth = 160;
class Org extends React.Component { class Org extends React.Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const { childData, parentNodeId } = this.props; const { childData, parentNodeId, data } = this.props;
if (parentNodeId && parentNodeId!== prevProps.parentNodeId) { if (parentNodeId && parentNodeId!== prevProps.parentNodeId) {
const parentData = this.graph?.findDataById(parentNodeId); const parentData = this.graph?.findDataById(parentNodeId);
if (!parentData.children) { if (!parentData.children) {
parentData.children = []; parentData.children = [];
...@@ -23,7 +24,7 @@ class Org extends React.Component { ...@@ -23,7 +24,7 @@ class Org extends React.Component {
collapsed: false, collapsed: false,
}); });
} else if (this.props.data && parentNodeId===null) { } else if (data && data !== prevProps.data && parentNodeId===null) {
this.graph?.destroy(); this.graph?.destroy();
this.graph = init(this)(this.elem, this.props.data); this.graph = init(this)(this.elem, this.props.data);
} }
......
...@@ -29,7 +29,7 @@ const EXPAND_ICON = function EXPAND_ICON(x, y, r) { ...@@ -29,7 +29,7 @@ const EXPAND_ICON = function EXPAND_ICON(x, y, r) {
class Tree extends React.Component { class Tree extends React.Component {
componentDidUpdate(prevProps, prevState){ componentDidUpdate(prevProps, prevState){
const { childData, parentNodeId } = this.props; const { childData, parentNodeId, data } = this.props;
if (parentNodeId && parentNodeId!== prevProps.parentNodeId) { if (parentNodeId && parentNodeId!== prevProps.parentNodeId) {
const parentData = this.graph?.findDataById(parentNodeId); const parentData = this.graph?.findDataById(parentNodeId);
...@@ -45,7 +45,7 @@ class Tree extends React.Component { ...@@ -45,7 +45,7 @@ class Tree extends React.Component {
collapsed: false, collapsed: false,
}); });
} else if (this.props.data && parentNodeId===null) { } else if (data && data !== prevProps.data && parentNodeId===null) {
this.graph?.destroy(); this.graph?.destroy();
this.graph = init(this)(this.elem, this.props.data); this.graph = init(this)(this.elem, this.props.data);
} }
......
...@@ -41,10 +41,14 @@ class MapContent extends React.Component { ...@@ -41,10 +41,14 @@ class MapContent extends React.Component {
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const { type } = this.props; const { type, topic } = this.props;
const { currentLevel } = this.state; const { currentLevel } = this.state;
if (type !== prevProps.type) { if (topic !== prevProps.topic) {
this.setState({ curTableModelData: [], parentNodeId: null, orgModelData: null, treeModelData: null, relationModelData: null }, () => {
this.getTreeTotalLevelThenQueryAllDirectoryAsTreeByDirLevel();
})
} else if (type !== prevProps.type) {
this.setState({ parentNodeId: null, orgModelData: null, treeModelData: null, relationModelData: null }, () => { this.setState({ parentNodeId: null, orgModelData: null, treeModelData: null, relationModelData: null }, () => {
if (type !== 'square') { if (type !== 'square') {
this.getTreeTotalLevelThenQueryAllDirectoryAsTreeByDirLevel(false, currentLevel); this.getTreeTotalLevelThenQueryAllDirectoryAsTreeByDirLevel(false, currentLevel);
...@@ -97,6 +101,8 @@ class MapContent extends React.Component { ...@@ -97,6 +101,8 @@ class MapContent extends React.Component {
const _curTableModelData = (_treeData.children||[]).filter(item => item.dbType!=='More'); const _curTableModelData = (_treeData.children||[]).filter(item => item.dbType!=='More');
if (first) { if (first) {
this.loadedRowsMap = {};
this.setState({ this.setState({
curTableModelData: _curTableModelData, curTableModelData: _curTableModelData,
breadcrumbContents: [{ data: _treeData }], breadcrumbContents: [{ data: _treeData }],
......
import React from 'react'; import React from 'react';
import { Tabs, Spin, Radio, Tooltip } from 'antd'; import { Spin, Radio, Tooltip, Tag } from 'antd';
import MapContent from './MapContent'; import MapContent from './MapContent';
import { dispatchLatest } from '../../../model'; import { dispatchLatest } from '../../../model';
import './index.less'; import './index.less';
const { TabPane } = Tabs; const { CheckableTag } = Tag;
const graphModes = [ const graphModes = [
{ {
...@@ -34,7 +34,9 @@ class Map extends React.Component { ...@@ -34,7 +34,9 @@ class Map extends React.Component {
type: 'square', type: 'square',
tabKey: '', tabKey: '',
loadingTopics: false, loadingTopics: false,
topics: null resourceTopics: null,
assetTopics: null,
selectedTopic: {}
}; };
} }
...@@ -47,8 +49,9 @@ class Map extends React.Component { ...@@ -47,8 +49,9 @@ class Map extends React.Component {
callback: data => { callback: data => {
this.setState({ this.setState({
loadingTopics: false, loadingTopics: false,
topics: data || [], resourceTopics: (data||[]).filter(item=>(item.code==='001'||item.code==='002')),
tabKey: (data || []).length > 0 ? data[0].id : '', assetTopics: (data||[]).filter(item=>(item.code!=='001'&&item.code!=='002')),
selectedTopic: (data||[]).length>0?data[0]:{}
}); });
}, },
error: () => { error: () => {
...@@ -66,8 +69,14 @@ class Map extends React.Component { ...@@ -66,8 +69,14 @@ class Map extends React.Component {
this.setState({ tabKey: activeKey }); this.setState({ tabKey: activeKey });
} }
onTagChange = (item, checked) => {
if (checked) {
this.setState({ selectedTopic: item });
}
}
render() { render() {
const { type, tabKey, topics, loadingTopics } = this.state; const { type, resourceTopics, assetTopics, loadingTopics, selectedTopic } = this.state;
const switchMode = <div className=''> const switchMode = <div className=''>
<Radio.Group <Radio.Group
...@@ -91,28 +100,52 @@ class Map extends React.Component { ...@@ -91,28 +100,52 @@ class Map extends React.Component {
<div className='asset-map' style={{ backgroundColor: '#fff' }}> <div className='asset-map' style={{ backgroundColor: '#fff' }}>
{ {
loadingTopics ? <Spin /> : <> loadingTopics ? <Spin /> : <>
{ <div
topics && topics.length > 0 && <Tabs animated={false} className='flex'
activeKey={tabKey} style={{
size='large' alignItems: 'center',
centered justifyContent: 'space-between',
onChange={this.onTabChange} height: 64,
> borderBottom: '1px solid #f0f0f0',
margin: '0px 10px'
}}
>
<div>
<span>数据资源: </span>
{
resourceTopics && resourceTopics.map(item => {
return (
<CheckableTag
key={item.id}
checked={selectedTopic?.id===item.id}
onChange={checked => this.onTagChange(item, checked)}
>
{item.name}
</CheckableTag>
);
})
}
</div>
<div>
<span>数据资产: </span>
{ {
topics && topics.map((topic) => { assetTopics && assetTopics.map(item => {
return ( return (
<TabPane tab={topic.name || ''} key={topic.id || ''}> <CheckableTag
{ key={item.id}
tabKey === topic.id && <div className='map-container' > checked={selectedTopic?.id===item.id}
<MapContent type={type} topic={topic} switchMode={switchMode} {...this.props} /> onChange={checked => this.onTagChange(item, checked)}
</div> >
} {item.name}
</TabPane> </CheckableTag>
); );
}) })
} }
</Tabs> </div>
} </div>
<div className='map-container' >
<MapContent type={type} topic={selectedTopic} switchMode={switchMode} {...this.props} />
</div>
</> </>
} }
</div> </div>
......
...@@ -4,12 +4,13 @@ ...@@ -4,12 +4,13 @@
height: calc(100vh - @header-height - @pm-4); height: calc(100vh - @header-height - @pm-4);
.yy-tabs-nav { .yy-tag {
margin: 0 !important; font-size: 14px;
margin-right: 2px;
} }
.map-container { .map-container {
height: calc(100vh - @header-height - @pm-4 - 57px/* - 53px */) !important; height: calc(100vh - @header-height - @pm-4 - 64px) !important;
overflow: auto !important; overflow: auto !important;
} }
} }
\ No newline at end of file
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