From e795a1c5647efaae2b98b4b1a3fa2bc2037c4383 Mon Sep 17 00:00:00 2001
From: lzhe <lzhe@example.com>
Date: 星期四, 24 十月 2024 18:37:59 +0800
Subject: [PATCH] 1
---
src/views/mdc/realtime-status/index.vue | 90 ++++++++++++++++++++++++++-------------------
1 files changed, 52 insertions(+), 38 deletions(-)
diff --git a/src/views/mdc/realtime-status/index.vue b/src/views/mdc/realtime-status/index.vue
index 9d8daee..ae05939 100644
--- a/src/views/mdc/realtime-status/index.vue
+++ b/src/views/mdc/realtime-status/index.vue
@@ -1,8 +1,8 @@
<!--
* @Date: 2024-04-09 22:11:21
* @LastEditors: lzhe lzhe@example.com
- * @LastEditTime: 2024-10-09 11:40:18
- * @FilePath: /mdc/Users/mache/Documents/demo/cps-web/src/views/mdc/realtime-status/index.vue
+ * @LastEditTime: 2024-10-22 20:56:44
+ * @FilePath: /cps-web/src/views/mdc/realtime-status/index.vue
瀹炴椂鐪嬫澘
-->
<template>
@@ -44,11 +44,12 @@
<ArrowRight />
</el-icon>
</div>
- <div class="status-content-cardp" v-for="(item,index) in timestatus" :style="{ 'width': (100 / column) + '%' }">
+ <div class="status-content-cardp" v-for="(item, index) in timestatus"
+ :style="{ 'width': (100 / column) + '%' }">
<div class="status-card-box" style="border-color: #ccc;">
<div class="status-card-top">
<div class="status-card-detail">
- <div title="461" class="status-card-detail-name">{{ item.code }}</div>
+ <div class="status-card-detail-name" :title="item.name">{{ item.name }}</div>
<div class="status-card-detail-status">
<div class="status-card-detail-point" :style="{ 'background-color': item.statusStyle }">
</div>{{ item.statusName }}
@@ -59,7 +60,8 @@
</div>
<div class="status-card-machine" style="border-color: #ccc;">
<div class="status-card-machine-img">
- <img src="./station.png" width="68" height="68">
+ <img :src="item.avatar" width="68" height="68">
+
</div>
<div class="status-card-machine-mesg">
<div class="status-card-machine-mesg-form">
@@ -70,7 +72,7 @@
</div>
</div>
<div class="status-card-bottom">
- <div class="status-card-bottom-realtime" @click="showvisible(item,index)"><i
+ <div class="status-card-bottom-realtime" @click="showvisible(item, index)"><i
class="iconfont saber-xiangqing status-card-bottom-icon"></i> 瀹炴椂鏁版嵁</div>
<div class="status-card-bottom-detail" @click="gostatus(item)"><i
class="iconfont saber-shuju status-card-bottom-icon"></i> 宸ヤ綅璇︽儏</div>
@@ -92,6 +94,7 @@
</template>
<script>
+import station from "./station1.jpg";
import moment from 'moment';
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
let icons = []
@@ -104,6 +107,7 @@
},
data() {
return {
+ station: station,
clickIndex: 0,
allwcs: [],
statusStyle: "#ccc",
@@ -124,7 +128,7 @@
}
},
mounted() {
- this.deviceStatus = this.$route.query.currentTag?[...this.$route.query.currentTag]:[];
+ this.deviceStatus = this.$route.query.currentTag ? [...this.$route.query.currentTag] : [];
this.getstationlabelList(); //鑾峰彇鏍囩瑙嗗浘涓嬬殑list
this.getprocess(); //鑾峰彇棰滆壊==銆嬭幏鍙栭《閮╰itle==銆嬭缃嚑琛屽嚑鍒�==銆媤s
},
@@ -147,10 +151,17 @@
// 瑙f瀽鏃堕棿瀛楃涓蹭负澶╂暟銆佸皬鏃躲�佸垎閽熷拰绉�
if (timeStr != undefined && timeStr != "--") {
var parts = timeStr.match(/(\d+)澶�(\d+)鏃�(\d+)鍒�(\d+)绉�/);
- var days = parseInt(parts[1], 10) * 24 * 60 * 60 * 1000; // 澶╂暟杞崲涓烘绉�
- var hours = parseInt(parts[2], 10) * 60 * 60 * 1000; // 灏忔椂杞崲涓烘绉�
- var minutes = parseInt(parts[3], 10) * 60 * 1000; // 鍒嗛挓杞崲涓烘绉�
- var seconds = parseInt(parts[4], 10) * 1000; // 绉掕浆鎹负姣
+ if(parts == null) {
+ var days = 0; // 澶╂暟杞崲涓烘绉�
+ var hours = 0; // 灏忔椂杞崲涓烘绉�
+ var minutes = 0; // 鍒嗛挓杞崲涓烘绉�
+ var seconds = 0; // 绉掕浆鎹负姣
+ }else {
+ var days = parseInt(parts[1], 10) * 24 * 60 * 60 * 1000; // 澶╂暟杞崲涓烘绉�
+ var hours = parseInt(parts[2], 10) * 60 * 60 * 1000; // 灏忔椂杞崲涓烘绉�
+ var minutes = parseInt(parts[3], 10) * 60 * 1000; // 鍒嗛挓杞崲涓烘绉�
+ var seconds = parseInt(parts[4], 10) * 1000; // 绉掕浆鎹负姣
+ }
// 鍒涘缓涓�涓狹oment.js鐨勬寔缁椂闂村璞�
var duration = moment.duration(days + hours + minutes + seconds);
// 澧炲姞鏃堕棿
@@ -190,14 +201,14 @@
this.$HTTP.get("/api/blade-cps/group/get-mdc-group").then(res => {
if (res.code == 200) {
this.stationlabelList = res.data;
- if(res.data.length != 0) {
+ if (res.data.length != 0) {
this.stationlabel = res.data[0].groupName;
}
}
})
},
changestatus(name) {
- if(this.stationlabelList.length == 0) {
+ if (this.stationlabelList.length == 0) {
this.station = "鐘舵�佽鍥�";
this.$message.error('鏈�夊畾瀹炴椂鐪嬫澘鏌ヨ缁勶紝璇峰埌"鍒嗘瀽璁剧疆 -> 瀹炴椂鐪嬫澘鏌ヨ缁勮缃�"涓�夋嫨宸ヤ綅缁�');
return;
@@ -211,19 +222,15 @@
}
this.gettimestatus(); //鏌ヨ鍒楄〃
},
- showvisible(item,index) {
- //clickIndex
+ showvisible(item, index) {
+ 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) {
@@ -246,7 +253,6 @@
}
},
goSet() {
- //console.log(this.$TOOL.data.get("MENU"));name == "閰嶇疆涓績"
this.$router.push('/mdc/configuration'); //鍒嗘瀽璁剧疆
},
gostatus(item) {
@@ -261,12 +267,12 @@
}
})
},
- changeTime(time) {
+ changeTime(time,diffTime) {
// 浣跨敤Moment.js瑙f瀽杩欎袱涓棩鏈熷瓧绗︿覆
var date1 = moment(time);
- var date2 = moment(moment().format('YYYY-MM-DD HH:mm:ss'));
+ var date2 = moment(diffTime);
// 璁$畻涓や釜鏃ユ湡涔嬮棿鐨勫樊寮傦紙姣锛�
- var differenceInMilliseconds = date2.diff(date1); // 娉ㄦ剰锛歞ate2 - date1 缁欏嚭姝f暟宸紓
+ var differenceInMilliseconds = date1.diff(date2); // 娉ㄦ剰锛歞ate1 - date2 缁欏嚭姝f暟宸紓
// 浣跨敤duration瀵硅薄灏嗗樊寮傝浆鎹负鏇存槗浜庡鐞嗙殑鍗曚綅
var duration = moment.duration(differenceInMilliseconds);
// 鎻愬彇澶╂暟銆佸皬鏃舵暟銆佸垎閽熸暟鍜岀鏁�
@@ -288,6 +294,9 @@
if (res.code == 200) {
var ids = [];
res.data.records.forEach(item => {
+ if(item.avatar == "") {
+ item.avatar = station;
+ }
ids.push(item.id);
if (item.properties != null && item.properties.length != 0) {
item.properties.forEach(item1 => {
@@ -325,7 +334,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) {
@@ -335,8 +343,10 @@
}
if (eventData.data.DeviceStatus) {
var time = moment(eventData.data.DeviceStatus.t).format('YYYY-MM-DD HH:mm:ss');
- var diffTime = that.changeTime(time); //杞崲鎴愬樊鍊硷紙鏃跺垎绉掞級
- that.setIntervalTime(); //鍗佺澧炲姞鏃堕棿
+ 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) {
@@ -353,22 +363,26 @@
item.properties.forEach((item1, index1) => {
if (item1.key == "DeviceStatus") { //鏈哄櫒鐘舵��
that.allwcs.forEach(item2 => {
- if (item2.code == eventData.data.DeviceStatus.v) {
+ if(eventData.data.DeviceStatus && item2.code == eventData.data.DeviceStatus.v) {
item1.value = item2.code;
item1.color = item2.color;
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]) {
+ if(eventData.data[item1.key].v == "") return;
var v = JSON.parse(eventData.data[item1.key].v);
if (Array.isArray(v)) { //濡傛灉鏄暟缁勶紝涓嶈祴鍊�
if (v.length == 0) {
res.data.records[index].properties.splice(index1, 1);
} else {
- item1.name = v[0].code;
- item1.code = v[0].msg;
+ item1.code = v[0].alarmNo;
}
} else {
item1.name = v.code;
@@ -532,7 +546,7 @@
font-weight: 700;
font-size: 16px;
color: #333;
- width: 26%;
+ max-width: 37%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
@@ -548,12 +562,12 @@
width: 12px;
height: 12px;
border-radius: 6px;
- margin-right: 8px;
+ margin-right: 2px;
}
.status-card-detail-time {
line-height: 12px;
- margin-left: 16px;
+ margin-left: 2px;
}
.status-card-machine {
--
Gitblit v1.9.3