|
@@ -71,16 +71,16 @@ Graph.registerPortLayout('more', (portsPositionArgs, elemBBox) => {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
})
|
|
})
|
|
-const emits = defineEmits([])
|
|
|
|
|
|
+const emits = defineEmits(['init'])
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
data: <any>{}
|
|
data: <any>{}
|
|
})
|
|
})
|
|
const {proxy}: any = getCurrentInstance()
|
|
const {proxy}: any = getCurrentInstance()
|
|
const state: any = reactive({
|
|
const state: any = reactive({
|
|
graph: null,
|
|
graph: null,
|
|
- isPort: false
|
|
|
|
|
|
+ isPort: false,
|
|
|
|
+ isInitEdges: false
|
|
})
|
|
})
|
|
-provide('graph', state.graph)
|
|
|
|
const ref_chart = ref()
|
|
const ref_chart = ref()
|
|
const workflowFuncInject = inject('workflowFunc', {} as WorkflowFunc)
|
|
const workflowFuncInject = inject('workflowFunc', {} as WorkflowFunc)
|
|
const initChart = () => {
|
|
const initChart = () => {
|
|
@@ -150,21 +150,25 @@ const initChart = () => {
|
|
state.graph.zoomToFit({ maxScale: 1 })
|
|
state.graph.zoomToFit({ maxScale: 1 })
|
|
state.graph.centerContent() // 居中显示
|
|
state.graph.centerContent() // 居中显示
|
|
initWatch()
|
|
initWatch()
|
|
- // positionPort()
|
|
|
|
|
|
+ emits('init', state.graph)
|
|
}
|
|
}
|
|
const initNodes = () => {
|
|
const initNodes = () => {
|
|
props.data.nodes.forEach(v => {
|
|
props.data.nodes.forEach(v => {
|
|
state.graph.addNode(handleNode(v))
|
|
state.graph.addNode(handleNode(v))
|
|
})
|
|
})
|
|
|
|
+
|
|
}
|
|
}
|
|
const initEdges = () => {
|
|
const initEdges = () => {
|
|
- props.data.edges.forEach(v => {
|
|
|
|
- const targetNode = state.graph.getCellById(v.target)
|
|
|
|
- targetNode.setData({
|
|
|
|
- edgeSource: v.port || v.source
|
|
|
|
|
|
+ if (!state.isInitEdges) {
|
|
|
|
+ props.data.edges.forEach(v => {
|
|
|
|
+ const targetNode = state.graph.getCellById(v.target)
|
|
|
|
+ targetNode.setData({
|
|
|
|
+ edgeSource: v.port || v.source
|
|
|
|
+ }, {deep: false})
|
|
|
|
+ state.graph.addEdge(handleEdge(v))
|
|
})
|
|
})
|
|
- state.graph.addEdge(handleEdge(v))
|
|
|
|
- })
|
|
|
|
|
|
+ state.isInitEdges = true
|
|
|
|
+ }
|
|
}
|
|
}
|
|
const initWatch = () => {
|
|
const initWatch = () => {
|
|
state.graph.on('node:click', ({ e, x, y, node, view, port }) => {
|
|
state.graph.on('node:click', ({ e, x, y, node, view, port }) => {
|