|
@@ -26,7 +26,7 @@ import {
|
|
|
import { arrowOptions } from "@/pages/flow/data";
|
|
|
import { useModel } from "umi";
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
|
-import { ImageFillType, ConnectorType } from "@/enum";
|
|
|
+import { ImageFillType, ConnectorType, LineType } from "@/enum";
|
|
|
import { set, cloneDeep } from "lodash-es";
|
|
|
import { Cell } from "@antv/x6";
|
|
|
import { fontFamilyOptions, alignOptionData } from '@/pages/flow/data';
|
|
@@ -113,6 +113,7 @@ export default function GraphStyle() {
|
|
|
|
|
|
useEffect(() => {
|
|
|
const firstNode = selectedCell?.find((item) => item.isNode());
|
|
|
+ const firstEdge = selectedCell?.find((item) => item.isEdge());
|
|
|
eventNodeList.current = [];
|
|
|
if (firstNode) {
|
|
|
const position = firstNode.position();
|
|
@@ -169,6 +170,38 @@ export default function GraphStyle() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(firstEdge) {
|
|
|
+ const data = firstEdge.getData();
|
|
|
+ const attrs = firstEdge.attrs || {};
|
|
|
+ const sourceMarker = attrs.line?.sourceMarker as Record<string, any>;
|
|
|
+ const targetMarker = attrs.line?.targetMarker as Record<string, any>;
|
|
|
+ const lineType = attrs.line?.strokeDasharray === LineType.solid
|
|
|
+ ? "solid"
|
|
|
+ : attrs.line?.strokeDasharray === LineType.dashed
|
|
|
+ ? "dashed"
|
|
|
+ : attrs.line?.strokeDasharray === LineType.dotted
|
|
|
+ ? "dotted"
|
|
|
+ : "dashdot";
|
|
|
+ let obj = {};
|
|
|
+ if(!firstNode) {
|
|
|
+ obj = {
|
|
|
+ stroke: {
|
|
|
+ type: lineType,
|
|
|
+ color: attrs.line?.stroke || "#000000",
|
|
|
+ width: attrs.line?.strokeWidth || 1,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setFormModel((state) => {
|
|
|
+ return {
|
|
|
+ ...state,
|
|
|
+ ...obj,
|
|
|
+ startArrow: sourceMarker?.name,
|
|
|
+ endArrow: targetMarker?.name,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
let nodeCount = 0;
|
|
|
selectedCell?.forEach((cell) => {
|
|
|
if (cell.isEdge()) {
|
|
@@ -195,6 +228,33 @@ export default function GraphStyle() {
|
|
|
opacity: model.opacity,
|
|
|
});
|
|
|
}
|
|
|
+ if (cell.isEdge()) {
|
|
|
+ const attr = cell.attrs;
|
|
|
+ const sourceMarker = attr?.line?.sourceMarker as Record<string, any>;
|
|
|
+ const targetMarker = attr?.line?.targetMarker as Record<string, any>;
|
|
|
+ cell.setAttrs({
|
|
|
+ line: {
|
|
|
+ ...(attr?.line || {}),
|
|
|
+ stroke: model.stroke.color,
|
|
|
+ strokeWidth: model.stroke.width,
|
|
|
+ strokeDasharray: LineType[model.stroke.type],
|
|
|
+ targetMarker: {
|
|
|
+ ...(targetMarker || {}),
|
|
|
+ name: model.endArrow,
|
|
|
+ args: {
|
|
|
+ size: model.stroke.width + 8,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sourceMarker: {
|
|
|
+ ...(sourceMarker || {}),
|
|
|
+ name: model.startArrow,
|
|
|
+ args: {
|
|
|
+ size: model.stroke.width + 8,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
});
|
|
|
};
|
|
|
|