Browse Source

fix: 消毒图标30秒更新一次

master
guoapeng 2 weeks ago
parent
commit
862e15cbf3
  1. 31
      src/app.vue
  2. 26
      src/components/home/HomeOperation.vue
  3. 15
      src/components/home/LineChart.vue
  4. 7
      src/stores/homeStore.ts
  5. 60
      src/views/home/chart.vue

31
src/app.vue

@ -1,4 +1,4 @@
<script setup lang='ts'>
<script setup lang="ts">
import { useDeviceStore } from 'stores/deviceStore' import { useDeviceStore } from 'stores/deviceStore'
import { useHomeStore } from 'stores/homeStore' import { useHomeStore } from 'stores/homeStore'
import { useLiquidStore } from 'stores/liquidStore' import { useLiquidStore } from 'stores/liquidStore'
@ -10,6 +10,7 @@ import { sendCmd, subscribeEvent } from '@/apis/system'
import { useDebugStore } from './stores/debugStore' import { useDebugStore } from './stores/debugStore'
import { useFormulaStore } from './stores/formulaStore' import { useFormulaStore } from './stores/formulaStore'
import { useSealStore } from './stores/sealStore' import { useSealStore } from './stores/sealStore'
/** /**
* 应用初始化组件 * 应用初始化组件
* @description 负责系统初始化流程控制包括设备信息获取数据同步及进度展示 * @description 负责系统初始化流程控制包括设备信息获取数据同步及进度展示
@ -40,26 +41,34 @@ onBeforeMount(async () => {
}) })
// store // store
subscribeEvent('stateUpdate', (data) => { subscribeEvent('stateUpdate', (data) => {
if (data.fromClass === 'AirLeakDetectTest') { //
if (data.fromClass === 'AirLeakDetectTest') {
//
sealStore.updateSealInfo(data.rely) sealStore.updateSealInfo(data.rely)
} }
else if (data.fromClass === 'AddLiquidService') { //
else if (data.fromClass === 'AddLiquidService') {
//
liquidStore.updateAddLiquidWorkState(data.rely) liquidStore.updateAddLiquidWorkState(data.rely)
} }
else if (data.fromClass === 'DrainLiquidService') { //
else if (data.fromClass === 'DrainLiquidService') {
//
liquidStore.updateDrainLiquidWorkState(data.rely) liquidStore.updateDrainLiquidWorkState(data.rely)
} }
else if (data.fromClass === 'DisinfectionCtrlServiceExt') { //
else if (data.fromClass === 'DisinfectionCtrlServiceExt') {
//
homeStore.updateHomeDisinfectionState(data.rely) homeStore.updateHomeDisinfectionState(data.rely)
} }
else if (data.fromClass === 'FrontEndRealtimeDisplayContentMgr') { //
else if (data.fromClass === 'H2O2SensorMgr') {
console.log(data.rely)
//
homeStore.updateHomeData(data.rely) homeStore.updateHomeData(data.rely)
} }
else if (data.fromClass === 'AppCore') { //
else if (data.fromClass === 'AppCore') {
//
deviceStateStore.setDeviceState(data.rely) deviceStateStore.setDeviceState(data.rely)
systemStore.insertLogs(data.rely.appEvents) systemStore.insertLogs(data.rely.appEvents)
} }
else if (data.fromClass === 'TestPageCtrlService') { //
else if (data.fromClass === 'TestPageCtrlService') {
//
debugStore.updateDebugPageState(data.rely) debugStore.updateDebugPageState(data.rely)
} }
}) })
@ -71,7 +80,7 @@ subscribeEvent('stateUpdate', (data) => {
const startProgress = () => { const startProgress = () => {
timer = setInterval(async () => { timer = setInterval(async () => {
// 1-9% // 1-9%
const randomStep = Math.floor((Math.random() * 9) + 1)
const randomStep = Math.floor(Math.random() * 9 + 1)
progress.value = Math.min(progress.value + randomStep, 100) progress.value = Math.min(progress.value + randomStep, 100)
const deviceInfo: Device.DeviceInfo = await initDeviceInfo() const deviceInfo: Device.DeviceInfo = await initDeviceInfo()
if (deviceInfo.deviceType === deviceType.LargeSpaceDM_B) { if (deviceInfo.deviceType === deviceType.LargeSpaceDM_B) {
@ -155,7 +164,7 @@ const initLiquidConfig = async () => {
</router-view> </router-view>
</template> </template>
<style scoped lang='scss'>
<style scoped lang="scss">
.main-content { .main-content {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -190,7 +199,7 @@ img {
.progress-bar { .progress-bar {
height: 100%; height: 100%;
background: linear-gradient(90deg, #1989FA, #096ae0);
background: linear-gradient(90deg, #1989fa, #096ae0);
border-radius: 30px; border-radius: 30px;
transition: width 0.3s ease; transition: width 0.3s ease;
} }

26
src/components/home/HomeOperation.vue

@ -56,8 +56,7 @@ watchEffect(() => {
/** /**
* @hook 生命周期钩子 - 组件挂载完成时执行 * @hook 生命周期钩子 - 组件挂载完成时执行
*/ */
onMounted(async () => {
})
onMounted(async () => {})
/** /**
* @function 开始消毒操作 * @function 开始消毒操作
@ -75,6 +74,8 @@ const onStartDisinfect = () => {
}) })
} }
let poll = null
const doStartDisinfect = async () => { const doStartDisinfect = async () => {
// //
const statusName = getDeviceStatus() const statusName = getDeviceStatus()
@ -97,6 +98,9 @@ const doStartDisinfect = async () => {
} }
await sendCmd(startParams) await sendCmd(startParams)
} }
// , 30
poll = setInterval(async () => {}, 1000 * 30)
console.log(poll)
} }
finally { finally {
systemStore.updateLoading(false) systemStore.updateLoading(false)
@ -177,12 +181,8 @@ const operationState = computed(() => {
<!-- 开始消毒时显示剩余时间或状态 --> <!-- 开始消毒时显示剩余时间或状态 -->
<div v-if="!operationState" class="home-remain-time"> <div v-if="!operationState" class="home-remain-time">
<div class="home-remaini-label"> <div class="home-remaini-label">
<span v-if="disinfectionState.state === 'disinfection'">
预计剩余时间:
</span>
<span v-else>
消毒状态
</span>
<span v-if="disinfectionState.state === 'disinfection'"> 预计剩余时间: </span>
<span v-else> 消毒状态 </span>
</div> </div>
<div v-if="disinfectionState.state === 'disinfection'" class="home-remaini-value"> <div v-if="disinfectionState.state === 'disinfection'" class="home-remaini-value">
{{ curStateRemainTimeS }} {{ curStateRemainTimeS }}
@ -203,7 +203,7 @@ const operationState = computed(() => {
width: 27vw; width: 27vw;
height: 8vh; height: 8vh;
border-radius: 12px; border-radius: 12px;
color: #FFFFFF;
color: #ffffff;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -211,14 +211,14 @@ const operationState = computed(() => {
gap: 10px; gap: 10px;
} }
.home-start { .home-start {
background: #31CB7A;
background: #31cb7a;
} }
.home-end { .home-end {
background: #FF6767;
background: #ff6767;
} }
.home-remain-time { .home-remain-time {
background: #F6FAFE;
background: #f6fafe;
margin-top: 6rem; margin-top: 6rem;
margin-left: 1rem; margin-left: 1rem;
margin-right: 1rem; margin-right: 1rem;
@ -230,7 +230,7 @@ const operationState = computed(() => {
font-size: 24px; font-size: 24px;
gap: 10px; gap: 10px;
.home-remaini-value { .home-remaini-value {
color: #2892F3;
color: #2892f3;
} }
} }
</style> </style>

15
src/components/home/LineChart.vue

@ -1,9 +1,10 @@
<script lang="ts" setup> <script lang="ts" setup>
import * as echarts from 'echarts' import * as echarts from 'echarts'
import { formatDateTime } from 'libs/utils'
import { onMounted, ref, watch } from 'vue' import { onMounted, ref, watch } from 'vue'
const props = defineProps<{ const props = defineProps<{
envData: Home.DisplayrelyMgrParams
envData: any
}>() }>()
const titles = { const titles = {
@ -11,6 +12,7 @@ const titles = {
WiredExtSensor: '外接传感器', WiredExtSensor: '外接传感器',
WirelessExtSensor: '无线传感器', WirelessExtSensor: '无线传感器',
} }
watch( watch(
() => props.envData, () => props.envData,
(newValue) => { (newValue) => {
@ -23,7 +25,7 @@ watch(
} }
const option = { const option = {
title: { title: {
text: titles[newValue?.[0]?.type || ''] || '',
text: titles[newValue?.type || ''] || '',
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -40,6 +42,7 @@ watch(
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: newValue.data.map(item => formatDateTime('HH:mm:ss', item.timestamp)),
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
@ -48,7 +51,7 @@ watch(
{ {
name: '温度', name: '温度',
type: 'line', type: 'line',
data: newValue.map(item => item.temp.toFixed(2)),
data: newValue.data.map(item => item.temp.toFixed(2)),
symbol: 'circle', symbol: 'circle',
symbolSize: 2, symbolSize: 2,
lineStyle: { lineStyle: {
@ -59,7 +62,7 @@ watch(
{ {
name: '湿度', name: '湿度',
type: 'line', type: 'line',
data: newValue.map(item => item.rh.toFixed(2)),
data: newValue.data.map(item => item.rh.toFixed(2)),
symbol: 'circle', symbol: 'circle',
symbolSize: 2, symbolSize: 2,
lineStyle: { lineStyle: {
@ -70,7 +73,7 @@ watch(
{ {
name: 'H2O2浓度', name: 'H2O2浓度',
type: 'line', type: 'line',
data: newValue.map(item => item.h2o2.toFixed(2)),
data: newValue.data.map(item => item.h2o2.toFixed(2)),
symbol: 'circle', symbol: 'circle',
symbolSize: 2, symbolSize: 2,
lineStyle: { lineStyle: {
@ -81,7 +84,7 @@ watch(
{ {
name: 'H2O2饱和度', name: 'H2O2饱和度',
type: 'line', type: 'line',
data: newValue.map(item => item.rs.toFixed(2)),
data: newValue.data.map(item => item.rs.toFixed(2)),
symbol: 'circle', symbol: 'circle',
symbolSize: 2, symbolSize: 2,
lineStyle: { lineStyle: {

7
src/stores/homeStore.ts

@ -50,10 +50,8 @@ export const useHomeStore = defineStore('home', () => {
* @param {Home.DisplayrelyMgr[]} data - * @param {Home.DisplayrelyMgr[]} data -
* @desc 湿 * @desc 湿
*/ */
const updateHomeData = (data: Home.DisplayrelyMgrs) => {
const sensordata = data.sensordata
if (sensordata && sensordata.length) {
sensordata.forEach((item, index) => {
const updateHomeData = (data: Home.DisplayrelyMgr[]) => {
data.forEach((item, index) => {
if (allData.value[index]) { if (allData.value[index]) {
allData.value[index].data.push(item) allData.value[index].data.push(item)
// data中的数据只保留最后30条 // data中的数据只保留最后30条
@ -72,7 +70,6 @@ export const useHomeStore = defineStore('home', () => {
} }
}) })
} }
}
const updatePressureConfig = (data: Home.ParssureData) => { const updatePressureConfig = (data: Home.ParssureData) => {
pressureConfig.value = data || PARSSURE_DATA pressureConfig.value = data || PARSSURE_DATA

60
src/views/home/chart.vue

@ -8,7 +8,7 @@ import LineChart from 'components/home/LineChart.vue'
import { stopTimer } from 'libs/countdownTimer' import { stopTimer } from 'libs/countdownTimer'
import { deviceStateMap } from 'libs/utils' import { deviceStateMap } from 'libs/utils'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import { provide, ref, watchEffect } from 'vue'
import { computed, onMounted, onUnmounted, provide, ref, watchEffect } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useFormulaStore } from '@/stores/formulaStore' import { useFormulaStore } from '@/stores/formulaStore'
@ -77,6 +77,55 @@ const goHome = () => {
const onClose = () => { const onClose = () => {
disinfectFormulaVisible.value = false disinfectFormulaVisible.value = false
} }
const chartList = ref<any[]>([])
const operationState = computed(() => {
return disinfectionState.value.state === 'idle' || disinfectionState.value.state === 'finished'
})
let poll = null
const getData = async () => {
const res = await syncSendCmd({
className: 'DisinfectionCtrlServiceExt',
fnName: 'getState',
})
console.log(res.rely.startTimestamp)
const data = await syncSendCmd({
className: 'H2O2SensorMgr',
fnName: 'getH2O2SensorList',
})
chartList.value = data.rely
for (let i = 0; i < chartList.value.length; i++) {
const item: any = chartList.value[i]
const list = await syncSendCmd({
className: 'H2O2SensorMgr',
fnName: 'getH2O2DataRecordList',
params: {
type: item.type,
id: item.id,
since: res.rely?.startTimestamp,
interval: 30,
before: 0,
},
})
chartList.value[i].data = list.rely
}
console.log(chartList.value)
}
onMounted(async () => {
await getData()
poll = setInterval(() => {
if (!operationState.value) {
clearInterval(poll)
}
getData()
}, 1000 * 30)
})
onUnmounted(() => {
clearInterval(poll)
})
</script> </script>
<template> <template>
@ -102,12 +151,9 @@ const onClose = () => {
</bt-button> </bt-button>
</div> </div>
</div> </div>
<div
class="line-chart-content"
:style="{ 'grid-template-columns': `repeat(${homeStore.h2O2SensorData.length},1fr)` }"
>
<div v-for="(item, index) in homeStore.allData" :key="index">
<LineChart :env-data="item.data" />
<div class="line-chart-content" :style="{ 'grid-template-columns': `repeat(${chartList.length},1fr)` }">
<div v-for="(item, index) in chartList" :key="index">
<LineChart :env-data="item" />
</div> </div>
</div> </div>
<div class="line-chart-bottom"> <div class="line-chart-bottom">

Loading…
Cancel
Save