Warning.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="warning">
  4. <div class="warning-item" v-for="item in WARNING_CONFIG" :key="item.id" @click="$emit('click', item)">
  5. <div class="img"> <img :src="item.src" alt="" /> </div>
  6. <div class="text">{{ item.text }}</div>
  7. <div class="extra">监测数量</div>
  8. <div class="num" :class="`warning-level_${warnData.maxLevel}`">{{ warnData[item.prop] }}</div>
  9. <div class="risk" :class="`warning-level_${warnData.maxLevel}`">{{ warnData[item.prop2] }}</div>
  10. </div>
  11. </div>
  12. </template>
  13. <script lang="ts" setup>
  14. import { shallowRef, onMounted } from 'vue';
  15. import { BillboardType, DEFAULT_TEST_DATA, WARNING_CONFIG } from '../billboard.data';
  16. import _ from 'lodash-es';
  17. const props = withDefaults(
  18. defineProps<{
  19. data?: BillboardType;
  20. }>(),
  21. {
  22. data: () => DEFAULT_TEST_DATA,
  23. }
  24. );
  25. defineEmits(['click']);
  26. const warnData = shallowRef<BillboardType['warningInfo']>({
  27. total: 5,
  28. vent: 1,
  29. ventRisk: '低风险',
  30. gas: 1,
  31. gasRisk: '低风险',
  32. dust: 1,
  33. dustRisk: '低风险',
  34. fire: 1,
  35. fireRisk: '低风险',
  36. safety: 1,
  37. safetyRisk: '低风险',
  38. maxLevel: 5,
  39. });
  40. function fetchData() {
  41. const info = props.data.warningInfo;
  42. if (!info) return;
  43. warnData.value = info;
  44. }
  45. onMounted(() => {
  46. fetchData();
  47. });
  48. </script>
  49. <style lang="less" scoped>
  50. @import '@/design/vent/color.less';
  51. @font-face {
  52. font-family: 'douyuFont';
  53. src: url(/@/assets/images/files/douyuFont.otf);
  54. }
  55. .warning {
  56. height: 100%;
  57. // display: flex;
  58. // justify-content: space-evenly;
  59. // align-items: center;
  60. // flex-wrap: wrap;
  61. }
  62. .warning-item:first-of-type {
  63. background-image: url(/@/assets/images/vent/home/select-bg.png);
  64. background-size: auto 100%;
  65. background-position: left center;
  66. padding-left: 60px;
  67. .text {
  68. width: 100px;
  69. text-align: left;
  70. }
  71. .risk {
  72. display: none;
  73. }
  74. .extra {
  75. display: none;
  76. }
  77. .num {
  78. text-align: right;
  79. flex-grow: 1;
  80. }
  81. // .warning-level_5 {
  82. // color: red;
  83. // }
  84. // .warning-level_4 {
  85. // color: orange;
  86. // }
  87. // .warning-level_3 {
  88. // color: yellow;
  89. // }
  90. // .warning-level_2 {
  91. // color: green;
  92. // }
  93. }
  94. .warning-item {
  95. display: flex;
  96. align-items: center;
  97. background-image: url(/@/assets/images/company/list-item-9.png);
  98. background-size: auto 80%;
  99. background-repeat: no-repeat;
  100. background-position: right center;
  101. height: 40px;
  102. margin-top: 10px;
  103. .text {
  104. text-align: center;
  105. width: 60px;
  106. }
  107. .extra {
  108. text-align: center;
  109. width: 100px;
  110. }
  111. .num {
  112. text-align: center;
  113. width: 100px;
  114. }
  115. .risk {
  116. text-align: right;
  117. width: 80px;
  118. }
  119. }
  120. .num {
  121. font-size: 20px;
  122. font-family: douyuFont;
  123. color: @vent-gas-primary-text;
  124. }
  125. .risk {
  126. font-size: 20px;
  127. font-family: douyuFont;
  128. color: @vent-gas-primary-text;
  129. }
  130. </style>