1
lzhe
2024-10-22 50d50abccf262c62903c3b2eba14096b8f9c26b8
1
已修改2个文件
42 ■■■■ 文件已修改
src/utils/tool.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/realtime-status/index.vue 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/tool.js
@@ -2,7 +2,7 @@
 * @Descripttion: 工具集
 * @version: 1.2
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-10-10 10:17:47
 * @LastEditTime: 2024-10-22 19:58:38
 */
import CryptoJS from 'crypto-js';
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-21 15:01:18
 * @LastEditTime: 2024-10-22 19:46:11
 * @FilePath: /cps-web/src/views/mdc/realtime-status/index.vue
 实时看板
-->
@@ -221,18 +221,14 @@
            this.gettimestatus();  //查询列表
        },
        showvisible(item, index) {
            //clickIndex
            if(item.properties.length == 0) {
                this.$message({
                    message: '该工位没有配置数据点',
                    type: 'warning'
                });
                return;
            }
            this.clickIndex = index;
            // if (item.properties == null || item.properties.length == 0) {
            //     this.$message({
            //         message: '请配置采集项',
            //         type: 'warning'
            //     });
            //     return;
            // }
            // var visibleList = JSON.parse(JSON.stringify(item.properties));
            // this.titleMap = "实时数据(" + item.code + ")";
            // this.visibleList = visibleList;
            this.visible = true;
        },
        searchstatus(item, index) {
@@ -270,12 +266,12 @@
                }
            })
        },
        changeTime(time) {
        changeTime(time,diffTime) {
            // 使用Moment.js解析这两个日期字符串  
            var date1 = moment(time);
            var date2 = moment(moment().format('YYYY-MM-DD HH:mm:ss'));
            var date2 = moment(diffTime);
            // 计算两个日期之间的差异(毫秒)  
            var differenceInMilliseconds = date2.diff(date1); // 注意:date2 - date1 给出正数差异
            var differenceInMilliseconds = date1.diff(date2); // 注意:date1 - date2 给出正数差异
            // 使用duration对象将差异转换为更易于处理的单位  
            var duration = moment.duration(differenceInMilliseconds);
            // 提取天数、小时数、分钟数和秒数  
@@ -334,7 +330,6 @@
                    this.$TOOL.socket.websocket.onmessage = function (event) {
                        //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) {
@@ -344,8 +339,10 @@
                                }
                                if (eventData.data.DeviceStatus) {
                                    var time = moment(eventData.data.DeviceStatus.t).format('YYYY-MM-DD HH:mm:ss');
                                    var diffTime = that.changeTime(time);  //转换成差值(时分秒)
                                    var preT = moment(eventData.data.DeviceStatus.preT).format('YYYY-MM-DD HH:mm:ss');
                                    var diffTime = that.changeTime(time,preT);  //转换成差值(时分秒)
                                    //that.setIntervalTime();   //十秒增加时间
                                    var diffTime = diffTime;
                                    item.time = diffTime;
                                    that.allwcs.forEach(item1 => {
                                        if (item1.code == eventData.data.DeviceStatus.v) {
@@ -368,6 +365,10 @@
                                                item1.code = item2.name;
                                            }
                                        })
                                        if (Object.keys(eventData.data).length == 0) {  //ws没有data数据,给默认值
                                            item1.code = "";
                                            item1.color = "#E4A512";
                                        };
                                    } else {
                                        if (item1.key == 'Alarm') {  //报警
                                            if (eventData.data[item1.key]) {
@@ -377,7 +378,6 @@
                                                    if (v.length == 0) {
                                                        res.data.records[index].properties.splice(index1, 1);
                                                    } else {
                                                        item1.name = v[0].alarmNo;
                                                        item1.code = v[0].alarmNo;
                                                    }
                                                } else {
@@ -558,12 +558,12 @@
    width: 12px;
    height: 12px;
    border-radius: 6px;
    margin-right: 8px;
    margin-right: 2px;
}
.status-card-detail-time {
    line-height: 12px;
    margin-left: 8px;
    margin-left: 2px;
}
.status-card-machine {