From b6468c97166a649147c476767cfc78cd86ac9b41 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期一, 11 三月 2024 08:38:20 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/components/Flow/GrapDrawer.less | 8
zy-asrs-flow/src/components/Flow/GraphConfig.jsx | 12
/dev/null | 15
zy-asrs-flow/package.json | 2
zy-asrs-flow/src/components/Flow/GraphTools copy.jsx | 348 +++++++
zy-asrs-flow/src/components/Flow/GraphDrawer.jsx | 110 ++
zy-asrs-flow/src/components/Flow/GraphComponent.jsx | 1376 ++++++++++++++++++++++++++++++
zy-asrs-flow/src/components/Flow/GraphTools.less | 6
zy-asrs-flow/src/components/Flow/GraphTools2.jsx | 323 +++++++
zy-asrs-flow/src/config/setting.ts | 2
zy-asrs-flow/src/components/Flow/GraphTools.jsx | 446 +++++++++
11 files changed, 2,600 insertions(+), 48 deletions(-)
diff --git a/zy-asrs-flow/package.json b/zy-asrs-flow/package.json
index c8b677d..f8dba02 100644
--- a/zy-asrs-flow/package.json
+++ b/zy-asrs-flow/package.json
@@ -66,6 +66,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet-async": "^1.3.0",
+ "react-syntax-highlighter": "^15.5.0",
"tweedle.js": "^2.1.0"
},
"devDependencies": {
@@ -91,7 +92,6 @@
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^10.5.4",
"mockjs": "^1.1.0",
- "prettier": "^2.8.8",
"react-dev-inspector": "^1.9.0",
"swagger-ui-dist": "^4.19.1",
"ts-node": "^10.9.2",
diff --git a/zy-asrs-flow/src/components/Flow/GrapDrawer.less b/zy-asrs-flow/src/components/Flow/GrapDrawer.less
new file mode 100644
index 0000000..6b98e1b
--- /dev/null
+++ b/zy-asrs-flow/src/components/Flow/GrapDrawer.less
@@ -0,0 +1,8 @@
+.graphDrawerContainer {
+ margin-top: 10px;
+ margin-bottom: 10px;
+}
+
+.graphDrawerContainer>div {
+ margin-top: 10px;
+}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphComponent.jsx b/zy-asrs-flow/src/components/Flow/GraphComponent.jsx
index 50c20e6..1a8bbb0 100644
--- a/zy-asrs-flow/src/components/Flow/GraphComponent.jsx
+++ b/zy-asrs-flow/src/components/Flow/GraphComponent.jsx
@@ -7,7 +7,7 @@
import { Stencil } from '@antv/x6-plugin-stencil';
import { History } from '@antv/x6-plugin-history'
import { Transform } from '@antv/x6-plugin-transform'
-import { commonGraphPorts, commonGraphAttrs, initGraphConnecting } from "./GraphConfig";
+import { commonGraphPorts, commonGraphAttrs, initGraphConnecting, initNodeData } from "./GraphConfig";
export const GraphComponent = React.forwardRef((props, ref) => {
const container = useRef(null);
@@ -41,6 +41,7 @@
label: '璁㈠崟绠$悊',
ports: commonGraphPorts,
attrs: commonGraphAttrs,
+ data: initNodeData,
});
const rect2 = graph.addNode({
@@ -51,6 +52,7 @@
label: '搴撳瓨绠$悊',
ports: commonGraphPorts,
attrs: commonGraphAttrs,
+ data: initNodeData,
});
graph.use(
@@ -77,11 +79,1347 @@
graph.use(
new Transform({
- resizing: {
- enabled: true
- },
+ resizing: {
+ enabled: true
+ },
}),
- )
+ )
+
+
+ graph.fromJSON({
+ "cells": [
+ {
+ "shape": "edge",
+ "attrs": {
+ "line": {
+ "stroke": "#A2B1C3",
+ "targetMarker": {
+ "name": "block",
+ "width": 12,
+ "height": 8
+ }
+ }
+ },
+ "id": "2475ea4f-f0e3-4b44-add4-7d4950ddea45",
+ "zIndex": 0,
+ "source": {
+ "cell": "71d8bc90-558f-489f-b432-a03d7af27cdc",
+ "port": "port2"
+ },
+ "target": {
+ "cell": "c5798537-a8a0-4d79-bd76-a4f663492126",
+ "port": "port1"
+ },
+ "data": {
+ "codeContent": null,
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "labels": [
+ {
+ "attrs": {
+ "label": {
+ "text": ""
+ }
+ }
+ }
+ ]
+ },
+ {
+ "shape": "edge",
+ "attrs": {
+ "line": {
+ "stroke": "#A2B1C3",
+ "targetMarker": {
+ "name": "block",
+ "width": 12,
+ "height": 8
+ }
+ }
+ },
+ "id": "2c3744b4-45ce-44a6-b169-402eaec24174",
+ "zIndex": 0,
+ "source": {
+ "cell": "c5798537-a8a0-4d79-bd76-a4f663492126",
+ "port": "port2"
+ },
+ "target": {
+ "cell": "3ca188b2-9ffe-4528-ba6e-c1568b6d7fe6",
+ "port": "port1"
+ },
+ "data": {
+ "codeContent": null,
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "labels": [
+ {
+ "attrs": {
+ "label": {
+ "text": ""
+ }
+ }
+ }
+ ]
+ },
+ {
+ "shape": "edge",
+ "attrs": {
+ "line": {
+ "stroke": "#A2B1C3",
+ "targetMarker": {
+ "name": "block",
+ "width": 12,
+ "height": 8
+ }
+ }
+ },
+ "id": "56181ccf-a41c-4cd8-82d6-e2a4bde31ba9",
+ "zIndex": 0,
+ "source": {
+ "cell": "3ca188b2-9ffe-4528-ba6e-c1568b6d7fe6",
+ "port": "port2"
+ },
+ "target": {
+ "cell": "63db5ce0-b916-44e4-a924-a79b35afe1d1",
+ "port": "port1"
+ },
+ "data": {
+ "codeContent": null,
+ "root": false,
+ "isLogic": false,
+ "logicBool": true,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "labels": [
+ {
+ "attrs": {
+ "label": {
+ "text": "true"
+ }
+ }
+ }
+ ]
+ },
+ {
+ "shape": "edge",
+ "attrs": {
+ "line": {
+ "stroke": "#A2B1C3",
+ "targetMarker": {
+ "name": "block",
+ "width": 12,
+ "height": 8
+ }
+ }
+ },
+ "id": "73ca24ef-e9d4-4f18-9f06-ca49ac65962a",
+ "zIndex": 0,
+ "source": {
+ "cell": "cc993d9b-ce11-409d-92c6-7208682dcc8b",
+ "port": "port4"
+ },
+ "target": {
+ "cell": "06d450fc-474e-4b23-b40d-c89fde446b28",
+ "port": "port3"
+ },
+ "data": {
+ "codeContent": null,
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "labels": [
+ {
+ "attrs": {
+ "label": {
+ "text": "false"
+ }
+ }
+ }
+ ]
+ },
+ {
+ "shape": "edge",
+ "attrs": {
+ "line": {
+ "stroke": "#A2B1C3",
+ "targetMarker": {
+ "name": "block",
+ "width": 12,
+ "height": 8
+ }
+ }
+ },
+ "id": "84a3a77c-79e8-4cf8-9bab-a72bbfc77f1d",
+ "zIndex": 0,
+ "source": {
+ "cell": "cc993d9b-ce11-409d-92c6-7208682dcc8b",
+ "port": "port2"
+ },
+ "target": {
+ "cell": "cd9da0a4-5c2d-4f1b-9c51-403b32f1ad51",
+ "port": "port1"
+ },
+ "data": {
+ "codeContent": null,
+ "root": false,
+ "isLogic": false,
+ "logicBool": true,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "labels": [
+ {
+ "attrs": {
+ "label": {
+ "text": "true"
+ }
+ }
+ }
+ ]
+ },
+ {
+ "shape": "edge",
+ "attrs": {
+ "line": {
+ "stroke": "#A2B1C3",
+ "targetMarker": {
+ "name": "block",
+ "width": 12,
+ "height": 8
+ }
+ }
+ },
+ "id": "93d65ae7-f170-466a-92ea-f69614002800",
+ "zIndex": 0,
+ "source": {
+ "cell": "c844f3d1-02a3-47d3-bcb9-51027c1deb1c",
+ "port": "port2"
+ },
+ "target": {
+ "cell": "cc993d9b-ce11-409d-92c6-7208682dcc8b",
+ "port": "port1"
+ },
+ "data": {
+ "codeContent": null,
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "labels": [
+ {
+ "attrs": {
+ "label": {
+ "text": ""
+ }
+ }
+ }
+ ]
+ },
+ {
+ "shape": "edge",
+ "attrs": {
+ "line": {
+ "stroke": "#A2B1C3",
+ "targetMarker": {
+ "name": "block",
+ "width": 12,
+ "height": 8
+ }
+ }
+ },
+ "id": "de85103e-80ac-4c88-92de-5bb1a131788c",
+ "zIndex": 0,
+ "source": {
+ "cell": "63db5ce0-b916-44e4-a924-a79b35afe1d1",
+ "port": "port2"
+ },
+ "target": {
+ "cell": "c844f3d1-02a3-47d3-bcb9-51027c1deb1c",
+ "port": "port1"
+ },
+ "data": {
+ "codeContent": null,
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "labels": [
+ {
+ "attrs": {
+ "label": {
+ "text": ""
+ }
+ }
+ }
+ ]
+ },
+ {
+ "position": {
+ "x": 60,
+ "y": 60
+ },
+ "size": {
+ "width": 120,
+ "height": 40
+ },
+ "attrs": {
+ "text": {
+ "text": "璁㈠崟绠$悊"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "strokeWidth": 2,
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "rect",
+ "id": "a4962b5d-6ef0-4217-bbf8-742652ffc0ee",
+ "data": {
+ "codeContent": null,
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 1,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ },
+ {
+ "position": {
+ "x": 260,
+ "y": 390
+ },
+ "size": {
+ "width": 120,
+ "height": 40
+ },
+ "attrs": {
+ "text": {
+ "text": "搴撳瓨绠$悊"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "strokeWidth": 2,
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "rect",
+ "id": "63db5ce0-b916-44e4-a924-a79b35afe1d1",
+ "data": {
+ "codeContent": "2222",
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 2,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ },
+ {
+ "position": {
+ "x": 270,
+ "y": 265
+ },
+ "size": {
+ "width": 100,
+ "height": 60
+ },
+ "attrs": {
+ "text": {
+ "text": "閫昏緫鍒ゆ柇1"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "path",
+ "id": "3ca188b2-9ffe-4528-ba6e-c1568b6d7fe6",
+ "data": {
+ "codeContent": "閫昏緫鍒ゆ柇1",
+ "root": false,
+ "isLogic": true,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 3,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ },
+ {
+ "position": {
+ "x": 300,
+ "y": 30
+ },
+ "size": {
+ "width": 80,
+ "height": 40
+ },
+ "attrs": {
+ "text": {
+ "text": "绋嬪簭鍏ュ彛"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "strokeWidth": 2,
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "rect",
+ "id": "71d8bc90-558f-489f-b432-a03d7af27cdc",
+ "data": {
+ "codeContent": null,
+ "root": true,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 4,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ },
+ {
+ "position": {
+ "x": 300,
+ "y": 110
+ },
+ "size": {
+ "width": 80,
+ "height": 40
+ },
+ "attrs": {
+ "text": {
+ "text": "甯哥敤缁勪欢"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "strokeWidth": 2,
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "rect",
+ "id": "c5798537-a8a0-4d79-bd76-a4f663492126",
+ "data": {
+ "codeContent": "1111",
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 5,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ },
+ {
+ "position": {
+ "x": 280,
+ "y": 511
+ },
+ "size": {
+ "width": 80,
+ "height": 40
+ },
+ "attrs": {
+ "text": {
+ "text": "甯哥敤缁勪欢2"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "strokeWidth": 2,
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "rect",
+ "id": "c844f3d1-02a3-47d3-bcb9-51027c1deb1c",
+ "data": {
+ "codeContent": "甯哥敤缁勪欢2",
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 6,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ },
+ {
+ "position": {
+ "x": 270,
+ "y": 620
+ },
+ "size": {
+ "width": 100,
+ "height": 60
+ },
+ "attrs": {
+ "text": {
+ "text": "閫昏緫鍒ゆ柇2"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "path",
+ "id": "cc993d9b-ce11-409d-92c6-7208682dcc8b",
+ "data": {
+ "codeContent": "閫昏緫鍒ゆ柇2",
+ "root": false,
+ "isLogic": true,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 7,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ },
+ {
+ "position": {
+ "x": 280,
+ "y": 781
+ },
+ "size": {
+ "width": 80,
+ "height": 40
+ },
+ "attrs": {
+ "text": {
+ "text": "甯哥敤缁勪欢3"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "strokeWidth": 2,
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "rect",
+ "id": "cd9da0a4-5c2d-4f1b-9c51-403b32f1ad51",
+ "data": {
+ "codeContent": "甯哥敤缁勪欢3",
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 8,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ },
+ {
+ "position": {
+ "x": 472,
+ "y": 640
+ },
+ "size": {
+ "width": 80,
+ "height": 40
+ },
+ "attrs": {
+ "text": {
+ "text": "甯哥敤缁勪欢4"
+ },
+ "body": {
+ "fill": "#efefef",
+ "stroke": "#4d4d4d",
+ "strokeWidth": 2,
+ "refD": "M 50 0 L 100 50 L 50 100 L 0 50 Z"
+ }
+ },
+ "visible": true,
+ "shape": "rect",
+ "id": "06d450fc-474e-4b23-b40d-c89fde446b28",
+ "data": {
+ "codeContent": "甯哥敤缁勪欢4",
+ "root": false,
+ "isLogic": false,
+ "logicBool": false,
+ "searchLogicId": 1,
+ "searchLogicBool": true,
+ "searchIndex": 0
+ },
+ "zIndex": 9,
+ "ports": {
+ "groups": {
+ "top": {
+ "position": "top",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "bottom": {
+ "position": "bottom",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "left": {
+ "position": "left",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ },
+ "right": {
+ "position": "right",
+ "attrs": {
+ "circle": {
+ "r": 5,
+ "magnet": true,
+ "stroke": "#5F95FF",
+ "strokeWidth": 1,
+ "fill": "#fff",
+ "style": {
+ "visibility": "hidden"
+ }
+ }
+ }
+ }
+ },
+ "items": [
+ {
+ "id": "port1",
+ "group": "top"
+ },
+ {
+ "id": "port2",
+ "group": "bottom"
+ },
+ {
+ "id": "port3",
+ "group": "left"
+ },
+ {
+ "id": "port4",
+ "group": "right"
+ }
+ ]
+ }
+ }
+ ]
+ })
+
props.initHandle();//閫氱煡鐖剁粍浠跺垵濮嬪寲瀹屾垚
return graph;
@@ -108,25 +1446,43 @@
stencilContainer.current.appendChild(stencil.container)
+ const n1Data = JSON.parse(JSON.stringify(initNodeData))
+ n1Data.root = true;//璁剧疆涓烘牴鑺傜偣
const n1 = graph.createNode({
shape: "rect",
width: 80,
height: 40,
- label: "榛樿缁勪欢",
+ label: "绋嬪簭鍏ュ彛",
attrs: commonGraphAttrs,
- ports: commonGraphPorts
+ ports: commonGraphPorts,
+ data: n1Data,
})
const n2 = graph.createNode({
shape: "rect",
width: 80,
height: 40,
- label: "娴嬭瘯缁勪欢",
+ label: "甯哥敤缁勪欢",
attrs: commonGraphAttrs,
- ports: commonGraphPorts
+ ports: commonGraphPorts,
+ data: initNodeData,
})
- stencil.load([n1, n2], 'group1')
+ const n3Data = JSON.parse(JSON.stringify(initNodeData))
+ n3Data.isLogic = true;//閫昏緫鍒ゆ柇
+ const n3 = graph.createNode({
+ shape: 'path',
+ width: 100,
+ height: 60,
+ // https://www.svgrepo.com/svg/13653/like
+ path: 'M 50 0 L 100 50 L 50 100 L 0 50 Z',
+ attrs: commonGraphAttrs,
+ label: '閫昏緫鍒ゆ柇',
+ ports: commonGraphPorts,
+ data: n3Data,
+ })
+
+ stencil.load([n1, n2, n3], 'group1')
}
function initBind(graph) {
diff --git a/zy-asrs-flow/src/components/Flow/GraphConfig.jsx b/zy-asrs-flow/src/components/Flow/GraphConfig.jsx
index 4f8bf75..9e41776 100644
--- a/zy-asrs-flow/src/components/Flow/GraphConfig.jsx
+++ b/zy-asrs-flow/src/components/Flow/GraphConfig.jsx
@@ -127,4 +127,14 @@
},
}
-export { commonGraphPorts, commonGraphAttrs, initGraphConnecting }
\ No newline at end of file
+const initNodeData = {
+ codeContent: null,
+ root: false,//榛樿涓嶆槸鏍硅妭鐐�
+ isLogic: false,//榛樿涓嶆槸閫昏緫鍒ゆ柇
+ logicBool: false,//閫昏緫鍒ゆ柇榛樿鍊�
+ searchLogicId: 1,//榛樿閫昏緫id
+ searchLogicBool: true,//榛樿閫昏緫id鏂瑰悜
+ searchIndex: 0,//榛樿鎵ц浼樺厛绾�
+}
+
+export { commonGraphPorts, commonGraphAttrs, initGraphConnecting, initNodeData }
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphDrawer.jsx b/zy-asrs-flow/src/components/Flow/GraphDrawer.jsx
index 00cd43f..df442c5 100644
--- a/zy-asrs-flow/src/components/Flow/GraphDrawer.jsx
+++ b/zy-asrs-flow/src/components/Flow/GraphDrawer.jsx
@@ -1,31 +1,89 @@
import React, { useRef, useEffect, useState } from "react";
-import { Button, Drawer, Input } from 'antd';
+import { Button, Drawer, Input, Switch } from 'antd';
+import { initNodeData } from "./GraphConfig";
+import './GrapDrawer.less';
const { TextArea } = Input;
export const GraphDrawer = ({ graphRef, isReady }) => {
const [open, setOpen] = useState(false);
-
const [init, setInit] = useState(false);
-
const [nodeData, setNodeData] = useState(null);
+ const [edgeData, setEdgeData] = useState(null);
+ const [codeContent, setCodeContent] = useState(null);
- const [codeContent,setCodeContent] = useState(null);
-
- const showDrawer = (graph, node) => {
+ const showNodeDrawer = (graph, node) => {
setOpen(true);
setNodeData(node);
+ if (node.data == null) {
+ node.data = initNodeData;
+ }
+
+ if (node.data.codeContent != null) {
+ setCodeContent(node.data.codeContent);
+ }
};
- const onClose = (e) => {
+ const showEdgeDrawer = (graph, edge) => {
+ setOpen(true);
+ setEdgeData(edge);
+ if (edge.data == null) {
+ edge.data = initNodeData;
+ }
+
+ if (edge.data.codeContent != null) {
+ setCodeContent(edge.data.codeContent);
+ }
+
+ if (edge.labels.length == 0) {
+ edge.appendLabel({
+ attrs: {
+ label: {
+ text: ""
+ }
+ }
+ })
+ }
+
+ }
+
+ const onNodeClose = (e) => {
setOpen(false);
setNodeData(null);
- console.log(codeContent);
+ setCodeContent(null);
};
- const textAreaChange = (e) => {
+ const onEdgeClose = (e) => {
+ setOpen(false);
+ setEdgeData(null);
+ setCodeContent(null);
+ };
+
+ const nodeTextAreaChange = (e) => {
setCodeContent(e.target.value);
+ nodeData.data.codeContent = e.target.value;
+ }
+
+ const edgeTextAreaChange = (e) => {
+ setCodeContent(e.target.value);
+ edgeData.data.codeContent = e.target.value;
+ }
+
+ const nodeDataInputChange = (e) => {
+ nodeData.label = e.target.value;
+ }
+
+ const edgeDataInputChange = (e) => {
+ edgeData.removeLabelAt(0);
+ edgeData.appendLabel({
+ attrs: {
+ label: {
+ text: e.target.value
+ }
+ }
+ })
+ edgeData.data.logicBool = e.target.value == 'true' ? true : false;
}
useEffect(() => {
@@ -34,21 +92,41 @@
if (!init) {
graph.on("node:dblclick", ({ node }) => {
- console.log(node);
- showDrawer(graph, node);
+ showNodeDrawer(graph, node);
+ })
+ graph.on("edge:dblclick", ({ edge }) => {
+ showEdgeDrawer(graph, edge);
})
setInit(true);
}
}
})
- if(nodeData){
+ if (nodeData) {
return (
<>
- <Drawer title={nodeData.label} onClose={onClose} open={open} size="large">
- <p>ID锛歿nodeData.id}</p>
- <p>鍙墽琛屼唬鐮侊細</p>
- <TextArea onChange={textAreaChange} rows={10} />
+ <Drawer title={nodeData.label} onClose={onNodeClose} open={open} size="large">
+ <div className="graphDrawerContainer">
+ <div>ID锛歿nodeData.id}</div>
+ <div>缁勪欢鍚嶏細<Input defaultValue={nodeData.label} onChange={nodeDataInputChange} /></div>
+ <div>鏍硅妭鐐癸細<Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={nodeData.data.root} /></div>
+ <div>鍙墽琛屼唬鐮侊細</div>
+ <TextArea value={codeContent} onChange={nodeTextAreaChange} rows={10} />
+ </div>
+ </Drawer>
+ </>
+ );
+ } else if (edgeData) {
+ return (
+ <>
+ <Drawer title={edgeData.label} onClose={onEdgeClose} open={open} size="large">
+ <div className="graphDrawerContainer">
+ <div>ID锛歿edgeData.id}</div>
+ <div>灞炴�ц鎯咃細<Input defaultValue={edgeData.labels[0].attrs.label.text} onChange={edgeDataInputChange} /></div>
+ <div>鏍硅妭鐐癸細<Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={edgeData.data.root} /></div>
+ <div>鍙墽琛屼唬鐮侊細</div>
+ <TextArea value={codeContent} onChange={edgeTextAreaChange} rows={10} />
+ </div>
</Drawer>
</>
);
diff --git a/zy-asrs-flow/src/components/Flow/GraphTools copy.jsx b/zy-asrs-flow/src/components/Flow/GraphTools copy.jsx
new file mode 100644
index 0000000..79c198a
--- /dev/null
+++ b/zy-asrs-flow/src/components/Flow/GraphTools copy.jsx
@@ -0,0 +1,348 @@
+import React, { useRef, useEffect, useState } from "react";
+import { Button, message } from 'antd';
+import { last } from "lodash";
+
+export const GraphTools = ({ graphRef, isReady }) => {
+
+ let codeContent = "";
+
+ const exportData = () => {
+ const graph = graphRef.current;
+ if (isReady) {
+ const data = graph.toJSON();
+ console.log(data);
+ // 杩欓噷浣犲彲浠ュ皢鏁版嵁鍙戦�佸埌鏈嶅姟鍣ㄦ垨淇濆瓨鍒版湰鍦�
+
+ const edges = [];
+ const nodes = [];
+ let rootNode = null;
+ data.cells.forEach((item) => {
+ if (item.shape == "edge") {
+ edges.push(item)
+ } else {
+ nodes.push(item)
+ if (item.data.root) {
+ rootNode = item;
+ }
+ }
+ })
+
+ if (rootNode == null) {
+ message.warning('璇疯缃▼搴忓叆鍙g粍浠�');
+ return;
+ }
+
+ console.log(getDescendants(rootNode, nodes, graph));
+
+ transCode(rootNode, nodes, graph)
+ // nodeDFS(rootNode, nodes, graph, codeContent)
+ // console.log(codeContent);
+ }
+ }
+
+ const transCode = (rootNode, nodes, graph) => {
+ let codeContent = "";
+ const descendants = [];
+ let stack = [rootNode];
+
+ let existLogicNode = [];
+ let values = nodeDFS(rootNode, nodes, graph);
+
+ let cpValues = JSON.parse(JSON.stringify(values))
+ console.log(cpValues);
+
+ let groupCode = {};
+ let logicGroupSearch = [];
+ let currentLogic = null;
+ cpValues.forEach((value) => {
+ if (value.data.isLogic) {
+ let tmp = {};
+ if (currentLogic == null) {
+ tmp = {
+ id: value.id,
+ parent: null,
+ currentCode: ""
+ }
+ } else {
+ tmp = {
+ id: value.id,
+ parent: currentLogic,
+ currentCode: ""
+ }
+ }
+ currentLogic = value.id;
+ logicGroupSearch.push(tmp);
+ }
+ })
+
+ console.log(cpValues);
+ console.log(logicGroupSearch);
+
+ let codeContentTmp = "";
+ while (values.length > 0) {
+ const current = values.pop();
+ const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
+
+ connectedEdges.forEach((edge) => {
+ //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
+ if (edge.source.cell != current.id) {
+ //鍙栦笂涓�鑺傜偣
+ let lastNode = null;
+ nodes.forEach((node) => {
+ if (node.id == edge.source.cell) {
+ lastNode = node;
+ }
+ })
+
+ if (lastNode != null) {
+ //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
+ if (lastNode.data.isLogic) {
+ let nestedCode = `
+ //**********${current.attrs.text.text}-start**********//
+ ${current.data.codeContent}
+ //**********${current.attrs.text.text}-end**********//
+ `;
+ codeContentTmp = "\n" + nestedCode + codeContentTmp;
+
+ let nestedIfCode = `
+ ${codeContentTmp}
+ `;
+
+ if (groupCode[lastNode.id] == null) {
+ groupCode[lastNode.id] = [{
+ code: nestedIfCode,
+ logicBool: edge.data.logicBool,
+ condition: lastNode.data.codeContent
+ }];
+ } else {
+ groupCode[lastNode.id].push({
+ code: nestedIfCode,
+ logicBool: edge.data.logicBool,
+ condition: lastNode.data.codeContent
+ });
+ }
+
+ codeContent += nestedIfCode;
+ codeContentTmp = "";
+
+ console.log(lastNode, current, true, codeContent);
+ } else {
+ if (current.data.codeContent != null && !current.data.isLogic) {
+ let nestedCode = `
+ //**********${current.attrs.text.text}-start**********//
+ ${current.data.codeContent}
+ //**********${current.attrs.text.text}-end**********//
+ `;
+ codeContentTmp = "\n" + nestedCode + codeContentTmp;
+ }
+ }
+ }
+ }
+ })
+
+ }
+
+ for (let i = logicGroupSearch.length - 1; i >= 0; i--) {
+ let logic = logicGroupSearch[i];
+ let logicGroup = groupCode[logic.id];
+
+ let logic1 = logicGroup[0];
+ let nestedIfCode = "";
+
+ if (logicGroup.length > 1) {
+ let logic2 = logicGroup[0];
+
+ if (logic1.logicBool) {
+ nestedIfCode = `
+ if (${logic1.condition}) {
+ ${logic1.code}
+ }else {
+ ${logic2.code}
+ }
+ `;
+ } else {
+ nestedIfCode = `
+ if (!(${logic1.condition})) {
+ ${logic1.code}
+ }else {
+ ${logic2.code}
+ }
+ `;
+ }
+ }
+
+ if (logic.parent != null) {
+ logicGroupSearch.forEach((item) => {
+ if (item.id == logic.parent) {
+ item.currentCode += nestedIfCode;
+ }
+ })
+ }
+
+ console.log(logicGroupSearch,nestedIfCode);
+ }
+
+ console.log(groupCode);
+ console.log(codeContent);
+
+ }
+
+ // const transCode = (rootNode, nodes, graph) => {
+ // let codeContent = "";
+ // const descendants = [];
+ // let stack = [rootNode];
+
+ // let count = 0;
+ // while (stack.length > 0) {
+ // const current = stack.pop();
+ // descendants.push(current);
+
+ // const children = getChildren(current, nodes, graph);
+ // stack.push(...children);
+
+ // // 杈撳嚭浠g爜
+ // if (!current.data.isLogic) {
+ // const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
+ // connectedEdges.forEach((edge) => {
+ // //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
+ // if(edge.source.cell != current.id){
+ // //鍙栦笂涓�鑺傜偣
+ // let lastNode = null;
+ // nodes.forEach((node) => {
+ // if(node.id == edge.source.cell){
+ // lastNode = node;
+ // }
+ // })
+
+ // if(lastNode != null) {
+ // //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
+ // if(lastNode.data.isLogic){
+ // console.log(lastNode);
+ // let nestedIfCode = "";
+ // if(lastNode.data.logicBool == 'true') {
+ // nestedIfCode = `
+ // if (${lastNode.data.codeContent}) {
+ // ${current.data.codeContent}
+ // }
+ // `;
+ // }else{
+ // nestedIfCode = `
+ // if (!(${lastNode.data.codeContent})) {
+ // ${current.data.codeContent}
+ // }
+ // `;
+ // }
+
+
+ // codeContent += "\n" + nestedIfCode;
+ // console.log(codeContent);
+ // }else{
+ // if (current.data.codeContent != null) {
+ // codeContent += "\n" + current.data.codeContent;
+ // }
+ // }
+ // }
+ // }
+ // console.log(current);
+ // })
+ // } else {
+ // // if (current.data.codeContent != null) {
+ // // codeContent += "\n" + current.data.codeContent;
+ // // }
+
+ // // const connectedEdges = graph.getConnectedEdges(current);
+ // // console.log(connectedEdges);
+ // // stack = []
+ // // let test = []
+ // // connectedEdges.forEach((edge) => {
+ // // nodes.forEach((item) => {
+ // // if (item.id === edge.target.cell && item.id != current.id) {
+ // // test.push(item);
+ // // }
+ // // })
+ // // });
+ // // console.log(test);
+ // // console.log();
+ // // let nestedIfCode = `
+ // // if (true}) {
+ // // ${current.data.codeContent}
+ // // }
+ // // `;
+
+ // // codeContent += "\n" + nestedIfCode;
+ // // console.log(codeContent);
+ // }
+
+ // }
+
+ // console.log(codeContent);
+ // }
+
+ const nodeDFS = (node, nodes, graph) => {
+ let values = [];
+ if (graph) {
+ const connectedEdges = graph.getConnectedEdges(node);
+ const children = [];
+
+ console.log(node);
+ connectedEdges.forEach((edge) => {
+ nodes.forEach((item) => {
+ if (item.id === edge.target.cell && item.id != node.id) {
+ children.push(item);
+ }
+ })
+ });
+
+ console.log(connectedEdges);
+ if (children.length != 0) {
+ console.log(children);
+ children.forEach((node) => {
+ console.log(node);
+ values.push(node);
+ values = values.concat(nodeDFS(node, nodes, graph))
+ })
+ }
+ }
+
+ return values;
+ }
+
+ const getChildren = (node, nodes, graph) => {
+ const connectedEdges = graph.getConnectedEdges(node);
+ const children = [];
+
+ connectedEdges.forEach((edge) => {
+ nodes.forEach((item) => {
+ if (item.id === edge.target.cell && item.id != node.id) {
+ children.push(item);
+ }
+ })
+ });
+
+ return children;
+ }
+
+ const getDescendants = (node, nodes, graph) => {
+ const descendants = [];
+ const stack = [node];
+
+ let count = 0;
+ while (stack.length > 0) {
+ const current = stack.pop();
+ descendants.push(current);
+
+ const children = getChildren(current, nodes, graph);
+ stack.push(...children);
+ }
+
+ return descendants;
+ }
+
+ return (
+ <>
+ <Button type="primary" onClick={exportData}>
+ 瀵煎嚭鏁版嵁
+ </Button>
+ </>
+ );
+}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphTools.jsx b/zy-asrs-flow/src/components/Flow/GraphTools.jsx
index 60d5d83..e8d6518 100644
--- a/zy-asrs-flow/src/components/Flow/GraphTools.jsx
+++ b/zy-asrs-flow/src/components/Flow/GraphTools.jsx
@@ -1,7 +1,54 @@
import React, { useRef, useEffect, useState } from "react";
-import { Button } from 'antd';
+import { Button, message, Modal } from 'antd';
+import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
+import { solarizedlight } from 'react-syntax-highlighter/dist/esm/styles/prism';
+import './GraphTools.less'
export const GraphTools = ({ graphRef, isReady }) => {
+
+ const [isModalOpen, setIsModalOpen] = useState(false);
+ const [preCode, setPreCode] = useState(null);
+
+ const handleOk = () => {
+ setIsModalOpen(false);
+ };
+
+ const handleCancel = () => {
+ setIsModalOpen(false);
+ };
+
+ //棰勮浠g爜
+ const prewCode = () => {
+ const graph = graphRef.current;
+ if (isReady) {
+ const data = graph.toJSON();
+
+ const edges = [];
+ const nodes = [];
+ let rootNode = null;
+ data.cells.forEach((item) => {
+ if (item.shape == "edge") {
+ edges.push(item)
+ } else {
+ nodes.push(item)
+ if (item.data.root) {
+ rootNode = item;
+ }
+ }
+ })
+
+ if (rootNode == null) {
+ message.warning('璇疯缃▼搴忓叆鍙g粍浠�');
+ return;
+ }
+
+ const codeContent = transCode(rootNode, nodes, graph)
+ console.log(codeContent);
+
+ setPreCode(codeContent);
+ setIsModalOpen(true);
+ }
+ }
const exportData = () => {
const graph = graphRef.current;
@@ -9,14 +56,405 @@
const data = graph.toJSON();
console.log(data);
// 杩欓噷浣犲彲浠ュ皢鏁版嵁鍙戦�佸埌鏈嶅姟鍣ㄦ垨淇濆瓨鍒版湰鍦�
+
+ const edges = [];
+ const nodes = [];
+ let rootNode = null;
+ data.cells.forEach((item) => {
+ if (item.shape == "edge") {
+ edges.push(item)
+ } else {
+ nodes.push(item)
+ if (item.data.root) {
+ rootNode = item;
+ }
+ }
+ })
+
+ if (rootNode == null) {
+ message.warning('璇疯缃▼搴忓叆鍙g粍浠�');
+ return;
+ }
+
+ console.log(getDescendants(rootNode, nodes, graph));
+
+ const codeContent = transCode(rootNode, nodes, graph)
+ console.log(codeContent);
}
+ }
+
+ const transCode = (rootNode, nodes, graph) => {
+ let codeContent = "";
+ let values = nodeDFS(rootNode, nodes, graph);
+ const searchNode = {
+ id: 1,
+ parent: null,
+ logicBool: true
+ };
+
+ let cpValues = JSON.parse(JSON.stringify(values))
+ console.log(cpValues);
+
+ let searchIndex = 0;
+ cpValues.forEach((value) => {
+ if (value.data.isLogic) {
+ value.data.searchLogicId = searchNode.id;
+ value.data.searchLogicBool = searchNode.logicBool;
+ value.data.searchIndex = searchIndex++;
+
+ let tmpSearchNode = JSON.parse(JSON.stringify(searchNode))
+ searchNode.parent = tmpSearchNode;
+ searchNode.id = value.id;
+ searchNode.logicBool = null;
+ searchIndex = 0;
+ } else {
+ let id = searchNode.id;
+ let logicBool = searchNode.logicBool;
+
+ const connectedEdges = graph.getConnectedEdges(value);//鍙栬竟
+ connectedEdges.forEach((edge) => {
+ let tmpSearchNode = JSON.parse(JSON.stringify(searchNode));
+ while (tmpSearchNode.parent != null) {
+ if (edge.source.cell == tmpSearchNode.id) {
+ logicBool = edge.data.logicBool;//鏇存柊鏂瑰悜
+ searchNode.logicBool = edge.data.logicBool;
+ id = tmpSearchNode.id;
+ break;
+ }
+ tmpSearchNode = tmpSearchNode.parent;
+ }
+ })
+
+ value.data.searchLogicId = id;
+ value.data.searchLogicBool = logicBool;
+ value.data.searchIndex = searchIndex++;
+ }
+ })
+
+ console.log(cpValues);
+ console.log(searchNode);
+
+ let tmp = {}
+ let tmpList = []
+ let tmpIndex = 0;
+ for (let i = cpValues.length - 1; i >= 0; i--) {
+ let item = cpValues[i];
+ if (tmp[item.data.searchLogicId] == null) {
+ tmpList[tmpIndex] = [item];
+ tmp[item.data.searchLogicId] = {
+ index: tmpIndex,
+ code: "",
+ codeTrue: "",
+ codeFalse: "",
+ condition: ""
+ };
+ tmpIndex++;
+ } else {
+ tmpList[tmp[item.data.searchLogicId].index].push(item);
+ }
+ }
+
+ console.log(tmp, tmpList);
+
+ tmpList.forEach((item) => {
+ item.forEach((val) => {
+ let originCode = tmp[val.data.searchLogicId].codeTrue;
+ if (!val.data.searchLogicBool) {
+ originCode = tmp[val.data.searchLogicId].codeFalse;
+ }
+
+ let codeContent = val.data.codeContent;
+
+ if (val.data.isLogic) {
+ codeContent = val.id + "_logic_tag";
+ console.log(val.data);
+ tmp[val.id].condition = val.data.codeContent;
+ } else {
+ codeContent = `
+ //**********${val.attrs.text.text}-start**********//
+ ${codeContent}
+ //**********${val.attrs.text.text}-start**********//
+ `;
+ }
+ let newCode = `
+ ${codeContent}
+
+ ${originCode}
+ `;
+
+ console.log(newCode);
+ if (val.data.searchLogicBool) {
+ tmp[val.data.searchLogicId].codeTrue = newCode;
+ } else {
+ tmp[val.data.searchLogicId].codeFalse = newCode;
+ }
+ })
+ })
+
+ let sortTmp = [];
+ for (var key in tmp) {
+ let obj = tmp[key];
+ obj.id = key;
+ sortTmp[tmp[key].index] = obj;
+ }
+
+ // 鍚堝苟True鍜孎alse
+ sortTmp.forEach((item) => {
+ let nestedIfCode = "";
+ if (item.condition == "") {
+ nestedIfCode = `
+ ${item.codeTrue}
+ ${item.codeFalse}
+ `;
+ } else {
+ nestedIfCode = `
+ if(${item.condition}){
+ // 閫昏緫TRUE
+ ${item.codeTrue}
+ }else {
+ // 閫昏緫FALSE
+ ${item.codeFalse}
+ }
+ `;
+ }
+
+ item.code = nestedIfCode;
+ })
+
+ console.log(sortTmp);
+
+ let finalTmp = {};
+ let sortTmpCopy = JSON.parse(JSON.stringify(sortTmp));
+ sortTmpCopy.forEach((item) => {
+ if (item.id != "1") {
+ let codeContent = item.code;
+ sortTmp.forEach((val) => {
+ codeContent = codeContent.replace(val.id + "_logic_tag", val.code);
+ console.log(item, val.id, codeContent);
+ })
+ finalTmp[item.id] = {
+ code: codeContent
+ }
+ }
+ })
+
+ console.log(sortTmpCopy);
+ console.log(finalTmp);
+
+ sortTmpCopy.forEach((item) => {
+ if (item.id == "1") {
+ let finalCode = item.code;
+ for (var key in finalTmp) {
+ let obj = finalTmp[key];
+ finalCode = finalCode.replace(key + "_logic_tag", obj.code);
+ }
+
+ codeContent = finalCode;
+ }
+ })
+
+ codeContent = formatJavaCode(codeContent)
+ return codeContent;
+ }
+
+ const formatJavaCode = (codeString) => {
+ let baseIndentation = " "; //鐢ㄥ洓涓┖鏍艰〃绀轰竴涓缉杩�
+ let indentationLevel = 0; //澧炲姞杩欒浠g爜鏉ュ垵濮嬪寲indentationLevel
+
+ let formattedCode = codeString
+ .replace(/^\s+/mg, '') // 绉婚櫎姣忚鍓嶉潰鐨勭┖鐧�
+ .replace(/(\{|\})/g, ' $& ') // 璁╁ぇ鎷彿鍛ㄥ洿閮芥湁绌烘牸
+ // 涓婇潰鐨�.replace(/^\s+/mg, '')鍙兘浼氬湪鎷彿鍛ㄥ洿鎻掑叆澶氫綑鐨勭┖鏍硷紝鎵�浠ヤ笅闈㈣繖琛屼唬鐮佷細绉婚櫎寮�澶存垨鏈熬鐨勭┖鏍�
+ .replace(/^\s+|\s+$/mg, '')
+ // 鐢ㄤ簡.split('\n')鍚庯紝姣忎竴琛岄兘鏄暟缁勪腑鐨勪竴涓厓绱狅紝鎵�浠ュ彲浠ラ�氳繃鍑忓皯鎴栧鍔犺寮�澶寸殑绌烘牸鏁版潵娣诲姞鎴栧垹闄ょ缉杩�
+ .split('\n').reduce((formattedCode, currentLine) => {
+ if (currentLine.includes('}')) {
+ // 濡傛灉涓�琛屼腑鍖呭惈鍙冲ぇ鎷彿锛屾垜浠鍑忓皯涓�涓缉杩�
+ indentationLevel--;
+ }
+
+ let indentation = baseIndentation.repeat(indentationLevel);
+ let indentedLine = indentation + currentLine;
+
+ if (currentLine.includes('{')) {
+ // 濡傛灉涓�琛屼腑鍖呭惈宸﹀ぇ鎷彿锛岄偅涓ぇ鎷彿鍚庨潰鐨勪唬鐮侀渶瑕侀澶栫殑涓�涓缉杩�
+ indentationLevel++;
+ }
+
+ return formattedCode + '\n' + indentedLine;
+ }, '');
+
+ return formattedCode;
+ }
+
+ // const transCode = (rootNode, nodes, graph) => {
+ // let codeContent = "";
+ // const descendants = [];
+ // let stack = [rootNode];
+
+ // let count = 0;
+ // while (stack.length > 0) {
+ // const current = stack.pop();
+ // descendants.push(current);
+
+ // const children = getChildren(current, nodes, graph);
+ // stack.push(...children);
+
+ // // 杈撳嚭浠g爜
+ // if (!current.data.isLogic) {
+ // const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
+ // connectedEdges.forEach((edge) => {
+ // //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
+ // if(edge.source.cell != current.id){
+ // //鍙栦笂涓�鑺傜偣
+ // let lastNode = null;
+ // nodes.forEach((node) => {
+ // if(node.id == edge.source.cell){
+ // lastNode = node;
+ // }
+ // })
+
+ // if(lastNode != null) {
+ // //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
+ // if(lastNode.data.isLogic){
+ // console.log(lastNode);
+ // let nestedIfCode = "";
+ // if(lastNode.data.logicBool == 'true') {
+ // nestedIfCode = `
+ // if (${lastNode.data.codeContent}) {
+ // ${current.data.codeContent}
+ // }
+ // `;
+ // }else{
+ // nestedIfCode = `
+ // if (!(${lastNode.data.codeContent})) {
+ // ${current.data.codeContent}
+ // }
+ // `;
+ // }
+
+
+ // codeContent += "\n" + nestedIfCode;
+ // console.log(codeContent);
+ // }else{
+ // if (current.data.codeContent != null) {
+ // codeContent += "\n" + current.data.codeContent;
+ // }
+ // }
+ // }
+ // }
+ // console.log(current);
+ // })
+ // } else {
+ // // if (current.data.codeContent != null) {
+ // // codeContent += "\n" + current.data.codeContent;
+ // // }
+
+ // // const connectedEdges = graph.getConnectedEdges(current);
+ // // console.log(connectedEdges);
+ // // stack = []
+ // // let test = []
+ // // connectedEdges.forEach((edge) => {
+ // // nodes.forEach((item) => {
+ // // if (item.id === edge.target.cell && item.id != current.id) {
+ // // test.push(item);
+ // // }
+ // // })
+ // // });
+ // // console.log(test);
+ // // console.log();
+ // // let nestedIfCode = `
+ // // if (true}) {
+ // // ${current.data.codeContent}
+ // // }
+ // // `;
+
+ // // codeContent += "\n" + nestedIfCode;
+ // // console.log(codeContent);
+ // }
+
+ // }
+
+ // console.log(codeContent);
+ // }
+
+ const nodeDFS = (node, nodes, graph) => {
+ let values = [];
+ if (graph) {
+ const connectedEdges = graph.getConnectedEdges(node);
+ const children = [];
+
+ console.log(node);
+ connectedEdges.forEach((edge) => {
+ nodes.forEach((item) => {
+ if (item.id === edge.target.cell && item.id != node.id) {
+ children.push(item);
+ }
+ })
+ });
+
+ console.log(connectedEdges);
+ if (children.length != 0) {
+ console.log(children);
+ children.forEach((node) => {
+ console.log(node);
+ values.push(node);
+ values = values.concat(nodeDFS(node, nodes, graph))
+ })
+ }
+ }
+
+ return values;
+ }
+
+ const getChildren = (node, nodes, graph) => {
+ const connectedEdges = graph.getConnectedEdges(node);
+ const children = [];
+
+ connectedEdges.forEach((edge) => {
+ nodes.forEach((item) => {
+ if (item.id === edge.target.cell && item.id != node.id) {
+ children.push(item);
+ }
+ })
+ });
+
+ return children;
+ }
+
+ const getDescendants = (node, nodes, graph) => {
+ const descendants = [];
+ const stack = [node];
+
+ let count = 0;
+ while (stack.length > 0) {
+ const current = stack.pop();
+ descendants.push(current);
+
+ const children = getChildren(current, nodes, graph);
+ stack.push(...children);
+ }
+
+ return descendants;
}
return (
<>
- <Button type="primary" onClick={exportData}>
- 瀵煎嚭鏁版嵁
- </Button>
+ <div className="container">
+ <Button type="primary" onClick={exportData}>
+ 瀵煎嚭鏁版嵁
+ </Button>
+
+ <Button type="primary" onClick={prewCode}>
+ 棰勮浠g爜
+ </Button>
+ </div>
+
+ <Modal title="Basic Modal" open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
+ <SyntaxHighlighter language="java" style={solarizedlight}>
+ {preCode}
+ </SyntaxHighlighter>
+ </Modal>
</>
);
}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphTools.less b/zy-asrs-flow/src/components/Flow/GraphTools.less
new file mode 100644
index 0000000..7502c89
--- /dev/null
+++ b/zy-asrs-flow/src/components/Flow/GraphTools.less
@@ -0,0 +1,6 @@
+.container {
+ width: 200px;
+ display: flex;
+ justify-content: space-around;
+ margin-top: 10px;
+}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphTools2.jsx b/zy-asrs-flow/src/components/Flow/GraphTools2.jsx
new file mode 100644
index 0000000..caf08bf
--- /dev/null
+++ b/zy-asrs-flow/src/components/Flow/GraphTools2.jsx
@@ -0,0 +1,323 @@
+import React, { useRef, useEffect, useState } from "react";
+import { Button, message } from 'antd';
+import { last } from "lodash";
+
+export const GraphTools = ({ graphRef, isReady }) => {
+
+ let codeContent = "";
+
+ const exportData = () => {
+ const graph = graphRef.current;
+ if (isReady) {
+ const data = graph.toJSON();
+ console.log(data);
+ // 杩欓噷浣犲彲浠ュ皢鏁版嵁鍙戦�佸埌鏈嶅姟鍣ㄦ垨淇濆瓨鍒版湰鍦�
+
+ const edges = [];
+ const nodes = [];
+ let rootNode = null;
+ data.cells.forEach((item) => {
+ if (item.shape == "edge") {
+ edges.push(item)
+ } else {
+ nodes.push(item)
+ if (item.data.root) {
+ rootNode = item;
+ }
+ }
+ })
+
+ if (rootNode == null) {
+ message.warning('璇疯缃▼搴忓叆鍙g粍浠�');
+ return;
+ }
+
+ console.log(getDescendants(rootNode, nodes, graph));
+
+ transCode(rootNode, nodes, graph)
+ // nodeDFS(rootNode, nodes, graph, codeContent)
+ // console.log(codeContent);
+ }
+ }
+
+ const transCode = (rootNode, nodes, graph) => {
+ let codeContent = "";
+ const descendants = [];
+ let stack = [rootNode];
+
+ let existLogicNode = [];
+ let values = nodeDFS(rootNode, nodes, graph);
+
+ let cpValues = JSON.parse(JSON.stringify(values))
+ console.log(cpValues);
+
+ let groupCode = {};
+ let logicGroupSearch = {};
+ let currentLogic = null;
+ cpValues.forEach((value) => {
+ if(value.data.isLogic) {
+ let tmp = {};
+ if(currentLogic == null) {
+ tmp = {
+ id: value.id,
+ parent: null
+ }
+ }else{
+ tmp = {
+ id: value.id,
+ parent: currentLogic
+ }
+ }
+ currentLogic = value.id;
+ logicGroupSearch[value.id] = tmp;
+ }
+ })
+
+ console.log(logicGroupSearch);
+
+ let codeContentTmp = "";
+ while (values.length > 0) {
+ const current = values.pop();
+ const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
+
+ connectedEdges.forEach((edge) => {
+ //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
+ if (edge.source.cell != current.id) {
+ //鍙栦笂涓�鑺傜偣
+ let lastNode = null;
+ nodes.forEach((node) => {
+ if (node.id == edge.source.cell) {
+ lastNode = node;
+ }
+ })
+
+ if (lastNode != null) {
+ //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
+ if (lastNode.data.isLogic) {
+ let nestedCode = `
+ //**********${current.attrs.text.text}-start**********//
+ ${current.data.codeContent}
+ //**********${current.attrs.text.text}-end**********//
+ `;
+ codeContentTmp = "\n" + nestedCode + codeContentTmp;
+
+ let nestedIfCode = "";
+ if (existLogicNode.indexOf(lastNode.id) == -1) {
+ //鍒ゆ柇杈归�昏緫鍊�
+ if (edge.data.logicBool == true) {
+ nestedIfCode = `
+ //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-start**********//
+ if (${lastNode.data.codeContent}) {
+ ${codeContentTmp}
+ // }
+ // //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-end**********//
+ `;
+ } else {
+ nestedIfCode = `
+ //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-start**********//
+ if (!(${lastNode.data.codeContent})) {
+ ${codeContentTmp}
+ // }
+ // //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-end**********//
+ `;
+ }
+ existLogicNode.push(lastNode.id);
+
+ groupCode[lastNode.id + "-true"] = nestedIfCode;
+ } else {
+ nestedIfCode = `
+ //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-start**********//
+ else {
+ ${codeContentTmp}
+ // }
+ // //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-end**********//
+ `;
+
+ groupCode[lastNode.id + "-false"] = nestedIfCode;
+ }
+
+
+ codeContent += nestedIfCode;
+ codeContentTmp = "";
+
+ console.log(lastNode, current, true, codeContent);
+ } else {
+ if (current.data.codeContent != null && !current.data.isLogic) {
+ let nestedCode = `
+ //**********${current.attrs.text.text}-start**********//
+ ${current.data.codeContent}
+ //**********${current.attrs.text.text}-end**********//
+ `;
+ codeContentTmp = "\n" + nestedCode + codeContentTmp;
+ }
+ }
+ }
+ }
+ })
+
+ }
+
+ console.log(groupCode);
+ console.log(codeContent);
+
+ }
+
+ // const transCode = (rootNode, nodes, graph) => {
+ // let codeContent = "";
+ // const descendants = [];
+ // let stack = [rootNode];
+
+ // let count = 0;
+ // while (stack.length > 0) {
+ // const current = stack.pop();
+ // descendants.push(current);
+
+ // const children = getChildren(current, nodes, graph);
+ // stack.push(...children);
+
+ // // 杈撳嚭浠g爜
+ // if (!current.data.isLogic) {
+ // const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
+ // connectedEdges.forEach((edge) => {
+ // //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
+ // if(edge.source.cell != current.id){
+ // //鍙栦笂涓�鑺傜偣
+ // let lastNode = null;
+ // nodes.forEach((node) => {
+ // if(node.id == edge.source.cell){
+ // lastNode = node;
+ // }
+ // })
+
+ // if(lastNode != null) {
+ // //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
+ // if(lastNode.data.isLogic){
+ // console.log(lastNode);
+ // let nestedIfCode = "";
+ // if(lastNode.data.logicBool == 'true') {
+ // nestedIfCode = `
+ // if (${lastNode.data.codeContent}) {
+ // ${current.data.codeContent}
+ // }
+ // `;
+ // }else{
+ // nestedIfCode = `
+ // if (!(${lastNode.data.codeContent})) {
+ // ${current.data.codeContent}
+ // }
+ // `;
+ // }
+
+
+ // codeContent += "\n" + nestedIfCode;
+ // console.log(codeContent);
+ // }else{
+ // if (current.data.codeContent != null) {
+ // codeContent += "\n" + current.data.codeContent;
+ // }
+ // }
+ // }
+ // }
+ // console.log(current);
+ // })
+ // } else {
+ // // if (current.data.codeContent != null) {
+ // // codeContent += "\n" + current.data.codeContent;
+ // // }
+
+ // // const connectedEdges = graph.getConnectedEdges(current);
+ // // console.log(connectedEdges);
+ // // stack = []
+ // // let test = []
+ // // connectedEdges.forEach((edge) => {
+ // // nodes.forEach((item) => {
+ // // if (item.id === edge.target.cell && item.id != current.id) {
+ // // test.push(item);
+ // // }
+ // // })
+ // // });
+ // // console.log(test);
+ // // console.log();
+ // // let nestedIfCode = `
+ // // if (true}) {
+ // // ${current.data.codeContent}
+ // // }
+ // // `;
+
+ // // codeContent += "\n" + nestedIfCode;
+ // // console.log(codeContent);
+ // }
+
+ // }
+
+ // console.log(codeContent);
+ // }
+
+ const nodeDFS = (node, nodes, graph) => {
+ let values = [];
+ if (graph) {
+ const connectedEdges = graph.getConnectedEdges(node);
+ const children = [];
+
+ console.log(node);
+ connectedEdges.forEach((edge) => {
+ nodes.forEach((item) => {
+ if (item.id === edge.target.cell && item.id != node.id) {
+ children.push(item);
+ }
+ })
+ });
+
+ console.log(connectedEdges);
+ if (children.length != 0) {
+ console.log(children);
+ children.forEach((node) => {
+ console.log(node);
+ values.push(node);
+ values = values.concat(nodeDFS(node, nodes, graph))
+ })
+ }
+ }
+
+ return values;
+ }
+
+ const getChildren = (node, nodes, graph) => {
+ const connectedEdges = graph.getConnectedEdges(node);
+ const children = [];
+
+ connectedEdges.forEach((edge) => {
+ nodes.forEach((item) => {
+ if (item.id === edge.target.cell && item.id != node.id) {
+ children.push(item);
+ }
+ })
+ });
+
+ return children;
+ }
+
+ const getDescendants = (node, nodes, graph) => {
+ const descendants = [];
+ const stack = [node];
+
+ let count = 0;
+ while (stack.length > 0) {
+ const current = stack.pop();
+ descendants.push(current);
+
+ const children = getChildren(current, nodes, graph);
+ stack.push(...children);
+ }
+
+ return descendants;
+ }
+
+ return (
+ <>
+ <Button type="primary" onClick={exportData}>
+ 瀵煎嚭鏁版嵁
+ </Button>
+ </>
+ );
+}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/config/setting.ts b/zy-asrs-flow/src/config/setting.ts
index 32a86f4..d1e75bd 100644
--- a/zy-asrs-flow/src/config/setting.ts
+++ b/zy-asrs-flow/src/config/setting.ts
@@ -1,5 +1,5 @@
// 鎺ュ彛鍦板潃
-export const API_BASE_URL: string = 'http://127.0.0.1:9090/wcs';
+export const API_BASE_URL: string = 'http://192.168.4.113:9090/wcs';
// 椤圭洰鍚嶇О
export const PROJECT_NAME: string = 'admin';
diff --git a/zy-asrs-flow/src/pages/home/index.css b/zy-asrs-flow/src/pages/home/index.css
deleted file mode 100644
index c08b77c..0000000
--- a/zy-asrs-flow/src/pages/home/index.css
+++ /dev/null
@@ -1,15 +0,0 @@
- /* 鎻愮ず妗嗙殑鏍峰紡 */
- .g6-tooltip {
- border: 1px solid #e2e2e2;
- border-radius: 4px;
- font-size: 12px;
- color: #545454;
- background-color: rgba(255, 255, 255, 0.9);
- padding: 10px 8px;
- box-shadow: rgb(174, 174, 174) 0px 0px 10px;
- }
-
- .modalInput {
- margin-top: 30px;
- margin-bottom: 30px;
- }
\ No newline at end of file
--
Gitblit v1.9.1