YjTuli.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div class="tuli">
  3. <div class="title">
  4. <el-checkbox class="yse-events" v-model="checked" label="" size="small" />
  5. <span>状态图例</span>
  6. </div>
  7. <div class="list">
  8. <div class="item" v-for="item in list" :key="item.id">
  9. <template v-if="item.outerType === 3">
  10. <img
  11. :src="require(`@/assets/status/status_${item.icon}.png`)"
  12. width="15"
  13. />
  14. <div class="text">
  15. {{ item.name }}
  16. </div>
  17. </template>
  18. <template v-else>
  19. <div :class="item.style" :style="iconStyle(item.style, index, item)"></div>
  20. <span class="text">{{ item.name }}</span>
  21. </template>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script setup>
  27. import { toRefs, ref, onMounted, watch } from "vue";
  28. const list = ref([]);
  29. const checked = ref(true);
  30. onMounted(async () => {
  31. list.value = arr;
  32. });
  33. const arr = [
  34. {
  35. name: "病虫异常",
  36. icon: "bcyc",
  37. outerType: 3,
  38. },
  39. {
  40. name: "生长异常",
  41. icon: "szyc",
  42. outerType: 3,
  43. },
  44. {
  45. name: "待复核",
  46. icon: "dfh",
  47. outerType: 3,
  48. },
  49. {
  50. name: "巡飞点位",
  51. icon: "xfdw",
  52. outerType: 3,
  53. },
  54. ];
  55. const props = defineProps({
  56. tabValue: {
  57. type: Object,
  58. default: () => {},
  59. },
  60. });
  61. const iconStyle = (type, index, item) => {
  62. if (type === "triangle") {
  63. return { borderBottomColor: item.color };
  64. }
  65. if (type === "circular") {
  66. return { background: item.color };
  67. }
  68. };
  69. watch(
  70. () => props.tabValue,
  71. (newValue, oldValue) => {
  72. if (newValue) {
  73. console.log("newValue", newValue);
  74. if (newValue.type === 3) {
  75. list.value = arr;
  76. } else {
  77. list.value = newValue.items.map(item =>{
  78. return {
  79. ...item,
  80. outerType:newValue.type,
  81. style:newValue.style
  82. }
  83. });
  84. }
  85. }
  86. }
  87. );
  88. </script>
  89. <style lang="scss" scoped>
  90. .tuli {
  91. width: 108px;
  92. background: rgba(3, 44, 57, 0.9);
  93. border-radius: 4px;
  94. border: 1px solid rgba(81, 233, 240, 0.3);
  95. .title {
  96. height: 30px;
  97. text-align: center;
  98. line-height: 30px;
  99. background: rgba(205, 243, 255, 0.15);
  100. border-radius: 4px 4px 0px 0px;
  101. border: 1px solid rgba(81, 233, 240, 0.3);
  102. font-size: 14px;
  103. font-family: PingFangSC-Regular, PingFang SC;
  104. font-weight: 400;
  105. color: #00fff0;
  106. }
  107. .list {
  108. width: 100%;
  109. display: flex;
  110. flex-direction: column;
  111. align-items: center;
  112. justify-content: space-around;
  113. padding: 10px 10px 10px 10px;
  114. .item {
  115. width: 100%;
  116. padding: 5px 5px 0px 5px;
  117. display: flex;
  118. flex-direction: row;
  119. align-items: center;
  120. justify-content: center;
  121. .circular {
  122. width: 12px;
  123. height: 12px;
  124. border-radius: 50px;
  125. background: #b0e000;
  126. }
  127. .triangle {
  128. width: 0;
  129. height: 0;
  130. border-left: 6px solid transparent; /* 左边框设置为透明 */
  131. border-right: 6px solid transparent; /* 右边框设置为透明 */
  132. border-bottom: 12px solid #d63f3c; /* 下边框设置为你想要的颜色和大小,这将形成三角形的底部 */
  133. }
  134. .color {
  135. width: 20%;
  136. height: 14px;
  137. }
  138. .text {
  139. margin-left: 5px;
  140. width: 76%;
  141. font-size: 12px;
  142. font-family: PingFangSC-Regular, PingFang SC;
  143. font-weight: 400;
  144. color: #ffffff;
  145. line-height: 17px;
  146. }
  147. }
  148. }
  149. }
  150. </style>