basicCard3.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="basicCard3">
  3. <div
  4. :class="activeIndex == index ? 'card3-box1' : 'card3-box'"
  5. v-for="(item, index) in card3Lists"
  6. :key="index"
  7. @click="toggleChange(index, item)"
  8. >
  9. <div class="card3-box-title">{{ item.title }}</div>
  10. <div class="card3-box-nd">
  11. <span class="card3-box-label">{{ item.ndLabel }}</span>
  12. <span class="card3-box-val">{{ `${item.ndVal}%` }}</span>
  13. </div>
  14. <div class="card3-box-time">
  15. <span class="card3-box-label">{{ item.tLabel }}</span>
  16. <span class="card3-box-val">{{ item.tVal }}</span>
  17. </div>
  18. <div class="card3-box-address">
  19. <span class="card3-box-label">{{ item.aLabel }}</span>
  20. <span class="card3-box-val">{{ item.aVal }}</span>
  21. </div>
  22. <div class="card3-box-warn">
  23. <div class="card3-box-item">
  24. {{ warningLevel }}
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script lang="ts" setup>
  31. import { ref, reactive, defineProps, watch, defineEmits } from 'vue';
  32. let props = defineProps({
  33. card3List: {
  34. type: Array,
  35. default: () => {
  36. return [];
  37. },
  38. },
  39. //风险等级
  40. warningLevel: {
  41. type: String,
  42. default: () => {
  43. return '';
  44. },
  45. },
  46. });
  47. let activeIndex = ref(0);
  48. let card3Lists = ref<any[]>([]);
  49. const emit = defineEmits(['toggleChange']);
  50. //选项切换
  51. function toggleChange(index, item) {
  52. console.log(index, '当前激活索引-------');
  53. activeIndex.value = index;
  54. emit('toggleChange', item.title);
  55. }
  56. watch(
  57. () => props.card3List,
  58. (newV, oldV) => {
  59. console.log(newV, 'newV---------');
  60. card3Lists.value = newV;
  61. },
  62. {
  63. immediate: true,
  64. deep: true,
  65. },
  66. );
  67. </script>
  68. <style lang="less" scoped>
  69. @font-face {
  70. font-family: douyuFont;
  71. src: url('../../../assets/font/douyuFont.otf');
  72. }
  73. .basicCard3 {
  74. display: flex;
  75. position: relative;
  76. box-sizing: border-box;
  77. align-items: flex-end;
  78. justify-content: flex-start;
  79. width: 100%;
  80. height: 100%;
  81. padding-bottom: 15px;
  82. overflow-x: auto;
  83. transform: scaleY(-1);
  84. .card3-box {
  85. position: relative;
  86. flex-shrink: 0;
  87. width: 352px;
  88. height: 202px;
  89. margin-right: 20px;
  90. transform: scaleY(-1);
  91. background: url('../../../assets/images/workPlaceWarn/composite.png') no-repeat center;
  92. background-size: 100% 100%;
  93. &:last-child {
  94. margin-right: 0;
  95. }
  96. .card3-box-title {
  97. position: absolute;
  98. top: 11px;
  99. width: 100%;
  100. color: #fff;
  101. font-size: 18px;
  102. text-align: center;
  103. }
  104. .card3-box-nd {
  105. display: flex;
  106. position: absolute;
  107. top: 55px;
  108. left: 50%;
  109. box-sizing: border-box;
  110. align-items: center;
  111. justify-content: space-between;
  112. width: 312px;
  113. height: 34px;
  114. padding: 0 10px;
  115. transform: translate(-50%, 0);
  116. background: url('../../../assets/images/workPlaceWarn/composite2.png') no-repeat center;
  117. background-size: 100% 100%;
  118. }
  119. .card3-box-time {
  120. display: flex;
  121. position: absolute;
  122. top: 100px;
  123. left: 50%;
  124. box-sizing: border-box;
  125. align-items: center;
  126. justify-content: space-between;
  127. width: 312px;
  128. height: 34px;
  129. padding: 0 10px;
  130. transform: translate(-50%, 0);
  131. background: url('../../../assets/images/workPlaceWarn/composite2.png') no-repeat center;
  132. background-size: 100% 100%;
  133. }
  134. .card3-box-address {
  135. display: flex;
  136. position: absolute;
  137. top: 145px;
  138. left: 50%;
  139. box-sizing: border-box;
  140. align-items: center;
  141. justify-content: space-between;
  142. width: 312px;
  143. height: 34px;
  144. padding: 0 10px;
  145. transform: translate(-50%, 0);
  146. background: url('../../../assets/images/workPlaceWarn/composite2.png') no-repeat center;
  147. background-size: 100% 100%;
  148. }
  149. .card3-box-warn {
  150. position: absolute;
  151. bottom: 0;
  152. left: 0;
  153. width: 75px;
  154. height: 75px;
  155. .card3-box-item {
  156. position: absolute;
  157. top: 52%;
  158. left: 7%;
  159. transform: rotate(45deg);
  160. color: #fff;
  161. }
  162. }
  163. .card3-box-label {
  164. width: 40px;
  165. color: #fff;
  166. }
  167. .card3-box-val {
  168. color: #0097db;
  169. font-family: douyuFont;
  170. }
  171. }
  172. .card3-box1 {
  173. position: relative;
  174. flex-shrink: 0;
  175. width: 352px;
  176. height: 230px;
  177. margin-right: 20px;
  178. transform: scaleY(-1);
  179. background: url('../../../assets/images/workPlaceWarn/composite1.png') no-repeat center;
  180. background-size: 100% 100%;
  181. &:last-child {
  182. margin-right: 0;
  183. }
  184. .card3-box-title {
  185. position: absolute;
  186. top: 11px;
  187. width: 100%;
  188. color: #fff;
  189. font-size: 18px;
  190. text-align: center;
  191. }
  192. .card3-box-nd {
  193. display: flex;
  194. position: absolute;
  195. top: 55px;
  196. left: 50%;
  197. box-sizing: border-box;
  198. align-items: center;
  199. justify-content: space-between;
  200. width: 312px;
  201. height: 34px;
  202. padding: 0 10px;
  203. transform: translate(-50%, 0);
  204. background: url('../../../assets/images/workPlaceWarn/composite2.png') no-repeat center;
  205. background-size: 100% 100%;
  206. }
  207. .card3-box-time {
  208. display: flex;
  209. position: absolute;
  210. top: 100px;
  211. left: 50%;
  212. box-sizing: border-box;
  213. align-items: center;
  214. justify-content: space-between;
  215. width: 312px;
  216. height: 34px;
  217. padding: 0 10px;
  218. transform: translate(-50%, 0);
  219. background: url('../../../assets/images/workPlaceWarn/composite2.png') no-repeat center;
  220. background-size: 100% 100%;
  221. }
  222. .card3-box-address {
  223. display: flex;
  224. position: absolute;
  225. top: 145px;
  226. left: 50%;
  227. box-sizing: border-box;
  228. align-items: center;
  229. justify-content: space-between;
  230. width: 312px;
  231. height: 34px;
  232. padding: 0 10px;
  233. transform: translate(-50%, 0);
  234. background: url('../../../assets/images/workPlaceWarn/composite2.png') no-repeat center;
  235. background-size: 100% 100%;
  236. }
  237. .card3-box-warn {
  238. position: absolute;
  239. bottom: 0;
  240. left: 0;
  241. width: 75px;
  242. height: 100px;
  243. .card3-box-item {
  244. position: absolute;
  245. top: 36%;
  246. left: 8%;
  247. transform: rotate(45deg);
  248. color: #fff;
  249. }
  250. }
  251. .card3-box-label {
  252. width: 40px;
  253. color: #fff;
  254. }
  255. .card3-box-val {
  256. color: #0097db;
  257. font-family: douyuFont;
  258. }
  259. }
  260. }
  261. </style>