deviceStatusModule.vue
8.52 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<template>
<div class="wms-ccs-container">
<!-- <div class="header">
<div class="wms-title">机加库区</div>
<div class="status-lights">
<div class="status-value big-value">{{ timeStr }}</div>
<div class="status-item status-switch">
<button class="search-btn green-btn">库区切换</button>
</div>
</div>
</div> -->
<div class="task-section">
<div class="table-wrapper">
<table class="task-table">
<thead>
<tr>
<th>设备ID</th>
<!-- <th>设备状态</th> -->
<th>设备状态</th>
<th>设备运行模式</th>
<th>设备当前位置</th>
<th>异常信息</th>
<th>异常处理方案</th>
<th>异常开始时间</th>
<th>上报时间戳</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in taskList" :key="index" :class="{ 'green-text': item.equipmentStatusDescription === '运行中', 'red-text': item.equipmentStatusDescription === '异常' }">
<td>{{ item.equipmentId }}</td>
<!-- <td>{{ item.equipmentStatus }}</td> -->
<td>{{ item.equipmentStatusDescription }}</td>
<td>{{ item.equipmentOperationModeDescription }}</td>
<td>{{ item.equipmentCurrentPosition }}</td>
<td>
<div class="multiline-content" :title="item.exceptionMessage">
{{ formatLongText(item.exceptionMessage) }}
</div>
<!-- <el-tooltip effect="dark" :content="item.exceptionMessage || '无'" placement="top" :disabled="!item.exceptionMessage || item.exceptionMessage.length <= 20">
<div class="multiline-content" :title="item.exceptionMessage">
{{ formatLongText(item.exceptionMessage) }}
</div>
</el-tooltip> -->
</td>
<td>
<div class="multiline-content" :title="item.exceptionHandlePlan">
{{ formatLongText(item.exceptionHandlePlan) }}
</div>
<!-- <el-tooltip effect="dark" :content="item.exceptionHandlePlan || '无'" placement="top" :disabled="!item.exceptionHandlePlan || item.exceptionHandlePlan.length <= 20">
<div class="multiline-content" :title="item.exceptionHandlePlan">
{{ formatLongText(item.exceptionHandlePlan) }}
</div>
</el-tooltip> -->
</td>
<td>{{ item.exceptionStartTime }}</td>
<td>{{ item.timestampFormat }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<el-dialog title="任务阶段查看" :visible.sync="drawer" width="75%" :before-close="handleClose">
<el-steps finish-status="success" :active="temp + 1">
<el-step v-for="(item, index) in deviceStatus" :key="index" :title="item.key" :description="item.value">
<template v-slot:description>
<el-button size="small">查看详情</el-button>
</template>
</el-step>
</el-steps>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
return {
baseUrlOff: 'http://127.0.0.1:6002/api/BulletinBoard/Mes/V1/ReadData2',
baseUrlOnLine: window.appConfig.baseUrlintOne,
sysData: {},
timer: null,
deviceStatus: [],
taskList: [],
drawer: false,
direction: 'rtl',
device: {},
temp: 0,
// 新增:定时器控制字段
refreshTimer: null, // 全局刷新定时器ID
}
},
methods: {
getData() {
const opt = {
urlSuffix: window.baseOnLineOrOff ? this.baseUrlOnLine : this.baseUrlOff,
logTitle: '设备状态查询',
isUrlALL: true,
headers: window.baseOnLineOrOff,
header: window.baseOnLineOrOff,
type: 'post',
}
const callBackFn = (res) => {
if (!this.ajaxSuccessDataBefore(res, opt.logTitle)) return
this.taskList = res.data.result
}
''.ajax(this, opt, callBackFn)
},
ajaxSuccessDataBefore(res, title) {
if (!res || !res.data || res.data.result == null || res.data.result.length === 0) {
this.sysData = []
''.Log(`${title}无数据`, 'getData')
return false
}
return true
},
progress(item) {
const taskStatusList = Object.entries(item.taskStatusTimestamps).map(([key, value]) => ({
key: key,
value: value,
}))
if (!taskStatusList.length) {
this.temp = -1
return
}
let lastValidIndex = -1
taskStatusList.forEach((item, index) => {
if (item.value !== null) {
lastValidIndex = index
}
})
this.temp = lastValidIndex
this.deviceStatus = taskStatusList
this.drawer = true
},
handleClose(done) {
done()
},
// 新增:格式化长文本,只显示2行
formatLongText(text) {
if (!text) return '无'
// 如果文本长度超过20个字符,截断并添加"..."
if (text.length > 20) {
return text.substring(0, 20) + '...'
}
return text
},
// 修改:定时器启动方法
intInterval: function() {
// 清理现有定时器
if (this.refreshTimer) {
clearInterval(this.refreshTimer)
}
// 启动新的定时器
this.refreshTimer = setInterval(() => {
this.getData()
}, 10000)
// console.log('设备状态定时器已启动')
},
// 新增:暂停接口请求
pauseApiRequest() {
// 停止全局刷新定时器
if (this.refreshTimer) {
clearInterval(this.refreshTimer)
this.refreshTimer = null
}
// console.log('设备状态接口请求已暂停')
},
// 新增:恢复接口请求
resumeApiRequest() {
// 重启全局刷新
if (!this.refreshTimer) {
this.intInterval()
}
// console.log('设备状态接口请求已恢复')
},
},
mounted() {
this.getData()
this.intInterval()
},
// 新增:组件销毁时停止定时器
beforeDestroy() {
this.pauseApiRequest()
},
// 新增:激活组件时恢复请求
activated() {
this.resumeApiRequest()
},
// 新增:停用组件时暂停请求
deactivated() {
this.pauseApiRequest()
},
}
</script>
<style scoped>
/* 全局基础样式 */
html,
body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
.wms-ccs-container {
background-color: #1c2c3b;
color: #e2e8f0;
font-family: '微软雅黑', sans-serif;
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
padding: 1vw;
box-sizing: border-box;
background-image: #1c2c3b;
}
.wms-ccs-container * {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* 任务表格区域样式 */
.task-section {
background-color: #1c2c3b;
/* border: 0.1vw solid #00509d; */
border-radius: 0.2vw;
/* padding: 0.7vw; */
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.table-wrapper {
flex: 1;
overflow-y: auto;
overflow-x: auto;
}
.task-table {
width: 100%;
border-collapse: collapse;
/* min-width: 1600px; */
background-color: #1c2c3b;
table-layout: fixed;
}
.task-table th {
/* padding: 10px 5px; */
text-align: center;
font-size: 1vw;
border: 0.1vw solid #00509d;
background-color: #034c77;
color: #fff;
font-weight: bold;
position: sticky;
top: 0;
z-index: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
height: 2.5vw;
line-height: 2.5vw;
}
.task-table td {
padding: 0px 0px;
text-align: center;
font-size: 1vw;
border: 0.1vw solid #004080;
white-space: normal;
word-wrap: break-word;
word-break: break-all;
height: 3.5vw;
line-height: 1.6;
/* max-height: 2.1vw; */
overflow: hidden;
text-overflow: ellipsis;
display: table-cell;
vertical-align: middle;
}
/* 表格行hover效果 */
.task-table tr:hover {
background-color: rgba(0, 80, 157, 0.3);
}
/* 新增:多行内容显示样式 */
.multiline-content {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2; /* 限制显示2行 */
overflow: hidden;
text-overflow: ellipsis;
line-height: 1.4;
max-height: 2.8em; /* 2行的高度 */
word-wrap: break-word;
word-break: break-all;
width: 100%;
text-align: center;
/* 确保垂直居中 */
display: flex;
align-items: center;
justify-content: center;
}
/* 任务时长文字颜色样式 */
.red-text {
color: #ff2d55 !important;
}
.green-text {
color: #00ff9d !important;
}
.yellow-text {
color: #ffc107 !important;
}
/* 滚动条样式 */
.table-wrapper::-webkit-scrollbar {
width: 0.4vw;
height: 0.4vw;
}
.table-wrapper::-webkit-scrollbar-thumb {
background-color: #0077b6;
border-radius: 0.2vw;
}
.table-wrapper::-webkit-scrollbar-track {
background-color: #001e3c;
}
/* 自定义tooltip样式 */
:deep(.el-tooltip__popper) {
max-width: 30vw;
word-wrap: break-word;
white-space: pre-line;
line-height: 1.5;
font-size: 0.9vw;
background-color: #034c77;
border-color: #034c77;
}
:deep(.el-tooltip__popper[x-placement^='top'] .popper__arrow) {
border-top-color: #034c77;
}
:deep(.el-tooltip__popper[x-placement^='top'] .popper__arrow:after) {
border-top-color: #034c77;
}
</style>