|
|
@ -8,7 +8,7 @@ import { computed, onMounted, ref, watchEffect } from 'vue' |
|
|
|
import { useLiquidStore } from '@/stores/liquidStore' |
|
|
|
|
|
|
|
const elementHeight = ref(200) |
|
|
|
const liquidContailRef = ref<HTMLElement | null>(null) |
|
|
|
const liquidContainelRef = ref<HTMLElement | null>(null) |
|
|
|
const rulerHeight = ref(0) |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
@ -17,11 +17,11 @@ onMounted(() => { |
|
|
|
elementHeight.value = element.clientHeight |
|
|
|
console.log('元素高度:', elementHeight.value) |
|
|
|
} |
|
|
|
if (liquidContailRef.value) { |
|
|
|
console.log('liquidContailRef=offsetHeight==', liquidContailRef.value.offsetHeight) |
|
|
|
rulerHeight.value = liquidContailRef.value.offsetHeight + 5 |
|
|
|
if (liquidContainelRef.value) { |
|
|
|
rulerHeight.value = liquidContainelRef.value.offsetHeight |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
const liquidStore = useLiquidStore() |
|
|
|
const liquidStateData = ref(liquidStore.liquidStateData) |
|
|
|
const liquidTotal = ref(liquidStore.liquidTotal) |
|
|
@ -43,10 +43,9 @@ const liquidHeight = computed(() => { |
|
|
|
|
|
|
|
<template> |
|
|
|
<div class="liquid-level-main"> |
|
|
|
<ScaleRuler :max-scale="liquidTotal" :rulerHeight="rulerHeight" :key="rulerHeight"/> |
|
|
|
<div class="liquid-level-container"> |
|
|
|
<div class="liquid-level" :style="{ height: `${liquidHeight}%` }" /> |
|
|
|
<img ref="liquidContailRef" :src="liquidLevelSvg" alt="液位图" class="liquid-level-img-r"> |
|
|
|
<ScaleRuler :key="rulerHeight" :max-scale="liquidTotal" :ruler-height="rulerHeight" /> |
|
|
|
<div ref="liquidContainelRef" class="liquid-level-container"> |
|
|
|
<img :src="liquidLevelSvg" alt="液位图" class="liquid-level-img-r"> |
|
|
|
<!-- <div class="liquid-level-middle" :style="{ height: `${liquidHeight}px` }" /> --> |
|
|
|
<div class="liquid-level" :style="{ height: `${liquidHeight}%` }" /> |
|
|
|
<div class="current-level"> |
|
|
@ -72,7 +71,7 @@ const liquidHeight = computed(() => { |
|
|
|
margin-top: -1.5vh; |
|
|
|
} |
|
|
|
.liquid-level-img-r { |
|
|
|
height: 31rem; |
|
|
|
height: 60vh; |
|
|
|
} |
|
|
|
.liquid-level { |
|
|
|
position: absolute; |
|
|
|