footerLeft.vue
3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<template>
<div>
<div class="title-text">第三层</div>
<div style="width: 100%; height: 80%; position: relative; left: 0vw; top: 5vw;">
<div class="tishenji">提升机</div>
<div id="bubble-containerThere"></div>
</div>
<div style="color: white;margin:2vh 0 0 6vw;display: flex;">
<div
style="display: flex;
justify-content: flex-start;
align-items: center;"
>
<div style="width: 1vw;height: 1vw;background: #98afdb;"></div>
<div
style=" font-size: 1vw;
width: 5vw;
margin-left: 0.3vw; "
>
过道
</div>
</div>
<div
style="display: flex;
justify-content: flex-start;
align-items: center;"
>
<div style="width: 1vw;height: 1vw;background: #006fdf;"></div>
<div
style=" font-size: 1vw;
width: 3vw;
margin-left: 0.3vw; "
>
库位
</div>
</div>
<div
style="display: flex;
justify-content: flex-start;
align-items: center;"
>
<div style="width: 1vw;height: 1vw;background: #A0169D;"></div>
<div
style=" font-size: 1vw;
width: 5vw;
margin-left: 0.3vw; "
>
行走路线
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
sysinfo: [],
}
},
methods: {
sed(data) {
this.agvLineData = data
var agvLineDatas = this.agvLineData
if (agvLineDatas) {
function formatMarkInfo(agvLineDatas) {
return agvLineDatas.map((item) => ({
id: `a_${item.barcode}`,
taskNumber: item.taskNo,
carCode: item.agvNo,
speed: item.speed,
status: item.agvState,
// startLandmark: item.startLandmark,
// endLandmark: item.endLandmark,
battery: item.voltage,
}))
}
var markInfos = formatMarkInfo(agvLineDatas)
window.findMarkInfo(markInfos, this.sysinfo)
this.sysinfo = markInfos
}
let temp = data.map((item) => item.taskPathPoints.map((point) => point.barcode))
// 1. 将数组 b 中所有需要匹配的 id 提取出来,存入一个 Set 中,以提高查找效率
const idsToUpdate = new Set()
temp.forEach((pair) => {
pair.forEach((id) => {
idsToUpdate.add(id)
})
})
// 2. 遍历 coordinatelist 数组
window.coordinatelistThere.forEach((item) => {
// 3. 使用 Set.has() 方法检查 id 是否存在,这一步非常快
if (item && idsToUpdate.has(item.id)) {
// 4. 如果存在,就为该对象添加 bgColor 属性
item.bgcolor = '#A0169D'
} else {
item.bgcolor = ''
}
})
// 2. 【核心修复】重新获取更新后的数据,并调用渲染函数
let coordinatelist = window.coordinatelistThere
let agvMarkList = []
coordinatelist.forEach((i) => {
// 这里的计算逻辑必须和 mounted 中保持一致
agvMarkList.push({ ...i, top: i.y * 1.3 + 'vw', left: i.x * 1.3 + 2 + 'vw' })
})
// 再次调用初始化函数,让它根据新数据重新渲染
window.initMarksLine('#bubble-containerThere', agvMarkList)
},
},
mounted() {
debugger
let coordinatelist = window.coordinatelistThere
let agvMarkList = []
coordinatelist.forEach((i) => {
agvMarkList.push({ ...i, top: i.y * 1.3 + 'vw', left: i.x * 1.3 + 2 + 'vw' })
})
window.initMarksLine('#bubble-containerThere', agvMarkList)
},
}
</script>
<style>
.title-text {
width: 100%;
height: 4vh;
font-size: 3vh;
font-weight: 600;
color: #fff;
text-align: center;
}
</style>