From 9dfbc038667839631578c12ff748534e5939bc82 Mon Sep 17 00:00:00 2001
From: zhuguifei <zhuguifei@zhuguifeideiMac.local>
Date: 星期二, 02 九月 2025 14:34:23 +0800
Subject: [PATCH] 1.修复微信小程序canvans显示在最上层问题
---
pages/tabBar/device.vue | 69 +++++++++++++++++++++++++---------
1 files changed, 50 insertions(+), 19 deletions(-)
diff --git a/pages/tabBar/device.vue b/pages/tabBar/device.vue
index b1c0a83..5f54016 100644
--- a/pages/tabBar/device.vue
+++ b/pages/tabBar/device.vue
@@ -169,20 +169,27 @@
</view>
<view class="info-box">
- <view class="left flex-sub">
+ <view class="left flex-sub" style="width: 60%;">
<view class="title text-sm text-cut">鎶ヨ淇℃伅:</view>
<template v-if="item.errorData">
- <view class="title text-sm text-red">鏁呴殰 {{item.errorData.length}}</view>
+ <view class="title text-sm text-red text-cut">{{ (item.errorData.length > 0) ? item.errorData[0]:'' }}</view>
</template>
- <template v-if="item.warnData">
- <view class="title text-sm text-yellow">鍛婅 {{item.warnData.length}}</view>
- </template>
+ <template v-else-if="item.warnData">
+ <view class="title text-sm text-yellow text-cut"> {{(item.warnData.length > 0) ? item.warnData[0]:''}}</view>
+ </template>
+ <view v-if="getErrorCount(item) > 0">
+ <u-tag size="mini" :text="getErrorCount(item)" type="error" plain></u-tag>
+ </view>
+ <view style="width: 20rpx;"></view>
+ <view v-if="getWarnCount(item) > 0">
+ <u-tag size="mini" :text="getWarnCount(item)" type="warning" plain></u-tag>
+ </view>
</view>
<view class="right" style="min-width: 240rpx;">
<view class="title text-sm">鏇存柊鏃堕棿:</view>
- <view class="title text-sm text-gray">{{ refreshTime}}</view>
+ <view class="title text-sm text-gray">{{ item.refreshTime}}</view>
</view>
</view>
@@ -205,19 +212,18 @@
isProcessing: false,
// key->璁惧绉熸埛+code
dataMap: new Map(),
- // 鏇存柊鏃堕棿
- refreshTime: '',
+
alarmEquCount: 0,
faultEquCount: 0,
timer: null
}
},
- mounted() {
+ onShow() {
this.startTimer()
this.mqttData()
},
- beforeDestroy() {
+ onHide() {
this.stopTimer()
uni.$off(this.$constant.MQTT_TOPIC_MESSAGE)
},
@@ -242,6 +248,7 @@
},
// 璁惧鏁版嵁鍜宮tqq瀹炴椂鏁版嵁鍚堝苟
mergeMqttRealData(mqttData) {
+
const {
tenantid,
machineid
@@ -251,20 +258,40 @@
const targetItem = this.dataList.find(item =>
item.tenantId === tenantid && item.code === machineid
);
+ if (targetItem && !targetItem.online) {
+ mqttData = {};
+ }
if (targetItem) {
const updatedItem = {
...targetItem,
realData: mqttData
};
+ updatedItem.refreshTime = dayjs().format('HH:mm:ss');
this.$set(this.dataList, this.dataList.indexOf(targetItem), updatedItem);
}
},
+
+ getErrorCount(item){
+ let count = 0;
+ if(item.errorData){
+ count += item.errorData.length
+ }
+ return count;
+ },
+ getWarnCount(item){
+ let count = 0;
+ if(item.warnData){
+ count += item.warnData.length
+ }
+ return count;
+ },
+
startTimer() {
this.timer = setInterval(() => {
- this.queryRealFaultData();
+ //this.queryRealFaultData();
}, 3000);
},
stopTimer() {
@@ -315,11 +342,11 @@
case topics.updateEquStatu:
this.handleEquipmentStatusUpdate(wdata);
break;
- case topics.realData:
+ case topics.realData:
this.mergeMqttRealData(wdata);
break;
- case topics.realFaultTopic:
- case topics.oneceFaultTopic:
+ case topics.realFaultTopic:
+ case topics.oneceFaultTopic:
this.handleFaultData(wdata);
break;
}
@@ -401,14 +428,18 @@
const [tenantId, equCode] = key.split("_");
const targetItem = this.dataList.find(i =>
i.tenantId == tenantId && i.code == equCode
- );
-
+ );
+
if (targetItem) {
const updatedItem = {
...targetItem,
- errorData: faults.filter(f => f.faultType === 1).map(n => n.faultName),
- warnData: faults.filter(f => f.faultType === 2).map(n => n.faultName),
- };
+ errorData: targetItem.online ? faults.filter(f => f.faultType === 1).map(n => n.faultName) : [],
+ warnData: targetItem.online ? faults.filter(f => f.faultType === 2).map(n => n.faultName) : [],
+ };
+ if(targetItem.online){
+ updatedItem.refreshTime = dayjs().format('HH:mm:ss');
+ }
+
this.$set(this.dataList, this.dataList.indexOf(targetItem), updatedItem);
}
});
--
Gitblit v1.9.3