headLeft.vue
5.33 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<template>
<div>
<div class="title-text">第一层</div>
<div style="width: 100%; height: 80%; position: relative; left: 0vw; top: 3vw;">
<div class="tishenji_one">
<div class="ne-one" style="font-size:1.2VW;font-weight:600;">
提升机
</div>
<div style="width:100%;height:18%;border: 1px solid #000;"></div>
<div style="width:100%;height:56%;display: flex;">
<div class="lineOne" style="font-size:1.2VW;font-weight:600;">输送线</div>
<div class="lineTwo" style="font-size:1.2VW;font-weight:600;">输送线</div>
</div>
</div>
<div id="bubble-container"></div>
</div>
<div style="color: white;margin:2vh 0 0 7vw;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) {
data.forEach((x) => {
if (x.status == 0) {
x.status = '待机'
} else if (x.status == 1) {
x.status = '任务执行中'
} else if (x.status == 3) {
x.status = '错误'
} else if (x.status == 4) {
x.status = '充电'
}
})
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.fwsCode,
speed: item.speed,
status: item.status,
// // startLandmark: item.startLandmark,
// // endLandmark: item.endLandmark,
battery: item.powerLevel,
}))
}
console.log(formatMarkInfo(agvLineDatas), 'formatMarkInfo(agvLineDatas)')
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.coordinatelist.forEach((item) => {
// 3. 使用 Set.has() 方法检查 id 是否存在,这一步非常快
if (item && idsToUpdate.has(item.id)) {
// 4. 如果存在,就为该对象添加 bgColor 属性
item.bgcolor = '#A0169D'
} else {
item.bgcolor = ''
}
})
// 2. 【核心修复】重新获取更新后的数据,并调用渲染函数
let coordinatelist = window.coordinatelist
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-container', agvMarkList)
},
},
mounted() {
debugger
let coordinatelist = window.coordinatelist
let agvMarkList = []
coordinatelist.forEach((i) => {
agvMarkList.push({ ...i, top: i.y * 1.3 + 'vw', left: i.x * 1.3 + 2 + 'vw' })
})
window.initMarksLine('#bubble-container', agvMarkList)
},
}
</script>
<style>
.title-text {
width: 100%;
height: 4vh;
font-size: 3vh;
font-weight: 600;
color: #fff;
text-align: center;
}
.tishenji_one {
width: 3.9vw;
height: 15vh;
position: relative;
/* font-size: 1.3vw; */
left: 5.9vw;
top: 6.5vw;
/* z-index: 999; */
background-color: #fff;
}
.ne-one {
width: 100%;
height: 26%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.lineOne {
width: 50%;
height: 100%;
border-top: none;
border-right: 2px solid #000;
border-bottom: none;
border-left: none;
writing-mode: vertical-rl;
/* 可选:控制文字方向(确保文字正立) */
text-orientation: upright;
flex-direction: column;
align-items: center;
justify-content: center;
line-height: 18px; /* 调整字间距 */
}
.lineTwo {
width: 50%;
height: 100%;
writing-mode: vertical-rl;
/* 可选:控制文字方向(确保文字正立) */
text-orientation: upright;
flex-direction: column;
align-items: center;
justify-content: center;
line-height: 28px; /* 调整字间距 */
}
</style>