|
@@ -125,18 +125,31 @@ export default {
|
|
const position = this.graph.getContentArea()
|
|
const position = this.graph.getContentArea()
|
|
const nodes = this.graph.getNodes()
|
|
const nodes = this.graph.getNodes()
|
|
const currentNode = nodes.find(item=>item.id===nodeId)
|
|
const currentNode = nodes.find(item=>item.id===nodeId)
|
|
|
|
+ let tempNode = currentNode
|
|
if(currentNode){
|
|
if(currentNode){
|
|
- currentNode.data.id=nodeLink.MyChartClassifyId||0
|
|
|
|
|
|
+ const oldId = currentNode.data.id
|
|
|
|
+ const newId = nodeLink.MyChartClassifyId||0
|
|
|
|
+ const isSetStyle = (oldId===0&&newId!==0)||(oldId!==0&&newId===0)
|
|
|
|
+ isSetStyle&&this.setNodeStyle(newId,tempNode)
|
|
|
|
+
|
|
|
|
+ tempNode.data.id=nodeLink.MyChartClassifyId||0
|
|
|
|
+ tempNode.label=nodeName
|
|
|
|
+ tempNode.data.nodeLink = nodeLink
|
|
|
|
+ /* currentNode.data.id=nodeLink.MyChartClassifyId||0
|
|
currentNode.label=nodeName
|
|
currentNode.label=nodeName
|
|
currentNode.data.nodeLink = nodeLink
|
|
currentNode.data.nodeLink = nodeLink
|
|
currentNode.removeTools()
|
|
currentNode.removeTools()
|
|
- if(!currentNode.data.id) return
|
|
|
|
|
|
+ const newId = currentNode.data.id
|
|
|
|
+ const isSetStyle = (oldId===0&&newId!==0)||(oldId!==0&&newId===0)
|
|
|
|
+ isSetStyle&&this.setNodeStyle(newId,currentNode)
|
|
|
|
+ if(!currentNode.data.id) return
|
|
const toolOption = this.getToolOption({chartNum:nodeLink.ChartNum,color:currentNode.attrs.label.fill})
|
|
const toolOption = this.getToolOption({chartNum:nodeLink.ChartNum,color:currentNode.attrs.label.fill})
|
|
- currentNode.addTools(toolOption)
|
|
|
|
|
|
+ currentNode.addTools(toolOption) */
|
|
}else{
|
|
}else{
|
|
//在视口范围内添加节点
|
|
//在视口范围内添加节点
|
|
- const tempNode = this.graph.addNode({
|
|
|
|
- ...baseNode,
|
|
|
|
|
|
+ const nodeStyle = nodeLink.MyChartClassifyId?baseNode:baseNode2
|
|
|
|
+ tempNode = this.graph.addNode({
|
|
|
|
+ ...nodeStyle,
|
|
...{
|
|
...{
|
|
x:position.x+position.width/2+20,
|
|
x:position.x+position.width/2+20,
|
|
y:position.y+position.height/2+20,
|
|
y:position.y+position.height/2+20,
|
|
@@ -147,12 +160,12 @@ export default {
|
|
nodeLink:nodeLink,
|
|
nodeLink:nodeLink,
|
|
},
|
|
},
|
|
label:nodeName,
|
|
label:nodeName,
|
|
- //tools:[this.getToolOption({chartNum:node.nodeLink.ChartNum,color:baseNode.attrs.label.fill})]
|
|
|
|
}})
|
|
}})
|
|
- if(!nodeLink.MyChartClassifyId) return
|
|
|
|
- const toolOption = this.getToolOption({chartNum:nodeLink.ChartNum,color:baseNode.attrs.label.fill})
|
|
|
|
- tempNode.addTools(toolOption)
|
|
|
|
}
|
|
}
|
|
|
|
+ tempNode.removeTools()
|
|
|
|
+ if(!tempNode.data.id) return
|
|
|
|
+ const toolOption = this.getToolOption({chartNum:nodeLink.ChartNum,color:tempNode.attrs.label.fill})
|
|
|
|
+ tempNode.addTools(toolOption)
|
|
},
|
|
},
|
|
//设置节点图分类的数量
|
|
//设置节点图分类的数量
|
|
getToolOption({chartNum,color}){
|
|
getToolOption({chartNum,color}){
|
|
@@ -162,10 +175,20 @@ export default {
|
|
return options
|
|
return options
|
|
},
|
|
},
|
|
//设置有无图分类节点的样式
|
|
//设置有无图分类节点的样式
|
|
- //oldType: 1有图分类,2无图分类
|
|
|
|
- setNodeStyle(oldType){
|
|
|
|
- //oldtype:1 表示节点从无图分类转换成有图分类,节点样式重置为baseNode
|
|
|
|
- //oldtype:2 表示节点从有图分类转换成无图分类,节点样式重置为baseNode2
|
|
|
|
|
|
+ //type: 0 无图分类 非0 有图分类
|
|
|
|
+ //非0 表示节点从无图分类转换成有图分类,节点样式重置为baseNode
|
|
|
|
+ //0 表示节点从有图分类转换成无图分类,节点样式重置为baseNode2
|
|
|
|
+ setNodeStyle(type,node){
|
|
|
|
+ const {attrs={}} = type?baseNode:baseNode2
|
|
|
|
+ const {body,label} = attrs
|
|
|
|
+ const styleMap = {
|
|
|
|
+ 'label/fill':label.fill,
|
|
|
|
+ 'body/fill':body.fill,
|
|
|
|
+ 'body/stroke':body.stroke
|
|
|
|
+ }
|
|
|
|
+ for(let k in styleMap){
|
|
|
|
+ node.attr(k,styleMap[k])
|
|
|
|
+ }
|
|
},
|
|
},
|
|
//点击右键菜单事件
|
|
//点击右键菜单事件
|
|
handleContext(key){
|
|
handleContext(key){
|