|
@@ -88,6 +88,21 @@
|
|
|
>
|
|
|
<p v-if="isDragOver">拖拽中</p>
|
|
|
</DropzoneBackground>
|
|
|
+
|
|
|
+ <Panel class="process-panel" position="top-right">
|
|
|
+ <div class="layout-panel">
|
|
|
+ <button
|
|
|
+ title="set horizontal layout"
|
|
|
+ @click="layoutGraph('LR')"
|
|
|
+ >
|
|
|
+ <PannelIcon name="horizontal" />
|
|
|
+ </button>
|
|
|
+
|
|
|
+ <button title="set vertical layout" @click="layoutGraph('TB')">
|
|
|
+ <PannelIcon name="vertical" />
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </Panel>
|
|
|
</VueFlow>
|
|
|
|
|
|
<div
|
|
@@ -204,7 +219,7 @@ import {
|
|
|
Grid,
|
|
|
} from "@element-plus/icons-vue";
|
|
|
import _ from "lodash-es";
|
|
|
-import { VueFlow, useVueFlow } from "@vue-flow/core";
|
|
|
+import { VueFlow, useVueFlow, Panel } from "@vue-flow/core";
|
|
|
import DropzoneBackground from "./components/DropzoneBackground/index.vue";
|
|
|
import CustomConnectionLine from "./components/CustomConnectionLine/index.vue";
|
|
|
import CustomNode from "./components/CustomNode/index.vue";
|
|
@@ -220,14 +235,22 @@ import {
|
|
|
import { formOption } from "./bindConfig";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import { useScreenshot } from "./screenshot.ts";
|
|
|
+import { useLayout } from "@/hooks/useLayout";
|
|
|
defineOptions({
|
|
|
name: "bindProcess/:id/:prodtCode",
|
|
|
});
|
|
|
|
|
|
const { capture } = useScreenshot();
|
|
|
+const { layout } = useLayout();
|
|
|
const instance = useVueFlow();
|
|
|
-const { onConnect, addEdges, vueFlowRef, onEdgeUpdateEnd, applyEdgeChanges } =
|
|
|
- instance;
|
|
|
+const {
|
|
|
+ onConnect,
|
|
|
+ addEdges,
|
|
|
+ vueFlowRef,
|
|
|
+ onEdgeUpdateEnd,
|
|
|
+ applyEdgeChanges,
|
|
|
+ fitView,
|
|
|
+} = instance;
|
|
|
const { onDragOver, onDrop, onDragLeave, isDragOver, onDragStart } =
|
|
|
useDragAndDrop();
|
|
|
const flowData = ref({ edges: [], nodes: [] });
|
|
@@ -524,6 +547,20 @@ watch(
|
|
|
loadTreeData();
|
|
|
}
|
|
|
);
|
|
|
+
|
|
|
+async function layoutGraph(direction) {
|
|
|
+ flowData.value.nodes.value = layout(
|
|
|
+ flowData.value.nodes,
|
|
|
+ flowData.value.edges,
|
|
|
+ direction
|
|
|
+ );
|
|
|
+
|
|
|
+ console.log(flowData.value.nodes);
|
|
|
+
|
|
|
+ nextTick(() => {
|
|
|
+ fitView();
|
|
|
+ });
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
@@ -623,6 +660,86 @@ watch(
|
|
|
margin-top: 20px;
|
|
|
color: #e6a23c;
|
|
|
}
|
|
|
+
|
|
|
+.process-panel,
|
|
|
+.layout-panel {
|
|
|
+ display: flex;
|
|
|
+ gap: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.process-panel {
|
|
|
+ background-color: #2d3748;
|
|
|
+ padding: 10px;
|
|
|
+ border-radius: 8px;
|
|
|
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+}
|
|
|
+
|
|
|
+.process-panel button {
|
|
|
+ border: none;
|
|
|
+ cursor: pointer;
|
|
|
+ background-color: #4a5568;
|
|
|
+ border-radius: 8px;
|
|
|
+ color: white;
|
|
|
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
|
|
|
+}
|
|
|
+
|
|
|
+.process-panel button {
|
|
|
+ font-size: 16px;
|
|
|
+ width: 40px;
|
|
|
+ height: 40px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+
|
|
|
+.checkbox-panel {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.process-panel button:hover,
|
|
|
+.layout-panel button:hover {
|
|
|
+ background-color: #2563eb;
|
|
|
+ transition: background-color 0.2s;
|
|
|
+}
|
|
|
+
|
|
|
+.process-panel label {
|
|
|
+ color: white;
|
|
|
+ font-size: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.stop-btn svg {
|
|
|
+ display: none;
|
|
|
+}
|
|
|
+
|
|
|
+.stop-btn:hover svg {
|
|
|
+ display: block;
|
|
|
+}
|
|
|
+
|
|
|
+.stop-btn:hover .spinner {
|
|
|
+ display: none;
|
|
|
+}
|
|
|
+
|
|
|
+.spinner {
|
|
|
+ border: 3px solid #f3f3f3;
|
|
|
+ border-top: 3px solid #2563eb;
|
|
|
+ border-radius: 50%;
|
|
|
+ width: 10px;
|
|
|
+ height: 10px;
|
|
|
+ animation: spin 1s linear infinite;
|
|
|
+}
|
|
|
+
|
|
|
+@keyframes spin {
|
|
|
+ 0% {
|
|
|
+ transform: rotate(0deg);
|
|
|
+ }
|
|
|
+ 100% {
|
|
|
+ transform: rotate(360deg);
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|
|
|
|
|
|
<style>
|