basicCard4.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="basicCard4">
  3. <div
  4. :class="activeIndex == index ? 'card4-box1' : 'card4-box'"
  5. v-for="(item, index) in card4List"
  6. :key="index"
  7. @click="toggleDustCard(index, item)"
  8. >
  9. <div class="card4-title">{{ item.title }}</div>
  10. <div class="card4-content">
  11. <div class="content-item" v-for="(items, ind) in item.list" :key="ind">
  12. <span>{{ items.label }}</span>
  13. <span>{{ items.value }}</span>
  14. </div>
  15. </div>
  16. <div class="card4-level">
  17. <div class="level-text">{{ warningLevel }}</div>
  18. </div>
  19. </div>
  20. </div>
  21. </template>
  22. <script lang="ts" setup>
  23. import { ref, reactive, defineProps, watch, defineEmits } from 'vue';
  24. let props = defineProps({
  25. cardData4: {
  26. type: Array,
  27. default: () => {
  28. return [];
  29. },
  30. },
  31. warningLevel: {
  32. type: String,
  33. default: '',
  34. },
  35. });
  36. let emit = defineEmits(['toggleDustCards']);
  37. let activeIndex = ref(0);
  38. let card4List = ref<any[]>([]);
  39. function toggleDustCard(index, item) {
  40. activeIndex.value = index;
  41. emit('toggleDustCards', item.sensorCode);
  42. }
  43. watch(
  44. () => props.cardData4,
  45. (newC, oldC) => {
  46. console.log(newC, 'newC------');
  47. if (newC.length != 0) {
  48. card4List.value = newC;
  49. }
  50. },
  51. {
  52. immediate: true,
  53. deep: true,
  54. },
  55. );
  56. </script>
  57. <style lang="less" scoped>
  58. .basicCard4 {
  59. display: flex;
  60. position: relative;
  61. box-sizing: border-box;
  62. align-items: flex-end;
  63. justify-content: flex-start;
  64. width: 100%;
  65. height: 100%;
  66. padding-bottom: 10px;
  67. overflow-x: auto;
  68. transform: scaleY(-1);
  69. background-color: rgb(41 49 53 / 80%);
  70. .card4-box {
  71. position: relative;
  72. flex-shrink: 0;
  73. width: 338px;
  74. height: 147px;
  75. margin: 0 10px;
  76. transform: scaleY(-1);
  77. background: url('../../../assets/images/workPlaceWarn/composite.png') no-repeat center;
  78. background-size: 100% 100%;
  79. .card4-title {
  80. position: absolute;
  81. top: 8px;
  82. left: 0;
  83. width: 100%;
  84. color: #fff;
  85. font-size: 14px;
  86. text-align: center;
  87. }
  88. .card4-content {
  89. display: flex;
  90. position: absolute;
  91. top: 26px;
  92. left: 0;
  93. flex-wrap: wrap;
  94. align-items: flex-start;
  95. justify-content: flex-start;
  96. width: 100%;
  97. height: 120px;
  98. .content-item {
  99. display: flex;
  100. align-items: center;
  101. justify-content: space-around;
  102. width: 50%;
  103. height: 50%;
  104. background: url('../../../assets/images/dust/dusthome/content-item.png') no-repeat center;
  105. background-size: 95% 50%;
  106. span {
  107. &:first-child {
  108. color: #fff;
  109. font-size: 14px;
  110. }
  111. &:last-child {
  112. color: #01fefc;
  113. font-family: douyuFont;
  114. }
  115. }
  116. }
  117. }
  118. .card4-level {
  119. position: absolute;
  120. bottom: 0;
  121. left: 0;
  122. width: 75px;
  123. height: 75px;
  124. .level-text {
  125. position: absolute;
  126. top: 65%;
  127. left: 10%;
  128. transform: rotate(45deg);
  129. color: #fff;
  130. font-size: 12px;
  131. }
  132. }
  133. }
  134. .card4-box1 {
  135. position: relative;
  136. flex-shrink: 0;
  137. width: 338px;
  138. height: 170px;
  139. margin: 0 10px;
  140. transform: scaleY(-1);
  141. background: url('../../../assets/images/workPlaceWarn/composite1.png') no-repeat center;
  142. background-size: 100% 100%;
  143. .card4-title {
  144. position: absolute;
  145. top: 8px;
  146. left: 0;
  147. width: 100%;
  148. color: #fff;
  149. font-size: 16px;
  150. text-align: center;
  151. }
  152. .card4-content {
  153. display: flex;
  154. position: absolute;
  155. top: 26px;
  156. left: 0;
  157. flex-wrap: wrap;
  158. align-items: flex-start;
  159. justify-content: flex-start;
  160. width: 100%;
  161. height: 120px;
  162. .content-item {
  163. display: flex;
  164. align-items: center;
  165. justify-content: space-around;
  166. width: 50%;
  167. height: 50%;
  168. background: url('../../../assets/images/dust/dusthome/content-item.png') no-repeat center;
  169. background-size: 95% 50%;
  170. span {
  171. &:first-child {
  172. color: #fff;
  173. font-size: 12px;
  174. }
  175. &:last-child {
  176. color: #01fefc;
  177. font-family: douyuFont;
  178. font-size: 14px;
  179. }
  180. }
  181. }
  182. }
  183. .card4-level {
  184. position: absolute;
  185. bottom: 0;
  186. left: 0;
  187. width: 75px;
  188. height: 75px;
  189. .level-text {
  190. position: absolute;
  191. top: 36%;
  192. left: 10%;
  193. transform: rotate(45deg);
  194. color: #fff;
  195. font-size: 12px;
  196. }
  197. }
  198. }
  199. }
  200. </style>