Commit 695f0762 by zhaochengxiang

优化地图样式

parent 385aee2a
...@@ -52,9 +52,11 @@ class Relation extends React.Component { ...@@ -52,9 +52,11 @@ class Relation extends React.Component {
render() { render() {
const { styles } = this.props;
return ( return (
<React.Fragment> <React.Fragment>
<div ref={ref => this.elem = ref} style={{ width: '100%', height: '100%', }}> <div ref={ref => this.elem = ref} style={styles}>
</div> </div>
</React.Fragment> </React.Fragment>
...@@ -267,7 +269,7 @@ G6.registerNode( ...@@ -267,7 +269,7 @@ G6.registerNode(
fill: colors[cfg.depth % colors.length], fill: colors[cfg.depth % colors.length],
stroke: highlight, stroke: highlight,
lineWidth, lineWidth,
cursor: (cfg.dbType==='Dir')?'pointer':'default', cursor: (cfg.dbType==='Dir'||cfg.dbType==='More')?'pointer':'default',
}, },
name: 'aggregated-node-keyShape', name: 'aggregated-node-keyShape',
}); });
......
...@@ -28,7 +28,7 @@ class MapContent extends React.Component { ...@@ -28,7 +28,7 @@ class MapContent extends React.Component {
relationChildData: null, relationChildData: null,
parentNodeId: null, parentNodeId: null,
breadcrumbContents: null, breadcrumbContents: null,
currentLevel: 1, currentLevel: -1,
totalLevel: 1, totalLevel: 1,
haveMoreData: false, haveMoreData: false,
}; };
...@@ -42,13 +42,18 @@ class MapContent extends React.Component { ...@@ -42,13 +42,18 @@ class MapContent extends React.Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const { type } = this.props; const { type } = this.props;
const { currentLevel } = this.state;
if (type !== prevProps.type) { if (type !== prevProps.type) {
this.setState({ parentNodeId: '' }); this.setState({ parentNodeId: null, orgModelData: null, treeModelData: null, relationModelData: null }, () => {
if (type !== 'square') {
this.getTreeTotalLevelThenQueryAllDirectoryAsTreeByDirLevel(false, currentLevel);
}
});
} }
} }
getTreeTotalLevelThenQueryAllDirectoryAsTreeByDirLevel = () => { getTreeTotalLevelThenQueryAllDirectoryAsTreeByDirLevel = (first=true, defaultCurrentLevel=-1) => {
const { topic } = this.props; const { topic } = this.props;
dispatch({ dispatch({
...@@ -57,16 +62,16 @@ class MapContent extends React.Component { ...@@ -57,16 +62,16 @@ class MapContent extends React.Component {
callback: data => { callback: data => {
const _totalLevel = Number(data); const _totalLevel = Number(data);
const _currentLevel = (_totalLevel < 3 ? _totalLevel : 3); const _currentLevel = (defaultCurrentLevel===-1) ? (_totalLevel < 3 ? _totalLevel : 3) : defaultCurrentLevel;
this.setState({ totalLevel: _totalLevel, currentLevel: _currentLevel }, () => { this.setState({ totalLevel: _totalLevel, currentLevel: _currentLevel }, () => {
this.queryAllDirectoryAsTreeByDirLevel(_currentLevel - 1); this.queryAllDirectoryAsTreeByDirLevel(first, _currentLevel - 1);
}); });
} }
}) })
} }
queryAllDirectoryAsTreeByDirLevel = (level) => { queryAllDirectoryAsTreeByDirLevel = (first, level) => {
const { topic } = this.props; const { topic } = this.props;
dispatchLatest({ dispatchLatest({
...@@ -90,15 +95,23 @@ class MapContent extends React.Component { ...@@ -90,15 +95,23 @@ class MapContent extends React.Component {
const _curTableModelData = (_treeData.children||[]).filter(item => item.dbType!=='More'); const _curTableModelData = (_treeData.children||[]).filter(item => item.dbType!=='More');
this.setState({ if (first) {
curTableModelData: _curTableModelData, this.setState({
breadcrumbContents: [{ data: _treeData }], curTableModelData: _curTableModelData,
haveMoreData: (_curTableModelData||[]).length===defaultLoadCount, breadcrumbContents: [{ data: _treeData }],
//深拷贝 haveMoreData: (_curTableModelData||[]).length===defaultLoadCount,
orgModelData: JSON.parse(JSON.stringify(_treeData)), //深拷贝
treeModelData: JSON.parse(JSON.stringify(_treeData)), orgModelData: JSON.parse(JSON.stringify(_treeData)),
relationModelData: JSON.parse(JSON.stringify(_treeData)) treeModelData: JSON.parse(JSON.stringify(_treeData)),
}); relationModelData: JSON.parse(JSON.stringify(_treeData))
});
} else {
this.setState({
orgModelData: JSON.parse(JSON.stringify(_treeData)),
treeModelData: JSON.parse(JSON.stringify(_treeData)),
relationModelData: JSON.parse(JSON.stringify(_treeData))
});
}
} }
}) })
} }
...@@ -365,10 +378,10 @@ class MapContent extends React.Component { ...@@ -365,10 +378,10 @@ class MapContent extends React.Component {
data={orgModelData} data={orgModelData}
parentNodeId={parentNodeId} parentNodeId={parentNodeId}
childData={orgChildData} childData={orgChildData}
type={`${topic.id || ''}${type}`}
loadMoreLeafData={this.loadMoreLeafData} loadMoreLeafData={this.loadMoreLeafData}
loadSubLeafData={this.loadSubLeafData} loadSubLeafData={this.loadSubLeafData}
onAssetClick={this.onAssetClick} onAssetClick={this.onAssetClick}
styles={{ width: '100%', height: '100%' }}
/> />
} }
{ {
...@@ -376,10 +389,10 @@ class MapContent extends React.Component { ...@@ -376,10 +389,10 @@ class MapContent extends React.Component {
data={treeModelData} data={treeModelData}
parentNodeId={parentNodeId} parentNodeId={parentNodeId}
childData={treeChildData} childData={treeChildData}
type={`${topic.id || ''}${type}`}
loadMoreLeafData={this.loadMoreLeafData} loadMoreLeafData={this.loadMoreLeafData}
loadSubLeafData={this.loadSubLeafData} loadSubLeafData={this.loadSubLeafData}
onAssetClick={this.onAssetClick} onAssetClick={this.onAssetClick}
styles={{ width: '100%', height: '100%' }}
/> />
} }
{ {
...@@ -387,10 +400,10 @@ class MapContent extends React.Component { ...@@ -387,10 +400,10 @@ class MapContent extends React.Component {
data={relationModelData} data={relationModelData}
parentNodeId={parentNodeId} parentNodeId={parentNodeId}
childData={relationChildData} childData={relationChildData}
type={`${topic.id || ''}${type}`}
loadMoreLeafData={this.loadMoreLeafData} loadMoreLeafData={this.loadMoreLeafData}
loadSubLeafData={this.loadSubLeafData} loadSubLeafData={this.loadSubLeafData}
onAssetClick={this.onAssetClick} onAssetClick={this.onAssetClick}
styles={{ width: '100%', height: '100%' }}
/> />
} }
<div <div
......
...@@ -13,10 +13,10 @@ const graphModes = [ ...@@ -13,10 +13,10 @@ const graphModes = [
title: '方块图', title: '方块图',
key: 'square' key: 'square'
}, },
{ // {
title: '组织图', // title: '组织图',
key: 'org', // key: 'org',
}, // },
{ {
title: '树形图', title: '树形图',
key: 'tree', key: 'tree',
......
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