|
@@ -51,6 +51,7 @@
|
|
|
@dragover="onDragOver"
|
|
|
@dragleave="onDragLeave"
|
|
|
@node-click="nodeClick($event)"
|
|
|
+ @edge-click="edgeClick($event)"
|
|
|
>
|
|
|
<template #edge-custom="props">
|
|
|
<CustomConnectionLine v-bind="props" />
|
|
@@ -93,7 +94,15 @@
|
|
|
<div v-if="!editStatus">
|
|
|
<div class="btns">
|
|
|
<el-button type="primary" @click="saveFlow">保存</el-button>
|
|
|
- <el-button type="danger" @click="cancelFlow">取消</el-button>
|
|
|
+ <el-button type="danger" v-if="cancelStatus" @click="cancelFlow"
|
|
|
+ >取消</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="info"
|
|
|
+ v-if="selectNode || selectLine"
|
|
|
+ @click="deleteFlow"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 工序信息编辑模式 -->
|
|
@@ -140,6 +149,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
+
|
|
|
<script setup>
|
|
|
import {
|
|
|
Back,
|
|
@@ -166,6 +176,12 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
import { formOption } from "./bindConfig";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import { useScreenshot } from "./screenshot.ts";
|
|
|
+defineOptions({
|
|
|
+ name: "BindProcess/:id?",
|
|
|
+});
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ console.log("g");
|
|
|
+});
|
|
|
const { capture } = useScreenshot();
|
|
|
const instance = useVueFlow();
|
|
|
const { onConnect, addEdges, vueFlowRef, onEdgeUpdateEnd, applyEdgeChanges } =
|
|
@@ -174,18 +190,38 @@ const { onDragOver, onDrop, onDragLeave, isDragOver, onDragStart } =
|
|
|
useDragAndDrop();
|
|
|
const flowData = ref({ edges: [], nodes: [] });
|
|
|
const flowDataCopy = ref({ edges: [], nodes: [] });
|
|
|
-provide("edges", flowData.value.edges);
|
|
|
const currentProcess = ref({});
|
|
|
+const selectNode = ref(null);
|
|
|
+const selectLine = ref(null);
|
|
|
+provide("selectNode", selectNode);
|
|
|
provide("currentProcess", currentProcess);
|
|
|
+provide("selectLine", selectLine);
|
|
|
+const edgeClick = (event) => {
|
|
|
+ if (!editStatus.value) {
|
|
|
+ selectLine.value = event.edge;
|
|
|
+ selectNode.value = null;
|
|
|
+ }
|
|
|
+};
|
|
|
const nodeClick = (event) => {
|
|
|
- if (!editStatus.value) return;
|
|
|
- currentProcess.value = event.node;
|
|
|
- if (!editStatus.value) return;
|
|
|
- currentProcess.value = event.node;
|
|
|
-
|
|
|
-
|
|
|
+ if (!editStatus.value) {
|
|
|
+ selectNode.value = event.node;
|
|
|
+ } else {
|
|
|
+ currentProcess.value = event.node;
|
|
|
+ }
|
|
|
+};
|
|
|
+//当使用回退时清空选择的node
|
|
|
|
|
|
+const handleKeydown = () => {
|
|
|
+ if (selectNode.value != null) {
|
|
|
+ selectNode.value = null;
|
|
|
+ }
|
|
|
+ if (selectLine.value != null) {
|
|
|
+ selectLine.value = null;
|
|
|
+ }
|
|
|
};
|
|
|
+onActivated(() => {
|
|
|
+ console.log("ac");
|
|
|
+});
|
|
|
onConnect(addEdges);
|
|
|
const getPng = () => {
|
|
|
if (!vueFlowRef.value) {
|
|
@@ -196,10 +232,13 @@ const getPng = () => {
|
|
|
};
|
|
|
const nodeType = ref("custom");
|
|
|
const editStatus = ref(false);
|
|
|
+provide("editStatus", editStatus);
|
|
|
const changeEditStatus = () => {
|
|
|
editStatus.value = !editStatus.value;
|
|
|
if (editStatus.value == false) {
|
|
|
currentProcess.value = {};
|
|
|
+ } else {
|
|
|
+ selectNode.value = null;
|
|
|
}
|
|
|
};
|
|
|
const router = useRouter();
|
|
@@ -238,6 +277,25 @@ const saveFlow = async () => {
|
|
|
};
|
|
|
const cancelFlow = () => {
|
|
|
flowData.value = JSON.parse(flowDataCopy.value);
|
|
|
+ if (selectNode.value != null) {
|
|
|
+ selectNode.value = null;
|
|
|
+ }
|
|
|
+ if (selectLine.value != null) {
|
|
|
+ selectLine.value = null;
|
|
|
+ }
|
|
|
+};
|
|
|
+const deleteFlow = () => {
|
|
|
+ const event = new KeyboardEvent("keydown", {
|
|
|
+ key: "Backspace",
|
|
|
+ keyCode: 8,
|
|
|
+ which: 8,
|
|
|
+ code: "Backspace",
|
|
|
+ bubbles: true,
|
|
|
+ cancelable: true,
|
|
|
+ });
|
|
|
+ document.dispatchEvent(event);
|
|
|
+ selectNode.value = null;
|
|
|
+ selectLine.value = null;
|
|
|
};
|
|
|
const saveInfo = async () => {
|
|
|
flowData.value.nodes.forEach((item, index) => {
|
|
@@ -260,13 +318,18 @@ const loadTreeData = () => {
|
|
|
list1.value = res.data ?? [];
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
+const cancelStatus = ref(true);
|
|
|
//通过id获取现存储信息
|
|
|
const loadProcessesFlow = async () => {
|
|
|
const res = await processesByRouteId(route.params.id);
|
|
|
if (res.data) {
|
|
|
- flowData.value = JSON.parse(res.data.routeData);
|
|
|
- flowDataCopy.value = res.data.routeData;
|
|
|
+ if (res.data.routeData && res.data.routeData != "") {
|
|
|
+ flowData.value = JSON.parse(res.data.routeData);
|
|
|
+ flowDataCopy.value = res.data.routeData;
|
|
|
+ cancelStatus.value = true;
|
|
|
+ } else {
|
|
|
+ cancelStatus.value = false;
|
|
|
+ }
|
|
|
} else {
|
|
|
flowDataCopy.value = JSON.stringify(flowData.value);
|
|
|
}
|
|
@@ -290,8 +353,13 @@ onMounted(() => {
|
|
|
loadTreeData();
|
|
|
loadProcessesFlow();
|
|
|
flowBoxScreen();
|
|
|
+ window.addEventListener("keydown", handleKeydown);
|
|
|
+ const route = useRoute();
|
|
|
+ console.log(route, "r");
|
|
|
+});
|
|
|
+onUnmounted(() => {
|
|
|
+ window.removeEventListener("keydown", handleKeydown);
|
|
|
});
|
|
|
-
|
|
|
const getNameByDictType = (dictValue) => {
|
|
|
let str = "";
|
|
|
dicts?.workshop_section?.forEach((element) => {
|
|
@@ -301,6 +369,7 @@ const getNameByDictType = (dictValue) => {
|
|
|
});
|
|
|
return str;
|
|
|
};
|
|
|
+
|
|
|
watch(
|
|
|
() => flowData.value.edges,
|
|
|
() => {
|