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.

62 lines
1.7 KiB

2 months ago
2 months ago
  1. <script setup lang="ts">
  2. import { computed } from 'vue'
  3. const props = defineProps({
  4. data: {
  5. type: Object,
  6. default: () => {
  7. return {}
  8. },
  9. },
  10. })
  11. const solutionStyle = computed(() => {
  12. const difference = (props.data.capacityTotal - props.data.capacityUsed) / props.data.capacityTotal
  13. const process = 100 - (difference * 100)
  14. const filter = difference > 0.4 ? 'hue-rotate(270deg) saturate(100) brightness(81%)' : difference > 0.1 ? 'hue-rotate(150deg) saturate(100)' : 'hue-rotate(120deg) saturate(100)'
  15. return {
  16. 'filter': filter,
  17. '-webkit-mask': `linear-gradient(to bottom, transparent ${process}%, #EEEFF8 ${process + 0.01}%)`,
  18. }
  19. })
  20. const percentage = computed(() => Number(((props.data.capacityTotal - props.data.capacityUsed) / props.data.capacityTotal).toFixed(2)) * 100)
  21. </script>
  22. <template>
  23. <div class="liquid-content">
  24. <div class="bottle_base">
  25. <img class="content-img" src="@/assets/images/liquied/liquied_bottle.svg" alt="chemical-bottle">
  26. </div>
  27. <div class="bottle" :style="solutionStyle">
  28. <img class="content-img" src="@/assets/images/liquied/liquied_bottle.svg" alt="chemical-bottle">
  29. </div>
  30. <div class="num" :style="{ color: percentage > 40 ? '#fff' : percentage > 10 ? '#FF8E00' : '#FF1C00' }">
  31. {{ percentage }} %
  32. </div>
  33. </div>
  34. </template>
  35. <style scoped lang="scss">
  36. .liquid-content{
  37. position: relative;
  38. display: flex;
  39. justify-content: center;
  40. }
  41. .bottle_base{
  42. position: relative;
  43. }
  44. .bottle {
  45. position: absolute;
  46. }
  47. .content-img{
  48. height: 80px;
  49. margin: 10px;
  50. }
  51. .num {
  52. position: absolute;
  53. top: 50%;
  54. left: 50%;
  55. transform: translate(-50%, -50%);
  56. font-weight: 700;
  57. }
  58. </style>