Procházet zdrojové kódy

连线锚点问题

CzRger před 4 měsíci
rodič
revize
af70b57dfa

+ 3 - 1
src/views/workflow/chart/index.vue

@@ -174,7 +174,6 @@ Graph.registerConnector(
     const offset = 6
     const deltaX = Math.abs(e.x - s.x)
     const control = Math.floor((deltaX / 3) * 2)
-
     const v1 = { x: s.x + offset + control, y: s.y }
     const v2 = { x: e.x - offset - control, y: e.y }
     return Path.normalize(
@@ -258,6 +257,8 @@ const initChart = () => {
       //   },
       // },
       connector: 'algo-connector',
+      connectionPoint: 'anchor',
+      anchor: 'center',
       // connector: {
       //   name: 'rounded',
       //   args: {
@@ -269,6 +270,7 @@ const initChart = () => {
         return new Shape.Edge({
           id,
           attrs: lineStyle,
+          zIndex: -1,
           tools: [
             {
               name: 'contextmenu',

+ 9 - 4
src/views/workflow/chart/node-add.vue

@@ -46,14 +46,19 @@ const onAddNode = (type) => {
   const node = getNodeDefault(type)
   const sons = props.graph.getSuccessors(props.node, {breadthFirst: true, deep: false, distance: 1}).filter(v => v.data.workflowData.edgeSource === props.port.id)
   const diff = 100
-  let X = 0
-  let Y = 0
+  let X: any = null
+  let Y: any = null
   if (sons.length > 0) {
     sons.forEach(s => {
       const {x, y} = s.position()
       const {width, height} = s.size()
-      X = Math.max(x, X)
-      Y = Math.max(y + height, Y)
+      if (X === null) {
+        X = x
+        Y = y
+      } else {
+        X = Math.max(x, X)
+        Y = Math.max(y + height, Y)
+      }
     })
     Y += diff
   } else {

+ 1 - 0
src/views/workflow/handle.ts

@@ -104,6 +104,7 @@ export const handleEdge = (ed) => {
     },
     shape: 'edge',
     attrs: lineStyle,
+    zIndex: -1,
     // router: {
     //   name: 'manhattan',
     //   args: {

+ 1 - 1
src/views/workflow/index.vue

@@ -55,7 +55,7 @@ const getJsonData = () => {
   console.log(res)
 }
 const initData = () => {
-  state.workflowData = data3
+  state.workflowData = data1
 }
 onMounted(() => {
   initData()

+ 0 - 1
src/views/workflow/mockJson.ts

@@ -924,7 +924,6 @@ export const data2 = {
     }
   ]
 }
-
 export const data3 = {
   "nodes": [
     {