Browse Source

fix: 传感器数值错误

master
guoapeng 2 weeks ago
parent
commit
4a151a4420
  1. 46
      src/components/home/Environment.vue
  2. 1
      src/stores/deviceStore.ts
  3. 3
      src/stores/homeStore.ts
  4. 10
      src/views/home/index.vue

46
src/components/home/Environment.vue

@ -56,82 +56,82 @@ onMounted(() => {
<img :src="imgs[envParams.type]"> {{ envParams.title }} <img :src="imgs[envParams.type]"> {{ envParams.title }}
</div> </div>
<div class="env-row odd"> <div class="env-row odd">
<div class="env-row-label ">
<div class="env-row-label">
温度 温度
</div> </div>
<div class="env-row-value ">
{{ roundNumber(envParams.temp || 0, 2) }}°C
<div class="env-row-value">
{{ envParams.temp === -1 ? '--' : roundNumber(envParams.temp, 2) }}°C
</div> </div>
</div> </div>
<div class="env-row"> <div class="env-row">
<div class="env-row-label ">
<div class="env-row-label">
相对湿度 相对湿度
</div> </div>
<div class="env-row-value"> <div class="env-row-value">
{{ roundNumber(envParams.rh || 0, 2) }}%RH
{{ envParams.rh === -1 ? '--' : roundNumber(envParams.rh, 2) }}%RH
</div> </div>
</div> </div>
<div class="env-row odd"> <div class="env-row odd">
<div class="env-row-label ">
<div class="env-row-label">
相对饱和度 相对饱和度
</div> </div>
<div class="env-row-value ">
{{ roundNumber(envParams.rs || 0, 2) }}%RS
<div class="env-row-value">
{{ envParams.rs === -1 ? '--' : roundNumber(envParams.rs, 2) }}%RS
</div> </div>
</div> </div>
<div class="env-row"> <div class="env-row">
<div class="env-row-label ">
<div class="env-row-label">
汽化过氧化氢 汽化过氧化氢
</div> </div>
<div class="env-row-value ">
{{ roundNumber(envParams.h2o2 || 0, 2) }}ppm
<div class="env-row-value">
{{ envParams.h2o2 === -1 ? '--' : roundNumber(envParams.h2o2, 2) }}ppm
</div> </div>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
div{
div {
//font-family: ; //font-family: ;
font-size: 18px; font-size: 18px;
font-weight: normal; font-weight: normal;
line-height: normal; line-height: normal;
letter-spacing: 0.06em; letter-spacing: 0.06em;
}
.title{
}
.title {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px; gap: 10px;
font-size: 26px; font-size: 26px;
padding: 1rem; padding: 1rem;
}
.title-line{
}
.title-line {
height: 1vw; height: 1vw;
position: absolute; position: absolute;
width: 100%; width: 100%;
border-radius: 10px 10px 0 0; border-radius: 10px 10px 0 0;
margin: -2.12rem; margin: -2.12rem;
}
.env-row{
}
.env-row {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
height: 7.8vh; height: 7.8vh;
padding: 7px; padding: 7px;
.env-row-label{
.env-row-label {
display: flex; display: flex;
align-items: center; align-items: center;
justify-self: start; justify-self: start;
justify-content: center; justify-content: center;
padding-left: 10px; padding-left: 10px;
} }
.env-row-value{
.env-row-value {
display: flex; display: flex;
align-items: center; align-items: center;
justify-self: end; justify-self: end;
justify-content: center; justify-content: center;
padding-right: 10px; padding-right: 10px;
} }
}
.odd {
}
.odd {
background: rgba(139, 190, 239, 0.1); background: rgba(139, 190, 239, 0.1);
}
}
</style> </style>

1
src/stores/deviceStore.ts

@ -41,7 +41,6 @@ export const useDeviceStore = defineStore('device', () => {
deviceInfo.value = info deviceInfo.value = info
isLowCost.value = info.projectType === 'DT600B' isLowCost.value = info.projectType === 'DT600B'
// isLowCost.value = true // isLowCost.value = true
console.log(isLowCost.value)
} }
/** /**

3
src/stores/homeStore.ts

@ -49,7 +49,6 @@ export const useHomeStore = defineStore('home', () => {
* @desc 湿 * @desc 湿
*/ */
const updateHomeData = (data: Home.DisplayrelyMgrs) => { const updateHomeData = (data: Home.DisplayrelyMgrs) => {
console.log('updateHomeData', data)
const sensordata = data.sensordata const sensordata = data.sensordata
if (sensordata && sensordata.length) { if (sensordata && sensordata.length) {
sensordata.forEach((item, index) => { sensordata.forEach((item, index) => {
@ -101,7 +100,7 @@ export const useHomeStore = defineStore('home', () => {
disinfectionState.value = disinfectState disinfectionState.value = disinfectState
if (!renderTimer) { if (!renderTimer) {
renderTimer = setTimeout(() => { renderTimer = setTimeout(() => {
h2O2SensorData.value = [...disinfectionState.value.h2o2SensorData] // 创建副本
// h2O2SensorData.value = [...disinfectionState.value.h2o2SensorData] // 创建副本
// updateHomeData(disinfectionState.value.h2o2SensorData) // updateHomeData(disinfectionState.value.h2o2SensorData)
renderTimer = null renderTimer = null
}, 3000) as unknown as NodeJS.Timeout // 类型断言兼容不同环境 }, 3000) as unknown as NodeJS.Timeout // 类型断言兼容不同环境

10
src/views/home/index.vue

@ -26,12 +26,12 @@ const initEnv1 = {
type: 'env1', type: 'env1',
title: '探头1', title: '探头1',
} }
const initEnv2 = {
type: 'env2',
title: '探头2',
}
// const initEnv2 = {
// type: 'env2',
// title: '2',
// }
const probe1Params = ref<Home.DisplayrelyMgrParams>(homeStore.h2O2SensorData[1] || initEnv1) const probe1Params = ref<Home.DisplayrelyMgrParams>(homeStore.h2O2SensorData[1] || initEnv1)
const probe2Params = ref<Home.DisplayrelyMgrParams>(homeStore.h2O2SensorData[2] || initEnv2)
const probe2Params = ref<Home.DisplayrelyMgrParams>(homeStore.h2O2SensorData[2])
const liquidInfo = ref<Liquid.LiquidData>(liquidStore.liquidStateData) const liquidInfo = ref<Liquid.LiquidData>(liquidStore.liquidStateData)
const liquidTotal = ref<number>(liquidStore.liquidTotal) const liquidTotal = ref<number>(liquidStore.liquidTotal)
const formulaInfo = ref() const formulaInfo = ref()

Loading…
Cancel
Save