Commit 12bc56c5 by zhaochengxiang

Merge branch 'dev-2106' into 'master'

Dev 2106

See merge request !1
parents d8648343 5ce9dced
...@@ -196,6 +196,8 @@ G6.registerNode( ...@@ -196,6 +196,8 @@ G6.registerNode(
visible: false, visible: false,
}); });
} }
width1 = r * 2.5
width2 = r * 4
if (depthCount[cfg.depth] > 10) { if (depthCount[cfg.depth] > 10) {
group.addShape('image', { group.addShape('image', {
......
import React from 'react'; import React from 'react';
import { Row, Col, Breadcrumb, Slider } from 'antd'; import { Row, Col, Breadcrumb, Slider, Select, Typography } from 'antd';
import { HomeOutlined } from '@ant-design/icons'; import { HomeOutlined } from '@ant-design/icons';
import SquareItem from './Component/SquareItem'; import SquareItem from './Component/SquareItem';
...@@ -33,7 +33,7 @@ class MapContent extends React.Component { ...@@ -33,7 +33,7 @@ class MapContent extends React.Component {
this.getTreeTotalLevelThenQueryAllDirectoryAsTreeByDirLevel(); this.getTreeTotalLevelThenQueryAllDirectoryAsTreeByDirLevel();
} }
componentDidUpdate(prevProps, prevState){ componentDidUpdate(prevProps, prevState) {
const { type } = this.props; const { type } = this.props;
if (type !== prevProps.type) { if (type !== prevProps.type) {
...@@ -50,10 +50,10 @@ class MapContent extends React.Component { ...@@ -50,10 +50,10 @@ 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 = (_totalLevel < 3 ? _totalLevel : 3);
this.setState({ totalLevel: _totalLevel, currentLevel: _currentLevel }, () => { this.setState({ totalLevel: _totalLevel, currentLevel: _currentLevel }, () => {
this.queryAllDirectoryAsTreeByDirLevel(_currentLevel-1); this.queryAllDirectoryAsTreeByDirLevel(_currentLevel - 1);
}); });
} }
}) })
...@@ -68,11 +68,11 @@ class MapContent extends React.Component { ...@@ -68,11 +68,11 @@ class MapContent extends React.Component {
callback: data => { callback: data => {
this.convertRemoteData(data); this.convertRemoteData(data);
const _treeData = this.convertTreeModelData(data||[]); const _treeData = this.convertTreeModelData(data || []);
this.setState({ this.setState({
curTableModelData: data||[], curTableModelData: data || [],
breadcrumbContents: [{ data: data||[] }], breadcrumbContents: [{ data: data || [] }],
//深拷贝 //深拷贝
orgModelData: JSON.parse(JSON.stringify(_treeData)), orgModelData: JSON.parse(JSON.stringify(_treeData)),
treeModelData: JSON.parse(JSON.stringify(_treeData)), treeModelData: JSON.parse(JSON.stringify(_treeData)),
...@@ -82,26 +82,26 @@ class MapContent extends React.Component { ...@@ -82,26 +82,26 @@ class MapContent extends React.Component {
}) })
} }
convertRemoteData = (data, parentDirId='') => { convertRemoteData = (data, parentDirId = '') => {
data.forEach((item, index) => { data.forEach((item, index) => {
if (item.dbType==='Dir') { if (item.dbType === 'Dir') {
item.text = item.dirName||''; item.text = item.dirName || '';
item.id = `d${parentDirId}${item.dirId||''}${index}`; item.id = `d${parentDirId}${item.dirId || ''}${index}`;
} else { } else {
let assetCnName = ''; let assetCnName = '';
(item.elements||[]).forEach(element => { (item.elements || []).forEach(element => {
if (element.name === '中文名称') { if (element.name === '中文名称') {
assetCnName = element.value; assetCnName = element.value;
} }
}) })
item.text = assetCnName||''; item.text = assetCnName || '';
item.id = `t${parentDirId}${item.id||''}${index}`; item.id = `t${parentDirId}${item.id || ''}${index}`;
} }
if (item.children) { if (item.children) {
this.convertRemoteData(item.children, item.dirId||''); this.convertRemoteData(item.children, item.dirId || '');
} }
}) })
} }
...@@ -110,7 +110,7 @@ class MapContent extends React.Component { ...@@ -110,7 +110,7 @@ class MapContent extends React.Component {
const { topic } = this.props; const { topic } = this.props;
return { return {
text: topic.name||'', text: topic.name || '',
id: `t${topic.id}`, id: `t${topic.id}`,
dbType: 'Root', dbType: 'Root',
children: data children: data
...@@ -121,8 +121,8 @@ class MapContent extends React.Component { ...@@ -121,8 +121,8 @@ class MapContent extends React.Component {
const { breadcrumbContents } = this.state; const { breadcrumbContents } = this.state;
this.setState({ this.setState({
breadcrumbContents: [...breadcrumbContents, { name: item.dirName||'', data: item.children||[] }], breadcrumbContents: [...breadcrumbContents, { name: item.dirName || '', data: item.children || [] }],
curTableModelData: item.children||[], curTableModelData: item.children || [],
}); });
} }
...@@ -133,8 +133,8 @@ class MapContent extends React.Component { ...@@ -133,8 +133,8 @@ class MapContent extends React.Component {
payload: { dirId: item.dirId }, payload: { dirId: item.dirId },
callback: data => { callback: data => {
this.convertRemoteData(data||[], item.dirId); this.convertRemoteData(data || [], item.dirId);
item.children = (data||[]); item.children = (data || []);
this.setSquareGraphState(item); this.setSquareGraphState(item);
} }
}) })
...@@ -148,8 +148,8 @@ class MapContent extends React.Component { ...@@ -148,8 +148,8 @@ class MapContent extends React.Component {
const { breadcrumbContents } = this.state; const { breadcrumbContents } = this.state;
this.setState({ this.setState({
breadcrumbContents: breadcrumbContents.splice(0, index===0?1:(index+1)), breadcrumbContents: breadcrumbContents.splice(0, index === 0 ? 1 : (index + 1)),
curTableModelData: content.data||[], curTableModelData: content.data || [],
}) })
} }
...@@ -158,11 +158,11 @@ class MapContent extends React.Component { ...@@ -158,11 +158,11 @@ class MapContent extends React.Component {
type: 'map.getTableModelByDirIid', type: 'map.getTableModelByDirIid',
payload: { dirId }, payload: { dirId },
callback: data => { callback: data => {
this.convertRemoteData(data||[], dirId); this.convertRemoteData(data || [], dirId);
this.setState({ this.setState({
parentNodeId: nodeId, parentNodeId: nodeId,
orgChildData: JSON.parse(JSON.stringify(data||[])), orgChildData: JSON.parse(JSON.stringify(data || [])),
treeChildData: JSON.parse(JSON.stringify(data||[])), treeChildData: JSON.parse(JSON.stringify(data || [])),
relationChildData: JSON.parse(JSON.stringify(data)), relationChildData: JSON.parse(JSON.stringify(data)),
}); });
} }
...@@ -171,34 +171,36 @@ class MapContent extends React.Component { ...@@ -171,34 +171,36 @@ class MapContent extends React.Component {
onLevelChange = (value) => { onLevelChange = (value) => {
this.setState({ currentLevel: value }, () => { this.setState({ currentLevel: value }, () => {
this.queryAllDirectoryAsTreeByDirLevel(value-1); this.queryAllDirectoryAsTreeByDirLevel(value - 1);
}); });
} }
render() { render() {
const { type, topic } = this.props; const { type, topic, switchMode } = this.props;
const { curTableModelData, breadcrumbContents, orgModelData , treeModelData, relationModelData, orgChildData, treeChildData, relationChildData, parentNodeId, currentLevel, totalLevel } = this.state; const { curTableModelData, breadcrumbContents, orgModelData, treeModelData, relationModelData, orgChildData, treeChildData, relationChildData, parentNodeId, currentLevel, totalLevel } = this.state;
let groups = []; let groups = [];
if (curTableModelData) { if (curTableModelData) {
for(var i=0;i<curTableModelData.length;i+=column){ for (var i = 0; i < curTableModelData.length; i += column) {
groups.push(curTableModelData.slice(i,i+column)); groups.push(curTableModelData.slice(i, i + column));
} }
} }
if (type === 'square') {
return ( return (
<div className='position-relative' style={{ height: '100%' }}> <div className='position-relative p-3' style={{ height: '100%' }}>
{ {
type==='square' && <> type === 'square' && <>
<div className="text-right mb-3">{switchMode}</div>
{ {
breadcrumbContents && breadcrumbContents.length>1 && <Breadcrumb className='mb-3'> breadcrumbContents && breadcrumbContents.length > 1 && <Breadcrumb className='mb-3'>
{ {
breadcrumbContents.map((content, index) => { breadcrumbContents.map((content, index) => {
return ( return (
<Breadcrumb.Item key={index}> <Breadcrumb.Item key={index}>
{ {
index===0 ? <HomeOutlined onClick={() => { this.onBreadcrumbItemClick(content, index); }} /> : ((index===breadcrumbContents.length-1) ? <span>{content.name||''}</span> : <span className='pointer' onClick={() => { this.onBreadcrumbItemClick(content, index); }}> index === 0 ? <HomeOutlined onClick={() => { this.onBreadcrumbItemClick(content, index); }} /> : ((index === breadcrumbContents.length - 1) ? <span>{content.name || ''}</span> : <span className='pointer' onClick={() => { this.onBreadcrumbItemClick(content, index); }}>
{content.name||''} {content.name || ''}
</span>) </span>)
} }
</Breadcrumb.Item> </Breadcrumb.Item>
...@@ -211,65 +213,82 @@ class MapContent extends React.Component { ...@@ -211,65 +213,82 @@ class MapContent extends React.Component {
groups && groups.map((group, index) => { groups && groups.map((group, index) => {
return ( return (
<div key={index}> <div key={index}>
<Row gutter={10} className={index===0?'':'mt-3'}> <Row gutter={10} className={index === 0 ? '' : 'mt-3'}>
{ {
group && group.map((item, _index) => { group && group.map((item, _index) => {
return ( return (
<Col key={_index} span={24/column}> <Col key={_index} span={24 / column}>
<SquareItem item={item} index={(index*column+_index)} onClick={this.onSquareItemClick} {...this.props} /> <SquareItem item={item} index={(index * column + _index)} onClick={this.onSquareItemClick} {...this.props} />
</Col> </Col>
) )
}) })
} }
</Row> </Row>
{ (index===groups.length-1) && <div style={{ height: 10 }} /> } { (index === groups.length - 1) && <div style={{ height: 10 }} />}
</div> </div>
) )
}) })
} }
</> </>
} }
</div>
);
} else {
return (
<div className='position-relative' style={{ height: '100%', overflow: 'hidden', backgroundImage: 'linear-gradient(to bottom left,#2e3b4e,#0d0d13 52%,#0d0d13)' }}>
{ {
type==='org' && <Org type === 'org' && <Org
data={orgModelData} data={orgModelData}
parentNodeId={parentNodeId} parentNodeId={parentNodeId}
childData={orgChildData} childData={orgChildData}
type={`${topic.id||''}${type}`} type={`${topic.id || ''}${type}`}
loadMoreData={this.loadMoreData} loadMoreData={this.loadMoreData}
/> />
} }
{ {
type==='tree' && <Tree type === 'tree' && <Tree
data={treeModelData} data={treeModelData}
parentNodeId={parentNodeId} parentNodeId={parentNodeId}
childData={treeChildData} childData={treeChildData}
type={`${topic.id||''}${type}`} type={`${topic.id || ''}${type}`}
loadMoreData={this.loadMoreData} /> loadMoreData={this.loadMoreData} />
} }
{ {
type==='relation' && <Relation type === 'relation' && <Relation
data={relationModelData} data={relationModelData}
parentNodeId={parentNodeId} parentNodeId={parentNodeId}
childData={relationChildData} childData={relationChildData}
type={`${topic.id||''}${type}`} type={`${topic.id || ''}${type}`}
loadMoreData={this.loadMoreData} /> loadMoreData={this.loadMoreData} />
} }
{ <div
type!=='square' && <div className='position-absolute text-right p-3'
className='position-absolute'
style={{ style={{
display: 'inline-block', display: 'block',
height: 60, right: 0,
right: 15, top: 0
top: 15
}} }}
> >
<span>层数</span> {switchMode}
<Slider vertical min={1} max={totalLevel} value={currentLevel} onChange={this.onLevelChange} /> <div className="mt-3">
<Typography.Text className="mr-2" style={{ color: '#fff' }}>层数</Typography.Text>
{/* <Slider vertical min={1} max={totalLevel} value={currentLevel} onChange={this.onLevelChange} /> */}
<Select value={currentLevel} onChange={this.onLevelChange} size="small">
{Array.from(new Array(totalLevel)).map((_, i) => <Select.Option key={i} value={i}>{i}</Select.Option>)}
</Select>
</div> </div>
}
</div> </div>
);
<div id="left-control-container"></div>
<div id="right-control-container"></div>
<div id="bottom-bg-container"></div>
</div>
)
}
} }
} }
......
...@@ -47,8 +47,8 @@ class Map extends React.Component { ...@@ -47,8 +47,8 @@ class Map extends React.Component {
callback: data => { callback: data => {
this.setState({ this.setState({
loadingTopics: false, loadingTopics: false,
topics: data||[], topics: data || [],
tabKey: (data||[]).length>0?data[0].id:'', tabKey: (data || []).length > 0 ? data[0].id : '',
}); });
}, },
error: () => { error: () => {
...@@ -68,12 +68,31 @@ class Map extends React.Component { ...@@ -68,12 +68,31 @@ class Map extends React.Component {
render() { render() {
const { type, tabKey, topics, loadingTopics } = this.state; const { type, tabKey, topics, loadingTopics } = this.state;
const switchMode = <div className=''>
<Radio.Group
value={type}
onChange={this.onTypeChange} size="small"
>
{
graphModes && graphModes.map((mode, index) => {
return (
<Tooltip key={index} title={mode.title || ''} >
<Radio.Button value={mode.key}>{(mode.title || '').substring(0, 1)}</Radio.Button>
</Tooltip>
);
})
}
</Radio.Group>
</div>
return ( return (
<div className='asset-map' style={{ backgroundColor: '#fff' }}> <div className='asset-map' style={{ backgroundColor: '#fff' }}>
{ {
loadingTopics ? <Spin /> : <> loadingTopics ? <Spin /> : <>
{ {
topics && topics.length>0 && <Tabs topics && topics.length > 0 && <Tabs
activeKey={tabKey} activeKey={tabKey}
size='large' size='large'
centered centered
...@@ -82,27 +101,10 @@ class Map extends React.Component { ...@@ -82,27 +101,10 @@ class Map extends React.Component {
{ {
topics && topics.map((topic) => { topics && topics.map((topic) => {
return ( return (
<TabPane tab={topic.name||''} key={topic.id||''}> <TabPane tab={topic.name || ''} key={topic.id || ''}>
<div className='d-flex px-3' style={{ height: 53, alignItems: 'center' }}>
<Radio.Group
value={type}
onChange={this.onTypeChange}
style={{ marginLeft: 'auto' }}
>
{
graphModes && graphModes.map((mode, index) => {
return (
<Tooltip key={index} title={mode.title||''} >
<Radio.Button value={mode.key}>{(mode.title||'').substring(0, 1)}</Radio.Button>
</Tooltip>
);
})
}
</Radio.Group>
</div>
{ {
tabKey===topic.id && <div className='map-container' style={{ padding: '0 10px' }}> tabKey === topic.id && <div className='map-container' >
<MapContent type={type} topic={topic} {...this.props} /> <MapContent type={type} topic={topic} switchMode={switchMode} {...this.props} />
</div> </div>
} }
</TabPane> </TabPane>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
} }
.map-container { .map-container {
height: calc(100vh - 64px - 30px - 57px - 53px) !important; height: calc(100vh - 64px - 30px - 57px/* - 53px */) !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