|
@@ -1,6 +1,6 @@
|
|
|
<!-- 装置关联关系 -->
|
|
|
<template>
|
|
|
- <div>
|
|
|
+ <div v-loading="loading" element-loading-text="加载数据中">
|
|
|
<div class="main-cont" ref="myElement" id="treedom">
|
|
|
<div class="main-left" ref="leftElement">
|
|
|
<div
|
|
@@ -48,10 +48,14 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
-import { onMounted, watch, ref, nextTick, defineEmits,inject } from "vue";
|
|
|
+import { onMounted, watch, ref, nextTick, defineEmits, inject } from "vue";
|
|
|
import devicePng from "@/assets/image/instruct/device.png";
|
|
|
import LeaderLine from "../../../../public/leader-line.min.js";
|
|
|
import AnimEvent from "../../../../public/anim-event.min.js";
|
|
|
+import { useRoute } from "vue-router";
|
|
|
+import { clickImgEvent} from "@/utils/common.js";
|
|
|
+const route = useRoute();
|
|
|
+const loading = ref(true);
|
|
|
const props = defineProps({
|
|
|
checkData: {
|
|
|
type: Object,
|
|
@@ -65,6 +69,10 @@ const props = defineProps({
|
|
|
type: Object,
|
|
|
default: () => {},
|
|
|
},
|
|
|
+ isScdView: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
});
|
|
|
const middleElement = ref(null);
|
|
|
const rightElement = ref(null);
|
|
@@ -92,7 +100,7 @@ const setdomRight = (el, item) => {
|
|
|
const processArray = (arr) => {
|
|
|
// ref_ied_id作为键,obj作为值
|
|
|
const uniqueObjects = new Map();
|
|
|
- if(!arr) return;
|
|
|
+ if (!arr) return;
|
|
|
// 遍历数组
|
|
|
for (const obj of arr) {
|
|
|
const { ref_ied_id } = obj;
|
|
@@ -109,16 +117,14 @@ const processArray = (arr) => {
|
|
|
return Array.from(uniqueObjects.values());
|
|
|
};
|
|
|
//点击图片的时候筛选出数据
|
|
|
-const clickImg = (dataItem) => {
|
|
|
- Object.values(props.iedRelation).find((item) => {
|
|
|
- if (item.ied_name == dataItem.ref_ied_name) {
|
|
|
- listData.value = item;
|
|
|
- }
|
|
|
- });
|
|
|
+const clickImg = async (dataItem) => {
|
|
|
+ loading.value =true;
|
|
|
+ listData.value =await clickImgEvent(props,dataItem,scdIdValue);
|
|
|
};
|
|
|
watch(
|
|
|
() => props.checkData,
|
|
|
(newValue, oldV) => {
|
|
|
+ loading.value =true;
|
|
|
listData.value = newValue;
|
|
|
if (newValue && leaderLines.value.length > 0) {
|
|
|
// leaderLines.value.forEach((line) => line.remove()); //清除连线
|
|
@@ -160,7 +166,7 @@ const clickResetLine = () => {
|
|
|
// 将设备列表分成两份
|
|
|
const bothSide = (data) => {
|
|
|
const formatArr = processArray(data);
|
|
|
- if(!formatArr) return;
|
|
|
+ if (!formatArr&&formatArr.length) return;
|
|
|
const arrlenght = formatArr.length;
|
|
|
const long1 = Math.ceil(arrlenght / 2);
|
|
|
leftList.value = formatArr.splice(0, long1);
|
|
@@ -168,17 +174,7 @@ const bothSide = (data) => {
|
|
|
};
|
|
|
|
|
|
const setLeaderline = () => {
|
|
|
- // lineArr.value = [];
|
|
|
//线条样式
|
|
|
- const lineStyle0 = {
|
|
|
- color: "#51637F",
|
|
|
- size: 2,
|
|
|
- path: "straight",
|
|
|
- startPlug: "arrow1",
|
|
|
- endPlug: "behind",
|
|
|
- startSocket: "right",
|
|
|
- endSocket: "left",
|
|
|
- };
|
|
|
const lineStyle1 = {
|
|
|
color: "#51637F",
|
|
|
size: 2,
|
|
@@ -187,6 +183,11 @@ const setLeaderline = () => {
|
|
|
startSocket: "right",
|
|
|
endSocket: "left",
|
|
|
};
|
|
|
+ const lineStyle0 = {
|
|
|
+ ...lineStyle1,
|
|
|
+ startPlug: "arrow1",
|
|
|
+ endPlug: "behind",
|
|
|
+ };
|
|
|
const lineStyle2 = {
|
|
|
color: "#134BEA",
|
|
|
size: 2,
|
|
@@ -196,29 +197,18 @@ const setLeaderline = () => {
|
|
|
startSocket: "right",
|
|
|
endSocket: "left",
|
|
|
};
|
|
|
- const lineStyleRight0 = {
|
|
|
- color: "#51637F",
|
|
|
- size: 2,
|
|
|
- path: "straight",
|
|
|
- startPlug: "arrow1",
|
|
|
- endPlug: "behind",
|
|
|
- startSocket: "left",
|
|
|
- endSocket: "right",
|
|
|
- };
|
|
|
const lineStyleRight1 = {
|
|
|
- color: "#51637F",
|
|
|
- size: 2,
|
|
|
- path: "straight",
|
|
|
- endPlug: "arrow1",
|
|
|
+ ...lineStyle1,
|
|
|
startSocket: "left",
|
|
|
endSocket: "right",
|
|
|
};
|
|
|
- const lineStyleRight2 = {
|
|
|
- color: "#134BEA",
|
|
|
- size: 2,
|
|
|
- path: "straight",
|
|
|
+ const lineStyleRight0 = {
|
|
|
+ ...lineStyleRight1,
|
|
|
startPlug: "arrow1",
|
|
|
- endPlug: "arrow1",
|
|
|
+ endPlug: "behind",
|
|
|
+ }
|
|
|
+ const lineStyleRight2 = {
|
|
|
+ ...lineStyle2,
|
|
|
startSocket: "left",
|
|
|
endSocket: "right",
|
|
|
};
|
|
@@ -281,6 +271,7 @@ const setLeaderline = () => {
|
|
|
// 保存进数组,方便进行遍历删除
|
|
|
leaderLines.value.push(line2);
|
|
|
}
|
|
|
+ loading.value =false
|
|
|
hiddenLine();
|
|
|
};
|
|
|
//设置中间盒子的所在位置
|
|
@@ -293,6 +284,7 @@ const middleLinePosition = () => {
|
|
|
element.value.style.marginTop = `${value}px`;
|
|
|
};
|
|
|
if (leftList.value.length > 3 || rightList.value.length > 3) {
|
|
|
+ if(!middleElement.value) return;
|
|
|
middleElement.value.style.marginTop = `${(heights - 60) / 2}px`; // 设置元素的垂直位置
|
|
|
} else {
|
|
|
setElementMarginTop(leftElement, 0);
|
|
@@ -307,7 +299,13 @@ const middleLinePosition = () => {
|
|
|
}
|
|
|
}, 0);
|
|
|
};
|
|
|
+let scdIdValue ='';
|
|
|
onMounted(() => {
|
|
|
+ if (props.delScdId) {
|
|
|
+ scdIdValue = props.delScdId;
|
|
|
+ } else {
|
|
|
+ scdIdValue = route.query.id;
|
|
|
+ }
|
|
|
nextTick(() => {
|
|
|
setLine();
|
|
|
middleLinePosition();
|
|
@@ -318,10 +316,11 @@ onMounted(() => {
|
|
|
});
|
|
|
//滚动时重定位线条
|
|
|
const newPositionLine = () => {
|
|
|
+ if(!document.getElementById("treedom")) return;
|
|
|
document.getElementById("treedom").addEventListener(
|
|
|
"scroll",
|
|
|
AnimEvent.add(() => {
|
|
|
- if(!leaderLines.value) return;
|
|
|
+ if (!leaderLines.value) return;
|
|
|
leaderLines.value.forEach((line) => {
|
|
|
hiddenLine();
|
|
|
line.position();
|
|
@@ -333,7 +332,7 @@ const newPositionLine = () => {
|
|
|
document.getElementById("treedom").addEventListener(
|
|
|
"resize",
|
|
|
AnimEvent.add(function () {
|
|
|
- if(!leaderLines.value) return;
|
|
|
+ if (!leaderLines.value) return;
|
|
|
leaderLines.value.forEach((line) => {
|
|
|
hiddenLine();
|
|
|
line.position();
|