| | |
| | | <!-- |
| | | * @Date: 2024-04-09 22:11:21 |
| | | * @LastEditors: lzhe lzhe@example.com |
| | | * @LastEditTime: 2024-06-17 17:26:45 |
| | | * @LastEditTime: 2024-06-18 16:42:07 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/realtime-status/index.vue |
| | | 实时看板 |
| | | --> |
| | |
| | | mounted() { |
| | | this.getstationlabelList(); //获取标签视图下的list |
| | | this.setIntervalTime(); //十秒增加时间 |
| | | this.getSetting(); //设置几行几列 |
| | | this.getSetting(); //设置几行几列 ==》获取顶部title=》获取颜色,获取机器=》ws |
| | | }, |
| | | methods: { |
| | | getSetting() { |
| | |
| | | this.timestatus = []; |
| | | this.$HTTP.post(`/api/blade-cps/workstation/real-time-status?current=${this.current}&size=${this.size}`,obj).then(res=> { |
| | | if(res.code == 200) { |
| | | this.timestatus = res.data.records; |
| | | var ids = []; |
| | | res.data.records.forEach(item=> { |
| | | item.statusName = "未知"; |
| | |
| | | this.$TOOL.socket.websocket.onmessage = function(event) { |
| | | num ++; |
| | | var eventData = JSON.parse(event.data); |
| | | console.log(eventData,1234) |
| | | if(eventData.data.DeviceStatus != undefined) { |
| | | var time = moment(eventData.data.DeviceStatus.t).format('YYYY-MM-DD HH:mm:ss'); |
| | | var diffTime = that.changeTime(time); //转换成差值(时分秒) |
| | | }else { |
| | | var diffTime = "--"; |
| | | } |
| | | if(res.data.records.length == 0) return; //没值不用循环 |
| | | res.data.records.forEach((item,index)=> { //第一步把v放到code里 |
| | | console.log(that.timestatus,2333) |
| | | if(that.timestatus.length == 0) return; //没值不用循环 |
| | | that.timestatus.forEach((item,index)=> { //第一步把v放到code里 |
| | | if(eventData.id == item.id) { |
| | | if(item.properties == null) { |
| | | item.properties = []; |
| | |
| | | } |
| | | }); |
| | | }; |
| | | var len = res.data.records.length; |
| | | intervalId = setInterval(function() { |
| | | if (num === len) { |
| | | clearInterval(intervalId); |
| | | that.timestatus = res.data.records; //等所有socket回来以后赋值 |
| | | } |
| | | }, 500); |
| | | // var len = res.data.records.length; |
| | | // intervalId = setInterval(function() { |
| | | // if (num === len) { |
| | | // clearInterval(intervalId); |
| | | // that.timestatus = res.data.records; //等所有socket回来以后赋值 |
| | | // } |
| | | // }, 500); |
| | | } |
| | | }) |
| | | }, |