liulijun
16 小时以前 5270308151082506e0e6df2c72d278d2976ec860
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
<template>
    <div :class="update" :style="{ left: left, top: top, marginBottom: 0 + 'px', marginTop: 15 + 'px' }"
        @click="mouseClick" v-loading.fullscreen.lock="fullscreenLoading">
        <img v-if="imgType === '2'" src="../../public/lines.png" />
        <img v-if="imgType === '1'" src="../../public/lines2.png" />
        <label v-if="equipNo" class="equip-no">{{ equipNo }}</label>
    </div>
    <el-dialog v-model="dialogVisible" :before-close="handleClose" width="520px" class="modern-dialog">
        <div class="dialog-header">
            <h3 class="dialog-title">输送线信息</h3>
        </div>
        <div class="dialog-content">
            <div class="info-list">
                <div class="info-item">
                    <span class="item-label">设备编号</span>
                    <span class="item-value">{{ equipNo || '无' }}</span>
                </div>
                <div class="info-item">
                    <span class="item-label">任务号</span>
                    <span class="item-value">{{ ConveyorLineInfo.TaskNum || '无' }}</span>
                </div>
                <div class="info-item">
                    <span class="item-label">是否有盘</span>
                    <span class="item-value">{{ ConveyorLineInfo.HasGoods || '无' }}</span>
                </div>
                <div class="info-item">
                    <span class="item-label">托盘条码</span>
                    <span class="item-value">{{ ConveyorLineInfo.PalletCode || '无' }}</span>
                </div>
                <div class="info-item">
                    <span class="item-label">状态</span>
                    <span :class="['item-value', statusClass]">{{ ConveyorLineInfo.Status || '无' }}</span>
                </div>
                <div class="info-item">
                    <span class="item-label">命令</span>
                    <span class="item-value">{{ ConveyorLineInfo.Command || '无' }}</span>
                </div>
            </div>
        </div>
    </el-dialog>
</template>
 
<script>
import { defineComponent } from "vue";
import JElDescription from "./JElDescription";
export default defineComponent({
    components: {
        JElDescription
    },
    props: {
        equipNoFontColor: {
            type: String,
            default: "blue",
        },
        equipNo: {
            type: String,
            default: "0",
        },
        imgType: {
            type: String,
            default: "1",
        },
        positionX: {
            type: Int32Array,
            default: 1,
        },
        positionY: {
            type: Int32Array,
            default: 1,
        },
        url: {
            type: String,
            default: "",
        },
        condition: {
            type: Boolean,
            default: false,
        },
    },
    data() {
        return {
            left: "500px",
            top: "400px",
            dialogVisible: false,
            fullscreenLoading: false,
            timer1: null,
            hasGoods: false,
            isAlarm: false,
            ConveyorLineInfo: {
                TaskNum: "",
                HasGoods: "",
                Status: "",
                Command: "",
                PalletCode: "",
            },
            form: {
                TaskType: "",
                TargetAddress: "",
                DeviceCode: "",
            },
            Map: {
            Command: {
                0: "无命令",
                1: "非就绪(不执行下发命令)",
                2: "取货站台工位就绪(有料)",
                3: "放货站台工位就绪(无料)",
                4: "放货站台工位就绪(有料)",
                5: "扫码工位就绪",
                6: "任务工位就绪",
                7: "申请料框",
                8: "料框到位",
                9: "执行命令中"
            },
            Status: {
                0: "脱机中",
                1: "手动待机",
                2: "自动待机",
                3: "设备运行",
                4: "设备故障"
            }
        },
        };
    },
    mounted() {
        const axisX = (this.positionX - 1) * 60 + 100;
        const axisY = (this.positionY - 1) + 50;
        this.$nextTick(() => {
            this.left = `${axisX}px`;
            this.top = `${axisY}px`;
        });
        // 启动定时器,每秒更新一次数据
        this.timer1 = setInterval(() => {
            this.updateAlarmStatus();
        }, 1000);
    },
    beforeUnmount() {
        // 清除定时器
        if (this.timer1) {
            clearInterval(this.timer1);
            this.timer1 = null;
        }
    },
    watch: {
        '$root.conveyorLineDetails': {
            handler() {
                this.updateAlarmStatus();
            },
            deep: true,
            immediate: true
        }
    },
    methods: {
        updateAlarmStatus() {
            const equipNoStr = String(this.equipNo);
            if (this.$root.conveyorLineDetails && this.$root.conveyorLineDetails[equipNoStr]) {
                const rawData = this.$root.conveyorLineDetails[equipNoStr];
                this.hasGoods = rawData.inStock === '是' || false;
                // 使用Home.vue中已经计算好的isAlarm值,或者根据状态判断
                this.isAlarm = rawData.isAlarm || (rawData.status === 4) || false;
                // 实时更新对话框中的数据
                this.ConveyorLineInfo = {
                    TaskNum: rawData.taskNum || rawData.TaskNum || '无',
                    HasGoods: (rawData.taskNum && rawData.taskNum !== '无' && rawData.taskNum !== '0') ? '是' : '否',
                    Status: rawData.status || rawData.Status || '无',
                    Command: rawData.command || rawData.Command || '无',
                    PalletCode: rawData.palletCode || rawData.PalletCode || '无',
                };
                // 将命令代码转换为对应的中文描述
                if (this.ConveyorLineInfo.Command !== '' && this.ConveyorLineInfo.Command !== '无') {
                    const commandCode = parseInt(this.ConveyorLineInfo.Command);
                    if (!isNaN(commandCode) && this.Map.Command && this.Map.Command[commandCode] !== undefined) {
                        this.ConveyorLineInfo.Command = this.Map.Command[commandCode];
                    }
                }
                // 将状态代码转换为对应的中文描述
                if (this.ConveyorLineInfo.Status !== '' && this.ConveyorLineInfo.Status !== '无') {
                    const statusCode = parseInt(this.ConveyorLineInfo.Status);
                    if (!isNaN(statusCode) && this.Map.Status && this.Map.Status[statusCode] !== undefined) {
                        this.ConveyorLineInfo.Status = this.Map.Status[statusCode];
                    }
                }
            } else {
                this.hasGoods = false;
                this.isAlarm = false;
            }
        },
        mouseClick() {
            this.fullscreenLoading = true;
            this.dialogVisible = true;
            // 从全局变量中获取输送线详细信息
            if (this.$root.conveyorLineDetails && this.$root.conveyorLineDetails[this.equipNo]) {
                // 先获取原始数据
                const rawData = this.$root.conveyorLineDetails[this.equipNo];
 
                // 复制数据到ConveyorLineInfo(模板中绑定的对象)
                this.ConveyorLineInfo = {
                    TaskNum: rawData.taskNum || rawData.TaskNum || '无',
                    HasGoods: (rawData.taskNum && rawData.taskNum !== '无' && rawData.taskNum !== '0') ? '是' : '否',
                    Status: rawData.status || rawData.Status || '无',
                    Command: rawData.command || rawData.Command || '无',
                    PalletCode: rawData.palletCode || rawData.PalletCode || '无',
                };
 
                // 将命令代码转换为对应的中文描述
                if (this.ConveyorLineInfo.Command !== '' && this.ConveyorLineInfo.Command !== '无') {
                    const commandCode = parseInt(this.ConveyorLineInfo.Command);
                    if (!isNaN(commandCode) && this.Map.Command && this.Map.Command[commandCode] !== undefined) {
                        this.ConveyorLineInfo.Command = this.Map.Command[commandCode];
                    }
                }
 
                // 将状态代码转换为对应的中文描述
                if (this.ConveyorLineInfo.Status !== '' && this.ConveyorLineInfo.Status !== '无') {
                    const statusCode = parseInt(this.ConveyorLineInfo.Status);
                    if (!isNaN(statusCode) && this.Map.Status && this.Map.Status[statusCode] !== undefined) {
                        this.ConveyorLineInfo.Status = this.Map.Status[statusCode];
                    }
                }
 
                // 将报警代码转换为对应的中文描述
                if (rawData.alarm !== '' && rawData.alarm !== '无') {
                    const alarmCode = parseInt(rawData.alarm);
                    if (!isNaN(alarmCode) && this.Map.ErrorCode && this.Map.ErrorCode[alarmCode] !== undefined) {
                        this.ConveyorLineInfo.Alarm = this.Map.ErrorCode[alarmCode];
                    }
                }
            } else {
                // 如果没有数据,使用默认值
                this.ConveyorLineInfo = {
                    TaskNum: '',
                    HasGoods: '',
                    Status: '',
                    Command: '',
                    PalletCode: '',
                };
            }
            this.fullscreenLoading = false;
        },
        handleClose() {
            this.dialogVisible = false;
            this.fullscreenLoading = false;
        },
 
        // SendCommand() {
        //     this.fullscreenLoading = true;
        //     this.form.DeviceCode=this.equipNo;
        //     this.http.post("api/DeviceInfo/ConveyorLineHandTask" ,this.form)
        //         .then((x) => {
        //             if (!x.status) {
        //                 this.$message.error(x.message);
        //             } else {
        //                 this.$Message.success(x.message);
        //             }
        //         })
        //         .finally(() => {
        //             this.fullscreenLoading = false;
        //         });
        // }, 
        // ConveyorLineReset() {
        //     this.fullscreenLoading = true;
        //     this.http.post("api/DeviceInfo/ConveyorLineReset?DeviceChildCode=" + this.equipNo, null, "")
        //         .then((x) => {
        //             if (!x.status) {
        //                 this.$message.error(x.message);
        //             } else {
        //                 this.$Message.success(x.message);
 
        //             }
        //         })
        //         .finally(() => {
        //             this.fullscreenLoading = false;
        //         });
        // },
        // ConveyorLineEmergencyStop() {
        //     this.fullscreenLoading = true;
        //     this.http.post("api/DeviceInfo/ConveyorLineEmergencyStop?DeviceChildCode=" + this.equipNo, null, "")
        //         .then((x) => {
        //             if (!x.status) {
        //                 this.$message.error(x.message);
        //             } else {
        //                 this.$Message.success(x.message);
 
        //             }
        //         })
        //         .finally(() => {
        //             this.fullscreenLoading = false;
        //         });
        // }, 
        // ConveyorLineReturn() {
        //     this.fullscreenLoading = true;
        //     this.http.post("api/DeviceInfo/ConveyorLineReturn?DeviceChildCode=" + this.equipNo, null, "")
        //         .then((x) => {
        //             if (!x.status) {
        //                 this.$message.error(x.message);
        //             } else {
        //                 this.$Message.success(x.message);
        //             }
        //         })
        //         .finally(() => {
        //             this.fullscreenLoading = false;
        //         });
        // },
        // ConveyorLineCancel() {
        //     this.fullscreenLoading = true;
        //     this.http.post("api/DeviceInfo/ConveyorLineCancel?DeviceChildCode=" + this.equipNo, null, "")
        //         .then((x) => {
        //             if (!x.status) {
        //                 this.$message.error(x.message);
        //             } else {
        //                 this.$Message.success(x.message);
        //             }
        //         })
        //         .finally(() => {
        //             this.fullscreenLoading = false;
        //         });
        // },
        // ConveyorLineInitialize() {
        //     this.fullscreenLoading = true;
        //     this.http.post("api/DeviceInfo/ConveyorLineInitialize?DeviceChildCode=" + this.equipNo, null, "")
        //         .then((x) => {
        //             if (!x.status) {
        //                 this.$message.error(x.message);
        //             } else {
        //                 this.$Message.success(x.message);
        //             }
        //         })
        //         .finally(() => {
        //             this.fullscreenLoading = false;
        //         });
        //},
        startTimer() {
            // 开启定时器,每3秒执行一次
            this.timer1 = setInterval(() => {
                this.updateAlarmStatus();
            }, 1000);
        },
    },
    computed: {
        update() {
            if (this.isAlarm) {
                return 'custom-img-alarm';
            }
            // 使用中文状态值判断
            const statusText = this.ConveyorLineInfo.Status;
            // 状态为手动待机时,无论有无盘都显示蓝色
            if (statusText === '手动待机') {
                return 'custom-img-blue';
            }
            // 状态为自动待机或设备运行且有盘时显示绿色
            if ((statusText === '自动待机' || statusText === '设备运行') && (this.hasGoods || this.ConveyorLineInfo.HasGoods === '是')) {
                return 'custom-img-color';
            }
            return 'custom-img';
        },
        statusClass() {
            const statusText = this.ConveyorLineInfo.Status;
            if (statusText === '手动待机') {
                return 'status-blue';
            } else if (statusText === '自动待机' || statusText === '设备运行') {
                return 'status-green';
            } else if (statusText === '设备故障') {
                return 'status-red';
            }
            return '';
        }
    }
});
</script>
 
<style scoped>
.custom-img {
    position: relative;
    display: inline-block;
    /* background-color:  #d9ecff ; */
}
 
.custom-img-color {
    position: relative;
    display: inline-block;
    background-color: #05fa7f;
    color: white;
    text-align: center;
}
 
.custom-img-alarm {
    position: relative;
    display: inline-block;
    background-color: #ff0000;
    color: white;
    text-align: center;
}
 
.custom-img-blue {
    position: relative;
    display: inline-block;
    background-color: #409eff;
    color: white;
    text-align: center;
}
 
.custom-img-blue img {
    width: 80px;
    height: 50px;
}
 
.custom-img-alarm img {
    width: 80px;
    height: 50px;
}
 
.custom-img img {
    width: 80px;
    height: 50px;
}
 
.custom-img-color img {
    width: 80px;
    height: 50px;
}
 
/* .custom-img-color::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: #05fa7f;
  border-radius: 50%;  
} */
 
.custom-img img {
    width: 80px;
    height: 50px;
}
 
.custom-img-color img {
    width: 80px;
    height: 50px;
}
 
.equip-no {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 25px;
    text-align: center;
    width: 100%;
}
 
.modern-dialog {
    border-radius: 16px !important;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
 
.modern-dialog .el-dialog__header {
    display: none;
}
 
.modern-dialog .el-dialog__body {
    padding: 0;
    margin: 0;
}
 
.dialog-header {
    background: linear-gradient(135deg, #409eff 0%, #67c23a 100%);
    padding: 20px 24px;
    text-align: center;
}
 
.dialog-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 2px;
}
 
.dialog-content {
    padding: 28px;
    background: #f8fafc;
    display: flex;
    justify-content: center;
}
 
.info-list {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
 
.info-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}
 
.info-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
 
.item-label {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
    min-width: 80px;
    text-align: left;
}
 
.item-value {
    font-size: 15px;
    color: #1f2937;
    font-weight: 500;
    text-align: right;
    flex: 1;
    margin-left: 20px;
    word-break: break-all;
    padding-left: 20px;
    border-left: 1px solid #e5e7eb;
}
 
.status-blue {
    color: #409eff !important;
    font-weight: 600;
}
 
.status-green {
    color: #67c23a !important;
    font-weight: 600;
}
 
.status-red {
    color: #f56c6c !important;
    font-weight: 600;
}
</style>