alarmList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="alarm-wrap">
  3. <div class="alarm-t">
  4. <div class="alarm-tag">
  5. <img src="@/assets/images/warningHome/alarm-bg.png" />
  6. </div>
  7. <div class="alarm-item-wrap">
  8. <div class="item-wrap">
  9. <div
  10. class="alarm-item"
  11. v-for="(item, index) in alarmList"
  12. :key="index"
  13. @click="toggleAlarm(item, index)"
  14. :class="{ active: activeAlarm === item.id }"
  15. >
  16. {{ item.name }}
  17. <div class="active-arrow" v-if="activeAlarm === item.id">
  18. <img src="@/assets/images/warningHome/alarm-active-arrow.png" />
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="alarm-t alarm-b">
  25. <div class="alarm-tag">
  26. <img src="@/assets/images/warningHome/alarm-bg2.png" />
  27. </div>
  28. <div class="alarm-item-wrap">
  29. <div class="item-wrap">
  30. <div
  31. class="alarm-item"
  32. v-for="(item, index) in alarmFactorList"
  33. :key="index"
  34. @click="toggleAlarm(item, index)"
  35. :class="{ active: activeAlarm === item.id }"
  36. >
  37. {{ item.name }}
  38. <div class="active-arrow" v-if="activeAlarm === item.id">
  39. <img src="@/assets/images/warningHome/alarm-active-arrow.png" />
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script setup>
  48. import eventBus from "@/api/eventBus";
  49. import { onMounted, ref } from "vue";
  50. const alarmList = ref([
  51. { name: "低温冻害", id: 1 },
  52. { name: "干旱缺水", id: 2 },
  53. { name: "冲梢风险", id: 3 },
  54. { name: "病虫风险", id: 4 },
  55. ]);
  56. const alarmFactorList = ref([
  57. { name: "温度因子", id: 21 },
  58. { name: "土壤水分", id: 22 },
  59. { name: "阴坡阳坡", id: 23 },
  60. ]);
  61. const mapLayerList = ref({})
  62. onMounted(() => {
  63. VE_API.warning.fetchWarningLayer({
  64. k: "risk_map",
  65. resultType: "json",
  66. }).then(({data}) => {
  67. mapLayerList.value = data
  68. eventBus.emit("alarmList:warningLayers", data)
  69. })
  70. });
  71. const activeAlarm = ref(1);
  72. const toggleAlarm = (item, index) => {
  73. activeAlarm.value = item.id;
  74. eventBus.emit("alarmList:changeMapLayer", mapLayerList.value[item.name])
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. .alarm-wrap {
  79. background: rgba(255, 255, 255, 0.1);
  80. border: 1px solid #9f9f9f;
  81. border-radius: 8px;
  82. width: 87px;
  83. display: flex;
  84. flex-direction: column;
  85. justify-content: center;
  86. align-items: center;
  87. .alarm-t {
  88. width: 100%;
  89. padding-top: 18px;
  90. .alarm-tag {
  91. position: relative;
  92. left: -8px;
  93. }
  94. .alarm-item-wrap {
  95. padding: 0 12px;
  96. .item-wrap {
  97. padding: 12px 0 24px 0;
  98. border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  99. .alarm-item {
  100. cursor: pointer;
  101. background: #232323;
  102. width: 62px;
  103. padding: 7px 10px;
  104. box-sizing: border-box;
  105. display: flex;
  106. align-items: center;
  107. justify-content: center;
  108. font-size: 20px;
  109. font-family: "PangMenZhengDao";
  110. border-radius: 4px;
  111. &.active {
  112. margin-bottom: 34px;
  113. position: relative;
  114. color: #ffd489;
  115. background: url("@/assets/images/warningHome/alarm-active.png") no-repeat center center / cover;
  116. }
  117. .active-arrow {
  118. position: absolute;
  119. bottom: -30px;
  120. }
  121. &:last-child {
  122. &.active {
  123. margin-bottom: 14px;
  124. }
  125. }
  126. }
  127. .alarm-item + .alarm-item {
  128. margin-top: 8px;
  129. }
  130. }
  131. }
  132. }
  133. }
  134. </style>