1
lzhe
2024-10-07 35a5b36f140c947d154460ce61007d6ace54ec9b
1
已修改3个文件
69 ■■■■■ 文件已修改
src/utils/tool.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/realtime-status/index.vue 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/station-live.vue 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/tool.js
@@ -2,7 +2,7 @@
 * @Descripttion: 工具集
 * @version: 1.2
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-10-06 23:09:59
 * @LastEditTime: 2024-10-07 00:52:31
 */
import CryptoJS from 'crypto-js';
@@ -18,7 +18,7 @@
console.log(hostname,port,pathname)
if (process.env.NODE_ENV=='development') {
    //var path = "120.46.212.231:85";
    //var path = "120.46.212.231:85";  //如果是本地联调,写成120.46.212.231:85,发版写成hostname+":"+port;
    var path = hostname+":"+port;
} else {
    var path = hostname+":"+port;
src/views/mdc/realtime-status/index.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-04-09 22:11:21
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-10-06 22:31:43
 * @LastEditTime: 2024-10-07 00:51:38
 * @FilePath: /mdc/Users/mache/Documents/demo/cps-web/src/views/mdc/realtime-status/index.vue
 实时看板
-->
@@ -281,7 +281,6 @@
            this.$HTTP.post(`/api/blade-cps/workstation/real-time-status?current=${this.current || 0}&size=${this.size || 6}`, obj).then(res => {
                if (res.code == 200) {
                    var ids = [];
                    console.log(this.allwcs, res.data)
                    res.data.records.forEach(item => {
                        ids.push(item.id);
                        if (item.properties != null && item.properties.length != 0) {
@@ -315,11 +314,12 @@
                            that.$TOOL.socket.sendDataToWebSocket(obj);  //发送
                        }
                    }, 500);
                    var num = 0;
                    //var num = 0;
                    var intervalId;
                    this.$TOOL.socket.websocket.onmessage = function (event) {
                        num++;
                        //num++;
                        var eventData = JSON.parse(event.data);
                        if(Object.keys(eventData.data).length == 0) return;
                        if (that.timestatus.length == 0) return;  //没值不用循环
                        that.timestatus.forEach((item, index) => {  //第一步把v放到code里
                            if (eventData.id == item.id) {
@@ -345,16 +345,12 @@
                                }
                                item.properties.forEach((item1, index1) => {
                                    if (item1.key == "DeviceStatus") {  //机器状态
                                        if (item1.value == "2") {
                                            that.allwcs.forEach(item2 => {
                                                if (item2.code == item1.value) {
                                                    item1.color = item2.color;
                                                    item1.code = item2.name;
                                                }
                                            })
                                        } else {
                                            item1.color = "#75C0C0";
                                        }
                                        that.allwcs.forEach(item2 => {
                                            if (item2.code == item1.value) {
                                                item1.color = item2.color;
                                                item1.code = item2.name;
                                            }
                                        })
                                    } else {
                                        if (item1.key == 'Alarm') {  //报警
                                            if (eventData.data[item1.key]) {
@@ -365,33 +361,28 @@
                                                    } else {
                                                        item1.name = v[0].code;
                                                        item1.code = v[0].msg;
                                                        that.allwcs.forEach(item2 => {
                                                            if (item2.name == "报警") {
                                                                item1.color = item2.color;
                                                            }
                                                        })
                                                    }
                                                } else {
                                                    item1.name = v.code;
                                                    item1.code = v.msg;
                                                    that.allwcs.forEach(item2 => {
                                                        if (item2.name == "报警") {
                                                            item1.color = item2.color;
                                                        }
                                                    })
                                                }
                                            }
                                        } else {
                                            if (eventData.data[item1.key]) {
                                                item1.code = eventData.data[item1.key].v;
                                                item1.color = "#75C0C0";
                                            }
                                        }
                                        that.allwcs.forEach(item2 => {
                                            if (item2.name == "报警") {
                                                item1.color = item2.color;
                                            }
                                        })
                                    }
                                })
                            }
                        });
                    };
                    console.log(this.timestatus,214)
                    // var len = res.data.records.length;
                    // intervalId = setInterval(function() {  
                    //     if (num === len) {  
@@ -534,7 +525,7 @@
    font-weight: 700;
    font-size: 16px;
    color: #333;
    width: 33%;
    width: 26%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
src/views/mdc/station-live.vue
@@ -2,7 +2,7 @@
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-10-06 23:03:58
 * @LastEditTime: 2024-10-07 00:49:07
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@@ -657,12 +657,12 @@
                        if(this.$TOOL.socket.websocket == null) {  //没有建立先建立
                            this.$TOOL.socket.connectToWebSocket(this.$TOOL.cookie.get("TOKEN")); 
                        }
                        console.log(obj,222333)
                        this.$TOOL.socket.sendDataToWebSocket(obj);  //发送
                        this.$TOOL.socket.websocket.onmessage = function(event) {  
                            var JSONData = JSON.parse(res.data.dpConfig);
                            var eventData = JSON.parse(event.data);
                            if(Object.keys(eventData.data).length == 0) return;
                            JSONData.forEach((item,index)=> {  //第一步把v放到code里
                                var eventData = JSON.parse(event.data);
                                if(item.dpName == "DeviceStatus") {  //机器状态
                                    if(eventData.data[item.dpName]) {
                                        item.code = eventData.data[item.dpName].v;
@@ -670,13 +670,10 @@
                                    that.allwcs.forEach((item1)=> {
                                        if(item.code == item1.code) {
                                            item.codeName = item1.name;    //第二步把v的code和运行对应
                                            if(item.code == "2") {
                                                item.color = "#73D13D";
                                            }else {
                                                item.color = "#75C0C0";
                                            }
                                            item.color = item1.color;
                                        }
                                    })
                                    item.description = item.dpLabel;
                                }else {
                                    if(item.dpName == 'Alarm') {  //报警
                                        if(eventData.data[item.dpName]) {
@@ -687,20 +684,23 @@
                                                }else {
                                                    item.description = v[0].code;
                                                    item.codeName = v[0].msg;
                                                    item.color = "#370C0D";
                                                }
                                            }else {
                                                item.description = v.code;
                                                item.codeName = v.msg;
                                                item.color = "#370C0D";
                                            }
                                        }
                                    }else {
                                        if(eventData.data[item.dpName]) {
                                            item.description = item.dpLabel;
                                            item.codeName = eventData.data[item.dpName].v;
                                        }
                                        item.color = "#75C0C0";
                                    }
                                    that.allwcs.forEach((item1)=> {
                                        if(item.code == item1.code) {
                                            item.color = item1.color;
                                        }
                                    })
                                }
                            });
                            that.dmpList = JSONData;