ListThree.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="list flex items-center" :class="`list_${type}`">
  4. <div class="flex-grow" :class="`list_wrapper_${type}`">
  5. <!-- 遍历每一组传感器数据 -->
  6. <div v-for="(item, i) in listConfig" :key="`customlist${i}`" class="list-item" :class="`list-item_${type}`">
  7. <div v-for="(ctx, j) in item.contents" :key="`vvhccdclc${j}`" :class="`list-item__content_${type} ${getBgClass(ctx.value)}`">
  8. <div class="list-item__label"> {{ ctx.label }}</div>
  9. <div class="list-item__value" :class="`list-item__value_${type}`">
  10. {{ ctx.value }}
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script lang="ts" setup>
  18. withDefaults(
  19. defineProps<{
  20. listConfig: {
  21. title: string;
  22. contents: {
  23. value: string;
  24. color: string;
  25. label?: string;
  26. info?: string;
  27. }[];
  28. }[];
  29. type: string;
  30. }>(),
  31. {
  32. listConfig: () => [],
  33. type: 'C',
  34. }
  35. );
  36. const getBgClass = (riskLevel: string) => {
  37. switch (riskLevel) {
  38. case '低风险':
  39. return 'bg-lowRisk';
  40. case '一般风险':
  41. return 'bg-normalRisk';
  42. case '较大风险':
  43. return 'bg-greaterRisk ';
  44. case '重大风险':
  45. return 'bg-majorRisk';
  46. case '报警':
  47. return 'bg-warning';
  48. default:
  49. return 'bg-lowRisk';
  50. }
  51. };
  52. </script>
  53. <style lang="less" scoped>
  54. @import '/@/design/theme.less';
  55. .list {
  56. padding-left: 20px;
  57. background-repeat: no-repeat;
  58. position: relative;
  59. display: flex;
  60. align-items: center;
  61. list-style: none;
  62. }
  63. .list-item_A {
  64. align-items: center;
  65. text-align: center;
  66. margin: 10px 10px 17px 10px;
  67. display: flex;
  68. flex-direction: column; /* 竖排 */
  69. gap: 5px; /* 间距 */
  70. }
  71. .list-item__content_A {
  72. display: flex;
  73. align-items: center;
  74. justify-content: space-between;
  75. width: 100%;
  76. height: 35px;
  77. padding: 0 12px;
  78. color: #ffffff;
  79. font-size: 13px;
  80. background-repeat: no-repeat;
  81. background-size: 100% 100%;
  82. }
  83. .list-item__content_A > .list-item__label {
  84. padding-left: 40px;
  85. }
  86. .list-item__content_A > .list-item__value {
  87. padding-right: 30px;
  88. font-weight: bold;
  89. font-style: italic;
  90. }
  91. .bg-lowRisk {
  92. background-image: url('/@/assets/images/beltFire/lowRisk.png');
  93. }
  94. .bg-normalRisk {
  95. background-image: url('/@/assets/images/beltFire/normalRisk.png');
  96. }
  97. .bg-greaterRisk {
  98. background-image: url('/@/assets/images/beltFire/greaterRisk.png');
  99. }
  100. .bg-warning {
  101. background-image: url('/@/assets/images/beltFire/warning.png');
  102. }
  103. .bg-majorRisk {
  104. background-image: url('/@/assets/images/beltFire/majorRisk.png');
  105. }
  106. .list-item__content_A.bg-lowRisk .list-item__value {
  107. color: #32ddff;
  108. }
  109. .list-item__content_A.bg-normalRisk .list-item__value {
  110. color: #ffff00;
  111. }
  112. .list-item__content_A.bg-greaterRisk .list-item__value {
  113. color: #ff9d17;
  114. }
  115. .list-item__content_A.bg-warning .list-item__value {
  116. color: #ff0000;
  117. }
  118. .list-item__content_A.bg-majorRisk .list-item__value {
  119. color: #ff3823;
  120. }
  121. </style>