Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
35aa3780
Commit
35aa3780
authored
Mar 19, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据地图
parent
e1ac798f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
228 additions
and
78 deletions
+228
-78
Org.jsx
src/view/Manage/Map/Component/Org.jsx
+140
-0
Relation.jsx
src/view/Manage/Map/Component/Relation.jsx
+4
-3
Tree.jsx
src/view/Manage/Map/Component/Tree.jsx
+3
-1
MapContent.jsx
src/view/Manage/Map/MapContent.jsx
+79
-73
index.jsx
src/view/Manage/Map/index.jsx
+2
-1
No files found.
src/view/Manage/Map/Component/Org.jsx
0 → 100644
View file @
35aa3780
import
React
from
'react'
;
import
G6
from
'@antv/g6'
;
import
{
ContextPath
}
from
'../../../../util'
;
let
graph
=
null
;
class
Org
extends
React
.
Component
{
componentDidMount
()
{
const
{
type
,
loadMoreData
,
history
}
=
this
.
props
;
const
container
=
document
.
getElementById
(
`container
${
type
||
''
}
`
);
if
(
!
container
)
return
;
const
width
=
container
.
scrollWidth
;
const
height
=
container
.
scrollHeight
||
500
;
graph
=
new
G6
.
TreeGraph
({
container
:
`container
${
type
||
''
}
`
,
width
,
height
,
linkCenter
:
true
,
modes
:
{
default
:
[
{
type
:
'collapse-expand'
,
onChange
:
function
onChange
(
item
,
collapsed
)
{
const
data
=
item
.
get
(
'model'
);
data
.
collapsed
=
collapsed
;
return
true
;
},
},
'drag-canvas'
,
'zoom-canvas'
,
],
},
defaultNode
:
{
size
:
9
,
anchorPoints
:
[
[
0
,
0.5
],
[
1
,
0.5
],
],
},
defaultEdge
:
{
type
:
'cubic-horizontal'
,
},
layout
:
{
type
:
'compactBox'
,
direction
:
'TB'
,
getId
:
function
getId
(
d
)
{
return
d
.
id
;
},
getHeight
:
function
getHeight
()
{
return
16
;
},
getWidth
:
function
getWidth
()
{
return
16
;
},
getVGap
:
function
getVGap
()
{
return
80
;
},
getHGap
:
function
getHGap
()
{
return
20
;
},
},
});
graph
.
node
(
function
(
node
)
{
let
position
=
'right'
;
let
rotate
=
0
;
if
(
!
node
.
children
)
{
position
=
'bottom'
;
rotate
=
Math
.
PI
/
2
;
}
return
{
label
:
node
.
text
||
''
,
labelCfg
:
{
position
,
offset
:
5
,
style
:
{
rotate
,
textAlign
:
'start'
,
},
},
};
});
this
.
layoutGraph
();
graph
.
on
(
'node:click'
,
function
(
e
)
{
const
node
=
e
.
item
;
const
model
=
node
.
getModel
();
if
(
model
.
dbType
===
'Dir'
)
{
const
children
=
model
.
children
;
if
(
!
children
&&
loadMoreData
)
{
loadMoreData
(
model
.
dirId
||
''
);
}
}
else
{
//通过资产id跳转到资产详情页
// model.tableModelId
// history && history.push(`${ContextPath}/home`);
}
});
if
(
typeof
window
!==
'undefined'
)
{
window
.
onresize
=
()
=>
{
if
(
!
graph
||
graph
.
get
(
'destroyed'
))
return
;
if
(
!
container
||
!
container
.
scrollWidth
||
!
container
.
scrollHeight
)
return
;
graph
.
changeSize
(
container
.
scrollWidth
,
container
.
scrollHeight
);
};
}
}
layoutGraph
=
()
=>
{
const
{
data
}
=
this
.
props
;
if
(
graph
&&
data
){
graph
.
data
(
data
);
graph
.
render
();
graph
.
fitView
();
}
}
componentDidUpdate
(
prevProps
,
prevState
){
this
.
layoutGraph
();
}
render
()
{
const
{
type
}
=
this
.
props
;
return
(
<
div
id=
{
`container${type||''}`
}
style=
{
{
width
:
'100%'
,
height
:
'100%'
}
}
></
div
>
);
}
}
export
default
Org
;
\ No newline at end of file
src/view/Manage/Map/Component/Relation.jsx
View file @
35aa3780
...
@@ -5,7 +5,6 @@ import { ContextPath } from '../../../../util';
...
@@ -5,7 +5,6 @@ import { ContextPath } from '../../../../util';
const
colors
=
[
const
colors
=
[
'#BDD2FD'
,
'#BDD2FD'
,
'#BDEFDB'
,
'#C2C8D5'
,
'#C2C8D5'
,
'#FBE5A2'
,
'#FBE5A2'
,
'#F6C3B7'
,
'#F6C3B7'
,
...
@@ -27,7 +26,9 @@ class Relation extends React.Component {
...
@@ -27,7 +26,9 @@ class Relation extends React.Component {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
const
container
=
document
.
getElementById
(
`container
${
type
||
''
}
`
);
const
container
=
document
.
getElementById
(
`container
${
type
||
''
}
`
);
const
width
=
container
.
scrollWidth
;
if
(
!
container
)
return
;
const
width
=
container
.
scrollWidth
||
500
;
const
height
=
container
.
scrollHeight
||
500
;
const
height
=
container
.
scrollHeight
||
500
;
function
refreshDragedNodePosition
(
e
)
{
function
refreshDragedNodePosition
(
e
)
{
...
@@ -128,7 +129,7 @@ class Relation extends React.Component {
...
@@ -128,7 +129,7 @@ class Relation extends React.Component {
layoutGraph
=
()
=>
{
layoutGraph
=
()
=>
{
const
{
data
}
=
this
.
props
;
const
{
data
}
=
this
.
props
;
if
(
graph
){
if
(
graph
&&
data
){
const
fittingString
=
(
str
,
maxWidth
,
fontSize
)
=>
{
const
fittingString
=
(
str
,
maxWidth
,
fontSize
)
=>
{
const
ellipsis
=
'...'
;
const
ellipsis
=
'...'
;
const
ellipsisLength
=
G6
.
Util
.
getTextSize
(
ellipsis
,
fontSize
)[
0
];
const
ellipsisLength
=
G6
.
Util
.
getTextSize
(
ellipsis
,
fontSize
)[
0
];
...
...
src/view/Manage/Map/Component/Tree.jsx
View file @
35aa3780
...
@@ -11,6 +11,8 @@ class Tree extends React.Component {
...
@@ -11,6 +11,8 @@ class Tree extends React.Component {
const
{
type
,
loadMoreData
,
history
}
=
this
.
props
;
const
{
type
,
loadMoreData
,
history
}
=
this
.
props
;
const
container
=
document
.
getElementById
(
`container
${
type
||
''
}
`
);
const
container
=
document
.
getElementById
(
`container
${
type
||
''
}
`
);
if
(
!
container
)
return
;
const
width
=
container
.
scrollWidth
;
const
width
=
container
.
scrollWidth
;
const
height
=
container
.
scrollHeight
||
500
;
const
height
=
container
.
scrollHeight
||
500
;
graph
=
new
G6
.
TreeGraph
({
graph
=
new
G6
.
TreeGraph
({
...
@@ -91,7 +93,7 @@ class Tree extends React.Component {
...
@@ -91,7 +93,7 @@ class Tree extends React.Component {
layoutGraph
=
()
=>
{
layoutGraph
=
()
=>
{
const
{
data
}
=
this
.
props
;
const
{
data
}
=
this
.
props
;
if
(
graph
){
if
(
graph
&&
data
){
graph
.
data
(
data
);
graph
.
data
(
data
);
graph
.
render
();
graph
.
render
();
graph
.
fitView
();
graph
.
fitView
();
...
...
src/view/Manage/Map/MapContent.jsx
View file @
35aa3780
...
@@ -3,6 +3,7 @@ import { Row, Col, Breadcrumb, Spin } from 'antd';
...
@@ -3,6 +3,7 @@ import { Row, Col, Breadcrumb, Spin } from 'antd';
import
{
HomeOutlined
}
from
'@ant-design/icons'
;
import
{
HomeOutlined
}
from
'@ant-design/icons'
;
import
SquareItem
from
'./Component/SquareItem'
;
import
SquareItem
from
'./Component/SquareItem'
;
import
Org
from
'./Component/Org'
;
import
Tree
from
'./Component/Tree'
;
import
Tree
from
'./Component/Tree'
;
import
Relation
from
'./Component/Relation'
;
import
Relation
from
'./Component/Relation'
;
import
{
dispatchLatest
}
from
'../../../model'
;
import
{
dispatchLatest
}
from
'../../../model'
;
...
@@ -18,6 +19,7 @@ class MapContent extends React.Component {
...
@@ -18,6 +19,7 @@ class MapContent extends React.Component {
loading
:
false
,
loading
:
false
,
tableModelData
:
null
,
tableModelData
:
null
,
curTableModelData
:
null
,
curTableModelData
:
null
,
orgModelData
:
null
,
treeModelData
:
null
,
treeModelData
:
null
,
relationModelData
:
null
,
relationModelData
:
null
,
breadcrumbContents
:
null
breadcrumbContents
:
null
...
@@ -114,37 +116,37 @@ class MapContent extends React.Component {
...
@@ -114,37 +116,37 @@ class MapContent extends React.Component {
onSquareItemClick
=
(
item
)
=>
{
onSquareItemClick
=
(
item
)
=>
{
const
{
tableModelData
}
=
this
.
state
;
const
{
tableModelData
}
=
this
.
state
;
if
(
!
item
.
children
)
{
if
(
!
item
.
children
)
{
// dispatchLatest({
dispatchLatest
({
// type: 'map.getTableModelByDirIid',
type
:
'map.getTableModelByDirIid'
,
// payload: { dirId: item.dirId },
payload
:
{
dirId
:
item
.
dirId
},
// callback: data => {
callback
:
data
=>
{
// this.convertRemoteData(data||[]);
this
.
convertRemoteData
(
data
||
[]);
// item.children = (data||[]);
item
.
children
=
(
data
||
[]);
// this.setSquareGraphState(item);
// this.setTreeAndRelationState(tableModelData);
// }
// })
// return;
item
.
children
=
[
{
"subDirCount"
:
0
,
"dbType"
:
"Dir"
,
"dirId"
:
"5f2a63e89cfac536601fb2a6"
,
"tableModelCount"
:
0
,
"dirName"
:
"公司"
},
{
"tableModelId"
:
"1"
,
"name"
:
"table"
,
"system"
:
"8月5"
,
"remarks"
:
"对外"
}
]
this
.
convertRemoteData
(
item
.
children
);
this
.
setSquareGraphState
(
item
);
this
.
setSquareGraphState
(
item
);
this
.
setTreeAndRelationState
(
tableModelData
);
this
.
setTreeAndRelationState
(
tableModelData
);
}
})
return
;
return
;
// item.children = [
// {
// "subDirCount": 0,
// "dbType": "Dir",
// "dirId": "5f2a63e89cfac536601fb2a6",
// "tableModelCount": 0,
// "dirName": "公司"
// },
// {
// "tableModelId": "1",
// "name": "table",
// "system": "8月5",
// "remarks": "对外"
// }
// ]
// this.convertRemoteData(item.children);
// this.setSquareGraphState(item);
// this.setTreeAndRelationState(tableModelData);
// return;
}
}
this
.
setSquareGraphState
(
item
);
this
.
setSquareGraphState
(
item
);
...
@@ -163,47 +165,11 @@ class MapContent extends React.Component {
...
@@ -163,47 +165,11 @@ class MapContent extends React.Component {
loadMoreData
=
(
id
)
=>
{
loadMoreData
=
(
id
)
=>
{
const
{
tableModelData
}
=
this
.
state
;
const
{
tableModelData
}
=
this
.
state
;
// dispatchLatest({
dispatchLatest
({
// type: 'map.getTableModelByDirIid',
type
:
'map.getTableModelByDirIid'
,
// payload: { dirId: id },
payload
:
{
dirId
:
id
},
// callback: data => {
callback
:
data
=>
{
// this.convertRemoteData(data||[]);
this
.
convertRemoteData
(
data
||
[]);
// function recursionData(_data) {
// if ((_data||[]).length === 0) return;
// _data.forEach((item, index) => {
// if (item.dirId === id) {
// item.children = data;
// } else {
// recursionData(item.children||[]);
// }
// })
// }
// recursionData(tableModelData);
// this.setTreeAndRelationState(tableModelData);
// }
// })
const
data
=
[
{
"subDirCount"
:
0
,
"dbType"
:
"Dir"
,
"dirId"
:
"5f2a63e89cfac536601fb2a6"
,
"tableModelCount"
:
0
,
"dirName"
:
"公司"
},
{
"tableModelId"
:
"1"
,
"name"
:
"table"
,
"system"
:
"8月5"
,
"remarks"
:
"对外"
}
]
this
.
convertRemoteData
(
data
);
function
recursionData
(
_data
)
{
function
recursionData
(
_data
)
{
if
((
_data
||
[]).
length
===
0
)
return
;
if
((
_data
||
[]).
length
===
0
)
return
;
...
@@ -221,18 +187,55 @@ class MapContent extends React.Component {
...
@@ -221,18 +187,55 @@ class MapContent extends React.Component {
this
.
setTreeAndRelationState
(
tableModelData
);
this
.
setTreeAndRelationState
(
tableModelData
);
}
}
})
// const data = [
// {
// "subDirCount": 0,
// "dbType": "Dir",
// "dirId": "5f2a63e89cfac536601fb2a6",
// "tableModelCount": 0,
// "dirName": "公司"
// },
// {
// "tableModelId": "1",
// "name": "table",
// "system": "8月5",
// "remarks": "对外"
// }
// ]
// this.convertRemoteData(data);
// function recursionData(_data) {
// if ((_data||[]).length === 0) return;
// _data.forEach((item, index) => {
// if (item.dirId === id) {
// item.children = data;
// } else {
// recursionData(item.children||[]);
// }
// })
// }
// recursionData(tableModelData);
// this.setTreeAndRelationState(tableModelData);
}
setTreeAndRelationState
=
(
tableModelData
)
=>
{
setTreeAndRelationState
=
(
tableModelData
)
=>
{
const
_treeData
=
this
.
convertTreeModelData
(
tableModelData
);
const
_treeData
=
this
.
convertTreeModelData
(
tableModelData
);
this
.
setState
({
this
.
setState
({
orgModelData
:
lodash
.
cloneDeep
(
_treeData
),
treeModelData
:
lodash
.
cloneDeep
(
_treeData
),
treeModelData
:
lodash
.
cloneDeep
(
_treeData
),
relationModelData
:
this
.
convertRelationModelData
(
lodash
.
cloneDeep
(
_treeData
))
relationModelData
:
this
.
convertRelationModelData
(
lodash
.
cloneDeep
(
_treeData
))
});
});
}
}
render
()
{
render
()
{
const
{
diagram
,
t
ype
}
=
this
.
props
;
const
{
diagram
,
t
opic
}
=
this
.
props
;
const
{
curTableModelData
,
breadcrumbContents
,
treeModelData
,
relationModelData
,
loading
}
=
this
.
state
;
const
{
curTableModelData
,
breadcrumbContents
,
orgModelData
,
treeModelData
,
relationModelData
,
loading
}
=
this
.
state
;
let
groups
=
[];
let
groups
=
[];
if
(
curTableModelData
)
{
if
(
curTableModelData
)
{
...
@@ -284,10 +287,13 @@ class MapContent extends React.Component {
...
@@ -284,10 +287,13 @@ class MapContent extends React.Component {
</>
</>
}
}
{
{
diagram
===
'tree'
&&
<
Tree
data=
{
treeModelData
}
type=
{
type
}
{
...
this
.
props
}
loadMoreData=
{
this
.
loadMoreData
}
/>
diagram
===
'org'
&&
<
Org
data=
{
orgModelData
}
type=
{
`${topic.id||''}${diagram}`
}
{
...
this
.
props
}
loadMoreData=
{
this
.
loadMoreData
}
/>
}
{
diagram
===
'tree'
&&
<
Tree
data=
{
treeModelData
}
type=
{
`${topic.id||''}${diagram}`
}
{
...
this
.
props
}
loadMoreData=
{
this
.
loadMoreData
}
/>
}
}
{
{
diagram
===
'relation'
&&
<
Relation
data=
{
relationModelData
}
type=
{
type
}
{
...
this
.
props
}
loadMoreData=
{
this
.
loadMoreData
}
/>
diagram
===
'relation'
&&
<
Relation
data=
{
relationModelData
}
type=
{
`${topic.id||''}${diagram}`
}
{
...
this
.
props
}
loadMoreData=
{
this
.
loadMoreData
}
/>
}
}
</>
</>
}
}
...
...
src/view/Manage/Map/index.jsx
View file @
35aa3780
...
@@ -56,6 +56,7 @@ class Map extends React.Component {
...
@@ -56,6 +56,7 @@ class Map extends React.Component {
tabBarExtraContent=
{
{
tabBarExtraContent=
{
{
left
:
<
Radio
.
Group
className=
'm-3'
size=
'small'
value=
{
diagram
}
onChange=
{
this
.
onRadioChange
}
>
left
:
<
Radio
.
Group
className=
'm-3'
size=
'small'
value=
{
diagram
}
onChange=
{
this
.
onRadioChange
}
>
<
Radio
.
Button
value=
'square'
>
方块图
</
Radio
.
Button
>
<
Radio
.
Button
value=
'square'
>
方块图
</
Radio
.
Button
>
<
Radio
.
Button
value=
'org'
>
组织图
</
Radio
.
Button
>
<
Radio
.
Button
value=
'tree'
>
树形图
</
Radio
.
Button
>
<
Radio
.
Button
value=
'tree'
>
树形图
</
Radio
.
Button
>
<
Radio
.
Button
value=
'relation'
>
关系图
</
Radio
.
Button
>
<
Radio
.
Button
value=
'relation'
>
关系图
</
Radio
.
Button
>
</
Radio
.
Group
>,
</
Radio
.
Group
>,
...
@@ -67,7 +68,7 @@ class Map extends React.Component {
...
@@ -67,7 +68,7 @@ class Map extends React.Component {
topics
&&
topics
.
map
((
topic
,
index
)
=>
{
topics
&&
topics
.
map
((
topic
,
index
)
=>
{
return
(
return
(
<
TabPane
tab=
{
topic
.
name
||
''
}
key=
{
index
.
toString
()
}
className=
'p-3'
style=
{
{
height
:
'100%'
}
}
>
<
TabPane
tab=
{
topic
.
name
||
''
}
key=
{
index
.
toString
()
}
className=
'p-3'
style=
{
{
height
:
'100%'
}
}
>
{
tabKey
===
index
.
toString
()
&&
<
MapContent
diagram=
{
diagram
}
topic=
{
topic
}
type=
'business'
{
...
this
.
props
}
/>
}
{
tabKey
===
index
.
toString
()
&&
<
MapContent
diagram=
{
diagram
}
topic=
{
topic
}
{
...
this
.
props
}
/>
}
</
TabPane
>
</
TabPane
>
);
);
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment