FireStatus.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <CommonTitle class="mb-10px" label="矿井火灾风险性等级" :value="risk" />
  4. <ListItem
  5. v-for="(item, i) in FIRE_STATUS_LIST"
  6. :key="item.icon"
  7. :icon="item.icon"
  8. :label="item.label"
  9. :value="listData[item.prop]"
  10. :type="i % 2 ? 'green' : 'blue'"
  11. class="mt-5px"
  12. />
  13. </template>
  14. <script lang="ts" setup>
  15. import _ from 'lodash-es';
  16. import { onMounted, ref, shallowRef } from 'vue';
  17. import CommonTitle from './CommonTitle.vue';
  18. import ListItem from './ListItem.vue';
  19. import { BillboardType, DEFAULT_TEST_DATA, FIRE_STATUS_LIST, FIRE_STATUS_IGNORE_TRANSLATION_KEYS } from '../billboard.data';
  20. const props = withDefaults(
  21. defineProps<{
  22. data?: BillboardType;
  23. }>(),
  24. {
  25. data: () => DEFAULT_TEST_DATA,
  26. }
  27. );
  28. const risk = ref('低风险');
  29. const listData = shallowRef<any>({});
  30. function fetchData() {
  31. const info = props.data.fireInfo || DEFAULT_TEST_DATA.fireInfo;
  32. const riskTrans = {
  33. 0: '低风险',
  34. 101: '低风险',
  35. 102: '普通风险',
  36. 103: '较高风险',
  37. 104: '高风险',
  38. 201: '低风险',
  39. 1001: '低风险',
  40. };
  41. const warnTrans = {
  42. 0: '低风险',
  43. 101: '低风险',
  44. 102: '一般风险',
  45. 103: '较大风险',
  46. 104: '重大风险',
  47. 201: '报警',
  48. 1001: '网络断开',
  49. };
  50. risk.value = riskTrans[info.fireWarnLevel];
  51. _.forEach(info, (val, key) => {
  52. if (FIRE_STATUS_IGNORE_TRANSLATION_KEYS.includes(key)) return;
  53. info[key] = warnTrans[val];
  54. });
  55. listData.value = info;
  56. }
  57. onMounted(() => {
  58. fetchData();
  59. });
  60. </script>
  61. <style lang="less" scoped></style>