Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-convertor-view
Project
Project
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
station
amos-convertor-view
Commits
8a9ee1f4
Commit
8a9ee1f4
authored
Mar 10, 2020
by
单奇雲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增TOPO节点添加及删除功能
parent
1407f9c8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
122 deletions
+143
-122
urlConsts.js
src/consts/urlConsts.js
+1
-0
preControlService.js
src/services/preControlService.js
+8
-0
leaderStruct.scss
src/styles/view/planMgmt/leaderStruct.scss
+9
-0
conf.js
src/view/planMgmt/common/conf.js
+1
-1
LeaderStructModel.js
src/view/planMgmt/view/leaderStruct/LeaderStructModel.js
+19
-21
index.js
src/view/planMgmt/view/leaderStruct/index.js
+105
-100
No files found.
src/consts/urlConsts.js
View file @
8a9ee1f4
...
@@ -224,6 +224,7 @@ export const FasSerUrl = {
...
@@ -224,6 +224,7 @@ export const FasSerUrl = {
updateTopographyUrl
:
completePrefix
(
baseURI
,
'api/Topography/updateTopo'
),
//更新Topo图数据
updateTopographyUrl
:
completePrefix
(
baseURI
,
'api/Topography/updateTopo'
),
//更新Topo图数据
queryNodeDetailUrl
:
completePrefix
(
baseURI
,
'api/Topography/detail/{id}'
),
//获取node节点详情
queryNodeDetailUrl
:
completePrefix
(
baseURI
,
'api/Topography/detail/{id}'
),
//获取node节点详情
saveNodeDetailUrl
:
completePrefix
(
baseURI
,
'api/Topography/detail'
),
//保存nodeDetail详情
saveNodeDetailUrl
:
completePrefix
(
baseURI
,
'api/Topography/detail'
),
//保存nodeDetail详情
deleteTopoUrl
:
completePrefix
(
baseURI
,
'api/Topography/{type}/{id}'
),
//删除点/线
};
};
...
...
src/services/preControlService.js
View file @
8a9ee1f4
...
@@ -221,3 +221,10 @@ export const nodeDetailTopoAction = (id) => {
...
@@ -221,3 +221,10 @@ export const nodeDetailTopoAction = (id) => {
export
const
nodeDetailTopoSaveAction
=
(
nodeDatil
)
=>
{
export
const
nodeDetailTopoSaveAction
=
(
nodeDatil
)
=>
{
return
commonPost
(
FasSerUrl
.
saveNodeDetailUrl
,
nodeDatil
);
return
commonPost
(
FasSerUrl
.
saveNodeDetailUrl
,
nodeDatil
);
};
};
/**
* 删除节点/线
*/
export
const
deleteTopoAction
=
(
id
,
type
)
=>
{
return
commonDelete
(
formatUrl
(
FasSerUrl
.
deleteTopoUrl
,
{
id
,
type
}));
};
\ No newline at end of file
src/styles/view/planMgmt/leaderStruct.scss
View file @
8a9ee1f4
...
@@ -44,6 +44,15 @@
...
@@ -44,6 +44,15 @@
border-right-style
:
solid
;
border-right-style
:
solid
;
border-width
:
1px
;
border-width
:
1px
;
.leader-struct-palette
{
border
:
1px
solid
rgb
(
201
,
201
,
201
);
height
:
10%
;
}
.leader-struct-diagram
{
height
:
90%
;
}
.tooltip-content
{
.tooltip-content
{
width
:
251px
;
width
:
251px
;
background
:
#345fa6
;
background
:
#345fa6
;
...
...
src/view/planMgmt/common/conf.js
View file @
8a9ee1f4
...
@@ -17,5 +17,5 @@ export const leaderStructButton = [
...
@@ -17,5 +17,5 @@ export const leaderStructButton = [
// { key: 'add', text: '添加', icon: 'tianjia' },
// { key: 'add', text: '添加', icon: 'tianjia' },
{
key
:
'edit'
,
text
:
'编辑'
,
icon
:
'xiugai'
},
{
key
:
'edit'
,
text
:
'编辑'
,
icon
:
'xiugai'
},
{
key
:
'save'
,
text
:
'保存'
,
icon
:
'baocun'
},
{
key
:
'save'
,
text
:
'保存'
,
icon
:
'baocun'
},
//
{ key: 'delete', text: '删除', icon: 'shanchu' }
{
key
:
'delete'
,
text
:
'删除'
,
icon
:
'shanchu'
}
];
];
src/view/planMgmt/view/leaderStruct/LeaderStructModel.js
View file @
8a9ee1f4
...
@@ -66,7 +66,6 @@ class LeaderStructModel extends Component {
...
@@ -66,7 +66,6 @@ class LeaderStructModel extends Component {
componentWillMount
=
()
=>
{
componentWillMount
=
()
=>
{
const
{
selectNode
}
=
this
.
props
||
{};
const
{
selectNode
}
=
this
.
props
||
{};
debugger
;
this
.
getNodeDetail
(
selectNode
);
this
.
getNodeDetail
(
selectNode
);
};
};
...
@@ -116,35 +115,34 @@ class LeaderStructModel extends Component {
...
@@ -116,35 +115,34 @@ class LeaderStructModel extends Component {
this
.
setState
({
form
});
this
.
setState
({
form
});
}
}
handleSubmit
=
nodeid
=>
{
handleSubmit
=
node
=>
{
debugger
;
this
.
form
.
validate
((
valid
,
dataValues
)
=>
{
this
.
form
.
validate
((
valid
,
dataValues
)
=>
{
debugger
;
if
(
valid
)
{
if
(
valid
)
{
let
{
form
}
=
this
.
state
;
let
{
form
}
=
this
.
state
;
form
.
nodeid
=
nodeid
;
form
.
nodeid
=
node
.
nodeid
;
this
.
nodeDetailEdit
(
form
);
form
.
nodekey
=
node
.
key
;
// this.nodeDetailEdit(form);
form
.
nodeDetail
=
JSON
.
stringify
(
form
.
nodeDetail
);
this
.
props
.
saveTopography
(
form
);
}
else
{
}
else
{
return
false
;
return
false
;
}
}
});
});
};
};
nodeDetailEdit
=
body
=>
{
// nodeDetailEdit = body => {
debugger
;
// body.nodeDetail = JSON.stringify(body.nodeDetail);
body
.
nodeDetail
=
JSON
.
stringify
(
body
.
nodeDetail
);
// nodeDetailTopoSaveAction(body).then(
nodeDetailTopoSaveAction
(
body
).
then
(
// data => {
data
=>
{
// AmosAlert.success('提示', '操作成功');
AmosAlert
.
success
(
'提示'
,
'操作成功'
);
// this.props.cancel();
// this.props.reloadPage();
// this.props.reloadSelectNode(this.props.selectNode.id);
this
.
props
.
cancel
();
// },
this
.
props
.
reloadSelectNode
(
this
.
props
.
selectNode
.
id
);
// err => {
},
// AmosAlert.error('提示', err);
err
=>
{
// }
AmosAlert
.
error
(
'提示'
,
err
);
// );
}
// };
);
};
/**
/**
* 获取表格刷新方法
* 获取表格刷新方法
...
...
src/view/planMgmt/view/leaderStruct/index.js
View file @
8a9ee1f4
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
PropTypes
from
'prop-types'
;
import
PropTypes
from
'prop-types'
;
import
{
browserHistory
}
from
'amos-react-router'
;
import
{
browserHistory
}
from
'amos-react-router'
;
import
{
Modal
,
Button
,
message
}
from
'amos-framework'
;
import
{
Modal
,
Button
,
message
,
AmosAlert
}
from
'amos-framework'
;
import
BizIcon
from
'./../../../common/icon/BizIcon'
;
import
BizIcon
from
'./../../../common/icon/BizIcon'
;
import
ToolBar
from
'./ToolBar'
;
import
ToolBar
from
'./ToolBar'
;
import
go
from
'amos-gojs'
;
import
go
from
'amos-gojs'
;
import
{
queryTopographyAction
,
updateTopographyAction
,
nodeDetailTopoAction
}
from
'./../../../../services/preControlService'
;
import
{
queryTopographyAction
,
updateTopographyAction
,
nodeDetailTopoAction
,
deleteTopoAction
}
from
'./../../../../services/preControlService'
;
import
LeaderStructModel
from
'./LeaderStructModel'
;
import
LeaderStructModel
from
'./LeaderStructModel'
;
import
LeaderStructRightGrid
from
'./LeaderStructRightGrid'
;
import
LeaderStructRightGrid
from
'./LeaderStructRightGrid'
;
...
@@ -27,75 +27,65 @@ class LeaderStruct extends Component {
...
@@ -27,75 +27,65 @@ class LeaderStruct extends Component {
modal
:
false
,
modal
:
false
,
toolBarFlag
:
''
,
toolBarFlag
:
''
,
selectNode
:
{},
selectNode
:
{},
selectNodeType
:
''
,
rightGridData
:
[]
rightGridData
:
[]
};
};
this
.
diagram
=
null
;
//gojs图
this
.
diagram
=
null
;
//gojs图
this
.
myPalette
=
null
;
//工具栏
this
.
updateTopologyData
=
{};
this
.
updateTopologyData
=
{};
}
}
// componentWillMount(){
// let { appId } = this.props.location.state;
// debugger;
// }
componentDidMount
()
{
componentDidMount
()
{
let
{
appId
}
=
this
.
props
.
location
.
state
;
let
{
appId
}
=
this
.
props
.
location
.
state
;
debugger
;
this
.
fetchData
(
appId
);
}
fetchData
=
(
appId
)
=>
{
queryTopographyAction
(
appId
).
then
(
res
=>
{
queryTopographyAction
(
appId
).
then
(
res
=>
{
this
.
setState
({
nodeData
:
res
.
nodeData
,
linkData
:
res
.
linkData
})
this
.
setState
({
nodeData
:
res
.
nodeData
,
linkData
:
res
.
linkData
})
this
.
renderCanvas
();
this
.
renderCanvas
();
});
});
}
}
// this function is the Node.dragComputation, to limit the movement of the parts
makePort
=
(
name
,
spot
,
output
,
input
)
=>
{
stayInFixedArea
=
(
part
,
pt
,
gridpt
)
=>
{
// the port is basically just a small transparent square
let
diagram
=
part
.
diagram
;
return
goObj
(
go
.
Shape
,
"Circle"
,
if
(
diagram
===
null
)
{
return
pt
;}
// compute the document area without padding
let
v
=
diagram
.
documentBounds
.
copy
();
v
.
subtractMargin
(
diagram
.
padding
);
// get the bounds of the part being dragged
let
b
=
part
.
actualBounds
;
let
loc
=
part
.
location
;
// now limit the location appropriately
let
x
=
Math
.
max
(
v
.
x
,
Math
.
min
(
pt
.
x
,
v
.
right
-
b
.
width
))
+
(
loc
.
x
-
b
.
x
);
let
y
=
Math
.
max
(
v
.
y
,
Math
.
min
(
pt
.
y
,
v
.
bottom
-
b
.
height
))
+
(
loc
.
y
-
b
.
y
);
return
new
go
.
Point
(
x
,
y
);
}
makePort
=
(
name
,
align
,
spot
,
output
,
input
)
=>
{
var
horizontal
=
align
.
equals
(
go
.
Spot
.
Top
)
||
align
.
equals
(
go
.
Spot
.
Bottom
);
// the port is basically just a transparent rectangle that stretches along the side of the node,
// and becomes colored when the mouse passes over it
return
goObj
(
go
.
Shape
,
{
{
// fill: "transparent", // changed to a color in the mouseEnter event handler
fill
:
null
,
// not seen, by default; set to a translucent gray by showSmallPorts, defined below
strokeWidth
:
0
,
// no stroke
stroke
:
null
,
width
:
0
,
// if not stretching horizontally, just 8 wide
desiredSize
:
new
go
.
Size
(
7
,
7
),
height
:
0
,
// if not stretching vertically, just 8 tall
alignment
:
spot
,
// align the port on the main Shape
alignment
:
align
,
// align the port on the main Shape
alignmentFocus
:
spot
,
// just inside the Shape
stretch
:
0
,
portId
:
name
,
// declare this object to be a "port"
portId
:
name
,
// declare this object to be a "port"
fromSpot
:
spot
,
// declare where links may connect at this port
fromSpot
:
spot
,
toSpot
:
spot
,
// declare where links may connect at this port
fromLinkable
:
output
,
// declare whether the user may draw links from here
fromLinkable
:
output
,
toLinkable
:
input
,
// declare whether the user may draw links to/from here
toSpot
:
spot
,
// declare where links may connect at this port
cursor
:
"pointer"
// show a different cursor to indicate potential link point
toLinkable
:
input
,
// declare whether the user may draw links to here
});
cursor
:
"pointer"
,
// show a different cursor to indicate potential link point
}
mouseEnter
:
function
(
e
,
port
)
{
// the PORT argument will be this Shape
//展示 连接点
if
(
!
e
.
diagram
.
isReadOnly
)
port
.
fill
=
"rgba(255,0,255,0.5)"
;
showSmallPorts
=
(
e
,
node
)
=>
{
},
node
&&
node
.
ports
.
each
(
function
(
port
)
{
mouseLeave
:
function
(
e
,
port
)
{
if
(
port
.
portId
!==
""
)
{
// don't change the default port, which is the big shape
port
.
fill
=
"transparent"
;
port
.
fill
=
"rgba(0,0,0,.3)"
;
}
});
}
hideSmallPorts
=
(
e
,
node
)
=>
{
node
&&
node
.
ports
.
each
(
function
(
port
)
{
if
(
port
.
portId
!==
""
)
{
// don't change the default port, which is the big shape
port
.
fill
=
null
;
}
}
});
});
}
}
// 选择节点
// 选择节点
nodeSelectionChanged
=
(
node
)
=>
{
nodeSelectionChanged
=
(
node
)
=>
{
console
.
log
(
node
,
'node'
);
if
(
node
.
isSelected
){
// console.log(node.data,'selected');
this
.
reloadSelectNode
(
node
.
data
.
id
);
this
.
reloadSelectNode
(
node
.
data
.
id
);
this
.
setState
({
selectNode
:
node
.
data
||
{}})
this
.
setState
({
selectNode
:
node
.
data
||
{},
selectNodeType
:
node
.
type
.
name
||
''
});
}
}
}
reloadSelectNode
=
(
id
)
=>
{
reloadSelectNode
=
(
id
)
=>
{
...
@@ -106,6 +96,7 @@ class LeaderStruct extends Component {
...
@@ -106,6 +96,7 @@ class LeaderStruct extends Component {
// 提示框
// 提示框
showToolTip
=
(
obj
,
diagram
,
tool
)
=>
{
showToolTip
=
(
obj
,
diagram
,
tool
)
=>
{
if
(
!
obj
.
data
.
isPalette
){
let
toolTipDIV
=
document
.
getElementById
(
'toolTipDIV'
);
let
toolTipDIV
=
document
.
getElementById
(
'toolTipDIV'
);
let
pt
=
diagram
.
lastInput
.
viewPoint
;
let
pt
=
diagram
.
lastInput
.
viewPoint
;
toolTipDIV
.
style
.
left
=
`
${
pt
.
x
+
12
}
px`
;
toolTipDIV
.
style
.
left
=
`
${
pt
.
x
+
12
}
px`
;
...
@@ -113,6 +104,7 @@ class LeaderStruct extends Component {
...
@@ -113,6 +104,7 @@ class LeaderStruct extends Component {
toolTipDIV
.
style
.
display
=
'block'
;
toolTipDIV
.
style
.
display
=
'block'
;
this
.
getNodeDetail
(
obj
.
data
.
id
);
this
.
getNodeDetail
(
obj
.
data
.
id
);
}
}
}
hideToolTip
=
(
diagram
,
tool
)
=>
{
hideToolTip
=
(
diagram
,
tool
)
=>
{
let
toolTipDIV
=
document
.
getElementById
(
'toolTipDIV'
);
let
toolTipDIV
=
document
.
getElementById
(
'toolTipDIV'
);
...
@@ -129,12 +121,11 @@ class LeaderStruct extends Component {
...
@@ -129,12 +121,11 @@ class LeaderStruct extends Component {
onOk
=
()
=>
{
onOk
=
()
=>
{
let
{
selectNode
}
=
this
.
state
;
let
{
selectNode
}
=
this
.
state
;
if
(
selectNode
.
id
)
{
if
(
selectNode
)
{
this
.
model
.
handleSubmit
(
selectNode
.
id
);
this
.
model
.
handleSubmit
(
selectNode
);
}
else
{
}
else
{
AmosAlert
.
warning
(
'提示'
,
'请选择节点后,再进行操作'
);
AmosAlert
.
warning
(
'提示'
,
'请选择节点后,再进行操作'
);
}
}
// this.setState({ model: false, toolBarFlag: '' })
};
};
cancel
=
()
=>
{
cancel
=
()
=>
{
...
@@ -162,58 +153,36 @@ class LeaderStruct extends Component {
...
@@ -162,58 +153,36 @@ class LeaderStruct extends Component {
});
});
this
.
diagram
=
goObj
(
go
.
Diagram
,
this
.
refs
.
goJsDiv
,
{
this
.
diagram
=
goObj
(
go
.
Diagram
,
this
.
refs
.
goJsDiv
,
{
allowZoom
:
false
,
// disallow zooming
// initialContentAlignment: go.Spot.TopLeft,
contentAlignment
:
go
.
Spot
.
Center
,
contentAlignment
:
go
.
Spot
.
Center
,
initialPosition
:
new
go
.
Point
(
0
,
0
),
initialPosition
:
new
go
.
Point
(
0
,
0
),
'undoManager.isEnabled'
:
true
,
//// enable undo & redo 是否可撤回
'undoManager.isEnabled'
:
true
,
//// enable undo & redo 是否可撤回
'animationManager.isEnabled'
:
false
,
// 过渡动画
'animationManager.isEnabled'
:
false
,
// 过渡动画
// 'textEditingTool.defaultTextEditor': this.customEditor,
ModelChanged
:
(
e
,
value
)
=>
{
// just for demonstration purposes,
ModelChanged
:
(
e
)
=>
{
// just for demonstration purposes,
if
(
e
.
isTransactionFinished
)
{
// show the model data in the page's TextArea
if
(
e
.
isTransactionFinished
)
{
// show the model data in the page's TextArea
console
.
log
(
e
.
model
.
toJson
(),
'model'
);
this
.
updateTopologyData
=
JSON
.
parse
(
e
.
model
.
toJson
());
this
.
updateTopologyData
=
JSON
.
parse
(
e
.
model
.
toJson
());
// this.props.nodeChange(e);
}
}
},
SelectionMoved
:
(
e
)
=>
{
// setTimeout(()=> {
// this.updateTopo();
// },0);
},
ViewportBoundsChanged
:
()
=>
{
// setTimeout(()=> {
// this.updateTopo();
// },0);
}
}
});
});
this
.
diagram
.
nodeTemplateMap
.
add
(
'leaderStruct'
,
this
.
diagram
.
nodeTemplateMap
.
add
(
'leaderStruct'
,
goObj
(
go
.
Node
,
'
Vertical
'
,
goObj
(
go
.
Node
,
'
Spot
'
,
{
{
locationSpot
:
go
.
Spot
.
Center
,
locationSpot
:
go
.
Spot
.
Center
,
// locationObjectName: 'ICON',
// selectionObjectName: 'ICON',
dragComputation
:
this
.
stayInFixedArea
,
selectionChanged
:
this
.
nodeSelectionChanged
,
selectionChanged
:
this
.
nodeSelectionChanged
,
toolTip
:
myToolTip
toolTip
:
myToolTip
},
},
new
go
.
Binding
(
'
posi
tion'
,
'loc'
,
go
.
Point
.
parse
).
makeTwoWay
(
go
.
Point
.
stringify
),
new
go
.
Binding
(
'
loca
tion'
,
'loc'
,
go
.
Point
.
parse
).
makeTwoWay
(
go
.
Point
.
stringify
),
goObj
(
go
.
Panel
,
'Auto'
,
goObj
(
go
.
Panel
,
'Auto'
,
goObj
(
go
.
Shape
,
'RoundedRectangle'
,
goObj
(
go
.
Shape
,
'RoundedRectangle'
,
{
fill
:
'white'
}),
{
fill
:
'white'
}),
goObj
(
go
.
TextBlock
,
goObj
(
go
.
TextBlock
,
{
{
editable
:
true
,
margin
:
10
,
margin
:
10
,
font
:
'15px sans-serif'
font
:
'15px sans-serif'
,
editable
:
true
,
},
},
new
go
.
Binding
(
'text'
,
'text'
)
new
go
.
Binding
(
'text'
,
'text'
)
.
makeTwoWay
()
),
),
),
),
// this.makePort("T", go.Spot.Top, go.Spot.Top, false, true),
// this.makePort("L", go.Spot.Left, go.Spot.Left, true, true),
// this.makePort("R", go.Spot.Right, go.Spot.Right, true, true),
// this.makePort("B", go.Spot.Bottom, go.Spot.BottomSide, true, false),
{
{
selectionAdornmentTemplate
:
selectionAdornmentTemplate
:
goObj
(
go
.
Adornment
,
'Auto'
,
goObj
(
go
.
Adornment
,
'Auto'
,
...
@@ -222,6 +191,14 @@ class LeaderStruct extends Component {
...
@@ -222,6 +191,14 @@ class LeaderStruct extends Component {
goObj
(
go
.
Placeholder
)
goObj
(
go
.
Placeholder
)
)
// end Adornment
)
// end Adornment
},
},
this
.
makePort
(
"T"
,
go
.
Spot
.
Top
,
false
,
true
),
this
.
makePort
(
"L"
,
go
.
Spot
.
Left
,
true
,
true
),
this
.
makePort
(
"R"
,
go
.
Spot
.
Right
,
true
,
true
),
this
.
makePort
(
"B"
,
go
.
Spot
.
Bottom
,
true
,
false
),
{
mouseEnter
:
this
.
showSmallPorts
,
mouseLeave
:
this
.
hideSmallPorts
,
},
)
)
);
);
...
@@ -233,13 +210,12 @@ class LeaderStruct extends Component {
...
@@ -233,13 +210,12 @@ class LeaderStruct extends Component {
relinkableFrom
:
true
,
relinkableFrom
:
true
,
relinkableTo
:
true
,
relinkableTo
:
true
,
reshapable
:
true
,
reshapable
:
true
,
selectionChanged
:
this
.
nodeSelectionChanged
,
},
},
goObj
(
go
.
Shape
,
{
strokeWidth
:
2
}),
goObj
(
go
.
Shape
,
{
strokeWidth
:
2
}),
goObj
(
go
.
Shape
,
{
toArrow
:
"OpenTriangle"
})
goObj
(
go
.
Shape
,
{
toArrow
:
"OpenTriangle"
})
);
);
// nodeData = [{"id":"2-00014","key":"00014","category":"Picture","group":"03000","text":"上海NPC A","source":"single-way","treeid":"4","singlePort":"00014"},{"id":"2-00015","key":"00015","category":"Picture","group":"03000","text":"上海NPC B","source":"single-way","treeid":"4","singlePort":"00015"},{"id":"2-00016","key":"00016","category":"Picture","group":"03000","text":"上海NPC C","source":"single-way","treeid":"4","singlePort":"00016"},{"id":"2-00017","key":"00017","category":"Picture","group":"03000","text":"上海NPC D","source":"single-way","treeid":"4","singlePort":"00017"},{"id":"2-00020","key":"00020","category":"Picture","group":"03000","text":"XAPMTSAP1","source":"single-way","treeid":"4","singlePort":"00020"}]
// linkData = [{"id":"c02e649cecff53fe8a0e96a1e56a18f8","from":"00020","to":"00014","treeid":"4","warnState":0,"warnMessage":"","hasArrow":true,"fromPort":"00020","toPort":"00014"},{"id":"f8072d2df9545646b2460c813085014f","from":"00020","to":"00015","treeid":"4","warnState":0,"warnMessage":"","hasArrow":true,"fromPort":"00020","toPort":"00015"},{"id":"8767ffa2a97d50a7a59c9391cff9810e","from":"00015","to":"00016","treeid":"4","warnState":0,"warnMessage":"","hasArrow":true,"fromPort":"00020","toPort":"00016"},{"id":"3c3ec3b00372557e936c3c8eefe92da8","from":"00015","to":"00017","treeid":"4","warnState":0,"warnMessage":"","hasArrow":true,"fromPort":"00020","toPort":"00017"}]
this
.
diagram
.
model
=
goObj
(
go
.
GraphLinksModel
,
this
.
diagram
.
model
=
goObj
(
go
.
GraphLinksModel
,
{
{
linkFromPortIdProperty
:
'fromPort'
,
// required information:
linkFromPortIdProperty
:
'fromPort'
,
// required information:
...
@@ -248,34 +224,68 @@ class LeaderStruct extends Component {
...
@@ -248,34 +224,68 @@ class LeaderStruct extends Component {
linkDataArray
:
linkData
||
[]
linkDataArray
:
linkData
||
[]
});
});
this
.
myPalette
=
goObj
(
go
.
Palette
,
this
.
refs
.
myPaletteDiv
,
{
nodeTemplateMap
:
this
.
diagram
.
nodeTemplateMap
,
// share the templates used by myDiagram
model
:
new
go
.
GraphLinksModel
([
// specify the contents of the Palette
{
category
:
"leaderStruct"
,
text
:
"节点"
,
isPalette
:
true
}
]
)
});
}
}
onButtonClick
=
(
key
)
=>
{
onButtonClick
=
(
key
)
=>
{
const
{
selectNode
,
selectNodeType
}
=
this
.
state
;
if
(
key
===
'goback'
)
{
if
(
key
===
'goback'
)
{
browserHistory
.
goBack
();
browserHistory
.
goBack
();
}
else
if
(
key
===
'save'
){
}
else
if
(
key
===
'save'
){
const
{
nodeDataArray
,
linkDataArray
}
=
this
.
updateTopologyData
;
this
.
saveTopography
(
null
);
const
params
=
{
appId
:
this
.
props
.
location
.
state
.
appId
,
nodeData
:
nodeDataArray
,
linkData
:
linkDataArray
};
updateTopographyAction
(
params
).
then
(
data
=>
{
message
.
success
(
'拓扑图保存成功!'
);
});
}
else
if
(
key
===
'edit'
){
}
else
if
(
key
===
'edit'
){
const
{
selectNode
}
=
this
.
state
;
if
(
selectNode
&&
selectNodeType
===
"Spot"
){
if
(
selectNode
.
id
){
this
.
setState
({
modal
:
true
});
this
.
setState
({
modal
:
true
});
}
else
{
}
else
{
message
.
danger
(
'请选择节点!'
);
message
.
danger
(
'请选择节点!'
);
}
}
}
else
if
(
key
===
'delete'
){
if
(
selectNode
&&
selectNodeType
){
selectNode
.
id
&&
deleteTopoAction
(
selectNode
.
id
,
selectNodeType
).
then
(
data
=>
{
message
.
success
(
'删除成功!'
);
});
this
.
diagram
.
commandHandler
.
deleteSelection
();
this
.
setState
({
selectNode
:
{},
selectNodeType
:
''
});
}
else
{
message
.
danger
(
'请选择节点!'
);
}
}
else
{
}
else
{
console
.
log
(
'暂未开发'
);
console
.
log
(
'暂未开发'
);
}
}
this
.
setState
({
toolBarFlag
:
key
});
this
.
setState
({
toolBarFlag
:
key
});
}
}
saveTopography
=
(
nodeDetail
)
=>
{
const
{
nodeDataArray
,
linkDataArray
}
=
this
.
updateTopologyData
;
const
params
=
{
appId
:
this
.
props
.
location
.
state
.
appId
,
nodeData
:
nodeDataArray
,
linkData
:
linkDataArray
,
nodeDetail
:
nodeDetail
};
updateTopographyAction
(
params
).
then
(
data
=>
{
AmosAlert
.
success
(
'提示'
,
'拓扑图保存成功!'
);
this
.
cancel
();
this
.
diagram
.
model
=
goObj
(
go
.
GraphLinksModel
,
{
linkFromPortIdProperty
:
'fromPort'
,
// required information:
linkToPortIdProperty
:
'toPort'
,
// identifies data property names
nodeDataArray
:
data
.
nodeData
||
[],
linkDataArray
:
data
.
linkData
||
[]
});
}).
catch
(
e
=>
{
AmosAlert
.
error
(
'错误'
,
'保存失败'
);
});;
}
getHeader
=
()
=>
{
getHeader
=
()
=>
{
const
{
toolBarFlag
}
=
this
.
state
;
const
{
toolBarFlag
}
=
this
.
state
;
if
(
toolBarFlag
===
'edit'
)
{
if
(
toolBarFlag
===
'edit'
)
{
...
@@ -291,6 +301,7 @@ class LeaderStruct extends Component {
...
@@ -291,6 +301,7 @@ class LeaderStruct extends Component {
cancel
=
{
this
.
cancel
}
cancel
=
{
this
.
cancel
}
selectNode
=
{
selectNode
}
selectNode
=
{
selectNode
}
reloadSelectNode
=
{
this
.
reloadSelectNode
}
reloadSelectNode
=
{
this
.
reloadSelectNode
}
saveTopography
=
{
this
.
saveTopography
}
ref
=
{
component
=>
this
.
model
=
component
}
ref
=
{
component
=>
this
.
model
=
component
}
/>
;
/>
;
}
}
...
@@ -318,19 +329,14 @@ class LeaderStruct extends Component {
...
@@ -318,19 +329,14 @@ class LeaderStruct extends Component {
<
/div
>
<
/div
>
<
div
className
=
'leader-struct-content'
>
<
div
className
=
'leader-struct-content'
>
<
div
className
=
'leader-struct-left'
>
<
div
className
=
'leader-struct-left'
>
<
div
ref
=
"myPaletteDiv"
className
=
'leader-struct-palette'
id
=
"myPaletteDiv"
/>
{
/* <img src='/src/view/planMgmt/view/leaderStruct/company.jpg' alt='' /> */
}
<
div
ref
=
"goJsDiv"
className
=
'leader-struct-diagram'
/>
<
div
ref
=
"goJsDiv"
style
=
{{
height
:
'100%'
}}
/
>
{
this
.
renderDetail
()}
{
this
.
renderDetail
()}
<
/div
>
<
/div
>
<
div
className
=
'leader-struct-right'
>
<
div
className
=
'leader-struct-right'
>
<
LeaderStructRightGrid
nodeDetail
=
{
rightGridData
}
/
>
<
LeaderStructRightGrid
nodeDetail
=
{
rightGridData
}
/
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
Modal
<
Modal
header
=
{
this
.
getHeader
(
toolBarFlag
)}
header
=
{
this
.
getHeader
(
toolBarFlag
)}
visible
=
{
modal
}
visible
=
{
modal
}
...
@@ -343,7 +349,6 @@ class LeaderStruct extends Component {
...
@@ -343,7 +349,6 @@ class LeaderStruct extends Component {
outterClosable
=
{
false
}
outterClosable
=
{
false
}
footer
=
{
this
.
getFooter
()}
footer
=
{
this
.
getFooter
()}
/
>
/
>
<
/div
>
<
/div
>
);
);
}
}
...
...
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