|
@@ -51,6 +51,7 @@
|
|
@dragover="onDragOver"
|
|
@dragover="onDragOver"
|
|
@dragleave="onDragLeave"
|
|
@dragleave="onDragLeave"
|
|
@node-click="nodeClick($event)"
|
|
@node-click="nodeClick($event)"
|
|
|
|
+ @edge-click="edgeClick($event)"
|
|
>
|
|
>
|
|
<template #edge-custom="props">
|
|
<template #edge-custom="props">
|
|
<CustomConnectionLine v-bind="props" />
|
|
<CustomConnectionLine v-bind="props" />
|
|
@@ -94,6 +95,12 @@
|
|
<div class="btns">
|
|
<div class="btns">
|
|
<el-button type="primary" @click="saveFlow">保存</el-button>
|
|
<el-button type="primary" @click="saveFlow">保存</el-button>
|
|
<el-button type="danger" @click="cancelFlow">取消</el-button>
|
|
<el-button type="danger" @click="cancelFlow">取消</el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ type="info"
|
|
|
|
+ v-if="selectNode || selectLine"
|
|
|
|
+ @click="deleteFlow"
|
|
|
|
+ >删除</el-button
|
|
|
|
+ >
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 工序信息编辑模式 -->
|
|
<!-- 工序信息编辑模式 -->
|
|
@@ -174,13 +181,35 @@ const { onDragOver, onDrop, onDragLeave, isDragOver, onDragStart } =
|
|
useDragAndDrop();
|
|
useDragAndDrop();
|
|
const flowData = ref({ edges: [], nodes: [] });
|
|
const flowData = ref({ edges: [], nodes: [] });
|
|
const flowDataCopy = ref({ edges: [], nodes: [] });
|
|
const flowDataCopy = ref({ edges: [], nodes: [] });
|
|
-provide("edges", flowData.value.edges);
|
|
|
|
const currentProcess = ref({});
|
|
const currentProcess = ref({});
|
|
|
|
+const selectNode = ref(null);
|
|
|
|
+const selectLine = ref(null);
|
|
|
|
+provide("selectNode", selectNode);
|
|
provide("currentProcess", currentProcess);
|
|
provide("currentProcess", currentProcess);
|
|
|
|
+provide("selectLine", selectLine);
|
|
|
|
+const edgeClick = (event) => {
|
|
|
|
+ if (!editStatus.value) {
|
|
|
|
+ selectLine.value = event.edge;
|
|
|
|
+ selectNode.value = null;
|
|
|
|
+ }
|
|
|
|
+};
|
|
const nodeClick = (event) => {
|
|
const nodeClick = (event) => {
|
|
- if (!editStatus.value) return;
|
|
|
|
- currentProcess.value = event.node;
|
|
|
|
- console.log("------------" + JSON.stringify(event.node))
|
|
|
|
|
|
+ if (!editStatus.value) {
|
|
|
|
+ selectNode.value = event.node;
|
|
|
|
+ } else {
|
|
|
|
+ currentProcess.value = event.node;
|
|
|
|
+ }
|
|
|
|
+ selectLine.value = null;
|
|
|
|
+};
|
|
|
|
+//当使用回退时清空选择的node
|
|
|
|
+
|
|
|
|
+const handleKeydown = () => {
|
|
|
|
+ if (selectNode.value != null) {
|
|
|
|
+ selectNode.value = null;
|
|
|
|
+ }
|
|
|
|
+ if (selectLine.value != null) {
|
|
|
|
+ selectLine.value = null;
|
|
|
|
+ }
|
|
};
|
|
};
|
|
onConnect(addEdges);
|
|
onConnect(addEdges);
|
|
const getPng = () => {
|
|
const getPng = () => {
|
|
@@ -192,10 +221,13 @@ const getPng = () => {
|
|
};
|
|
};
|
|
const nodeType = ref("custom");
|
|
const nodeType = ref("custom");
|
|
const editStatus = ref(false);
|
|
const editStatus = ref(false);
|
|
|
|
+provide("editStatus", editStatus);
|
|
const changeEditStatus = () => {
|
|
const changeEditStatus = () => {
|
|
editStatus.value = !editStatus.value;
|
|
editStatus.value = !editStatus.value;
|
|
if (editStatus.value == false) {
|
|
if (editStatus.value == false) {
|
|
currentProcess.value = {};
|
|
currentProcess.value = {};
|
|
|
|
+ } else {
|
|
|
|
+ selectNode.value = null;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
@@ -234,6 +266,25 @@ const saveFlow = async () => {
|
|
};
|
|
};
|
|
const cancelFlow = () => {
|
|
const cancelFlow = () => {
|
|
flowData.value = JSON.parse(flowDataCopy.value);
|
|
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 () => {
|
|
const saveInfo = async () => {
|
|
flowData.value.nodes.forEach((item, index) => {
|
|
flowData.value.nodes.forEach((item, index) => {
|
|
@@ -286,8 +337,11 @@ onMounted(() => {
|
|
loadTreeData();
|
|
loadTreeData();
|
|
loadProcessesFlow();
|
|
loadProcessesFlow();
|
|
flowBoxScreen();
|
|
flowBoxScreen();
|
|
|
|
+ window.addEventListener("keydown", handleKeydown);
|
|
|
|
+});
|
|
|
|
+onUnmounted(() => {
|
|
|
|
+ window.removeEventListener("keydown", handleKeydown);
|
|
});
|
|
});
|
|
-
|
|
|
|
const getNameByDictType = (dictValue) => {
|
|
const getNameByDictType = (dictValue) => {
|
|
let str = "";
|
|
let str = "";
|
|
dicts?.workshop_section?.forEach((element) => {
|
|
dicts?.workshop_section?.forEach((element) => {
|