DeviceWarning.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <ModuleBasic :title="config.moduleName" :version="config.showStyle?.version" :size="config.showStyle?.size" :position="config.showStyle?.position">
  4. <CostumeHeader>
  5. <template #select>
  6. <!-- 填写空的div以覆盖默认的选择框 -->
  7. <div></div>
  8. </template>
  9. <div class="w-200px flex flex-items-center">
  10. <RightCircleOutlined class="w-30px" />
  11. <div v-for="(label, prop) in config.moduleData.header" :key="prop" class="flex-grow-1">
  12. {{ label }}
  13. <span> {{ get(scene, prop) }}条 </span>
  14. </div>
  15. </div>
  16. </CostumeHeader>
  17. <div class="timeline">
  18. <div v-for="(item, i) in warns" :key="`svvhccdw-${i}`" class="flex items-center timeline-item">
  19. <div class="timeline-item__icon" :class="`timeline-item__icon_${item.color}`"></div>
  20. <div class="timeline-item__dot"></div>
  21. <div class="timeline-item__label">{{ item.label }}</div>
  22. <div :class="`timeline-item__value_${item.color}`">{{ item.count }}</div>
  23. </div>
  24. <div class="timeline-component"></div>
  25. </div>
  26. </ModuleBasic>
  27. </template>
  28. <script lang="ts" setup>
  29. import { computed, onMounted, ref } from 'vue';
  30. // import { list as cfgList } from '@/views/vent/deviceManager/configurationTable/configuration.api';
  31. // import { list } from '@/views/vent/deviceManager/deviceTable/device.api';
  32. import ModuleBasic from './moduleBasic.vue';
  33. import CostumeHeader from './CostumeHeader.vue';
  34. import { RightCircleOutlined } from '@ant-design/icons-vue';
  35. import { useInitScene } from '../hooks/useInit';
  36. import { get } from '../../billboard/utils';
  37. import _ from 'lodash-es';
  38. // import MiniBoard from './MiniBoard.vue';
  39. // import mapComponent from './components/3Dmap/index.vue';
  40. // 设备类别,是个枚举 TODO: 将手动换为自动获取类别
  41. const devicekind = 'warn';
  42. // const configs = ref<{ prop: string; label: string }[]>([]);
  43. // function fetchConfig() {
  44. // cfgList({
  45. // deviceType: 'devicekind',
  46. // }).then(({ records }) => {
  47. // const moduleData = JSON.parse(records[0]?.moduleData);
  48. // configs.value = Object.keys(moduleData).map((k) => {
  49. // return {
  50. // prop: k,
  51. // label: moduleData[k],
  52. // };
  53. // });
  54. // });
  55. // }
  56. const config = ref({
  57. moduleName: '设备告警',
  58. moduleData: {
  59. header: {
  60. 'netstatus.val': '网络断开',
  61. },
  62. main: {
  63. 'red.val': '严重',
  64. 'orange.val': '非常严重',
  65. 'yellow.val': '较严重',
  66. 'blue.val': '一般严重',
  67. 'alarm.val': '报警',
  68. },
  69. },
  70. showStyle: {
  71. size: 'width:450px;height:280px;',
  72. position: 'right:0px;top:640px;',
  73. version: 'enhanced',
  74. },
  75. });
  76. // const { config: remoteConfig, fetchConfig } = useInitConfig(devicekind);
  77. const { scene, fetchScene } = useInitScene(devicekind);
  78. const warns = computed(() => {
  79. const colors = ['red', 'orange', 'yellow', 'green', 'blue'];
  80. let i = -1;
  81. return _.map(config.value.moduleData.main || [], (label, prop) => {
  82. i += 1;
  83. return {
  84. label,
  85. count: get(scene, prop),
  86. color: colors[i],
  87. };
  88. });
  89. });
  90. onMounted(() => {
  91. fetchScene();
  92. // fetchConfig();
  93. });
  94. </script>
  95. <style lang="less" scoped>
  96. @import '@/design/vent/color.less';
  97. .timeline-item {
  98. height: 20%;
  99. }
  100. .timeline-item__icon_red {
  101. background-image: url('@/assets/images/home-container/configurable/warn_icon_5.png');
  102. }
  103. .timeline-item__icon_orange {
  104. background-image: url('@/assets/images/home-container/configurable/warn_icon_4.png');
  105. }
  106. .timeline-item__icon_yellow {
  107. background-image: url('@/assets/images/home-container/configurable/warn_icon_3.png');
  108. }
  109. .timeline-item__icon_green {
  110. background-image: url('@/assets/images/home-container/configurable/warn_icon_2.png');
  111. }
  112. .timeline-item__icon_blue {
  113. background-image: url('@/assets/images/home-container/configurable/warn_icon_1.png');
  114. }
  115. .timeline-item__icon {
  116. width: 33px;
  117. height: 35px;
  118. margin-left: 50px;
  119. background-repeat: no-repeat;
  120. background-position: center center;
  121. }
  122. .timeline-item__dot {
  123. width: 10px;
  124. height: 10px;
  125. margin-left: 70px;
  126. background-color: @vent-gas-primary-bg;
  127. border-radius: 5px;
  128. position: relative;
  129. }
  130. .timeline-item__dot::before {
  131. content: '';
  132. position: absolute;
  133. top: -3px;
  134. left: -3px;
  135. width: 16px;
  136. height: 16px;
  137. border-radius: 8px;
  138. border: 1px solid @vent-gas-tab-border;
  139. }
  140. .timeline-item__label {
  141. width: 100px;
  142. margin-left: 70px;
  143. }
  144. .timeline-item__value_red {
  145. color: red;
  146. }
  147. .timeline-item__value_orange {
  148. color: orange;
  149. }
  150. .timeline-item__value_yellow {
  151. color: yellow;
  152. }
  153. .timeline-item__value_green {
  154. color: yellowgreen;
  155. }
  156. .timeline-item__value_blue {
  157. color: lightblue;
  158. }
  159. .timeline {
  160. height: 220px;
  161. padding: 5px;
  162. position: relative;
  163. }
  164. .timeline-component {
  165. position: absolute;
  166. width: 2px;
  167. height: 180px;
  168. top: 20px;
  169. left: 162px;
  170. background-image: @vent-configurable-home-timeline;
  171. }
  172. </style>