消毒机设备
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.9 KiB

3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
2 months ago
2 months ago
  1. <script lang="ts" setup>
  2. import liquidLevelSvg from 'assets/images/liquid/liquid-container.svg'
  3. import ScaleRuler from 'components/liquid/ScaleRuler.vue'
  4. // import liquidScaleSvg from 'assets/images/liquid/liquid-scale.svg'
  5. import { roundNumber } from 'libs/utils'
  6. import { computed, onMounted, ref, watchEffect } from 'vue'
  7. import { useLiquidStore } from '@/stores/liquidStore'
  8. const elementHeight = ref(200)
  9. const liquidContainelRef = ref<HTMLElement | null>(null)
  10. const rulerHeight = ref(0)
  11. onMounted(() => {
  12. const element = document.querySelector('.liquid-level-img')
  13. if (element) {
  14. elementHeight.value = element.clientHeight
  15. console.log('元素高度:', elementHeight.value)
  16. }
  17. if (liquidContainelRef.value) {
  18. rulerHeight.value = liquidContainelRef.value.offsetHeight
  19. }
  20. })
  21. const liquidStore = useLiquidStore()
  22. const liquidStateData = ref(liquidStore.liquidStateData)
  23. const liquidTotal = ref(liquidStore.liquidTotal)
  24. watchEffect(() => {
  25. liquidTotal.value = liquidStore.liquidTotal
  26. liquidStateData.value = liquidStore.liquidStateData
  27. })
  28. const nowLiquid = computed(() => {
  29. return roundNumber(liquidStateData.value.nowLiquid, 0)
  30. })
  31. // 计算液位高度(根据比例计算,假设图片高度固定为200px,可根据实际调整)
  32. const liquidHeight = computed(() => {
  33. return ((Number(nowLiquid.value) / Number(liquidTotal.value)) * 100).toFixed(2)
  34. })
  35. </script>
  36. <template>
  37. <div class="liquid-level-main">
  38. <ScaleRuler :key="rulerHeight" :max-scale="liquidTotal" :ruler-height="rulerHeight" />
  39. <div ref="liquidContainelRef" class="liquid-level-container">
  40. <img :src="liquidLevelSvg" alt="液位图" class="liquid-level-img-r">
  41. <!-- <div class="liquid-level-middle" :style="{ height: `${liquidHeight}px` }" /> -->
  42. <div class="liquid-level" :style="{ height: `${liquidHeight}%` }" />
  43. <div class="current-level">
  44. <span>当前液位</span>
  45. <span class="text">{{ nowLiquid }}</span>
  46. <span class="text">g</span>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <style lang="scss" scoped>
  52. .liquid-level-main {
  53. display: flex;
  54. gap: 5px;
  55. }
  56. .liquid-level-container{
  57. position: relative;
  58. height: 60vh;; /* 根据实际调整 */
  59. }
  60. .liquid-level-img-l {
  61. height: 62.5vh;
  62. margin-top: -1.5vh;
  63. }
  64. .liquid-level-img-r {
  65. height: 60vh;
  66. }
  67. .liquid-level {
  68. position: absolute;
  69. bottom: 0;
  70. left: 0;
  71. width: 100%;
  72. background: linear-gradient(to top, #0099ff, #7fc8fa); /* 颜色渐变,可按需调整 */
  73. min-height: .8rem;
  74. border-radius: 0 0 20px 20px;
  75. }
  76. .liquid-level-middle{
  77. background: linear-gradient(352deg, #0093f5, #effafe);
  78. bottom: 0;
  79. left: 0;
  80. position: absolute;
  81. width: 50%;
  82. z-index: 1;
  83. margin-left: 23%
  84. }
  85. .current-level {
  86. position: absolute;
  87. top: 2rem;
  88. left: 50%;
  89. transform: translateX(-50%);
  90. font-size: 1.3rem;
  91. font-weight: bold;
  92. .text{
  93. color: #007bff;
  94. padding: 3px;
  95. }
  96. }
  97. </style>