Summary.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <Result v-if="unavailble" status="error" title="网络异常" sub-title="无法获取到相关信息" />
  4. <template v-else>
  5. <Row justify="space-around">
  6. <!-- <Col> -->
  7. <LargeBoard :label="SUMMARY_HEADER_CONFIG.label" :value="headerData" :type="SUMMARY_HEADER_CONFIG.type" />
  8. <!-- </Col> -->
  9. </Row>
  10. <CommonTable class="mt-10px" :columns="SUMMARY_COLUMN" :data="tableData" />
  11. </template>
  12. </template>
  13. <script lang="ts" setup>
  14. import { Row, Result } from 'ant-design-vue';
  15. import { SUMMARY_HEADER_CONFIG, SUMMARY_COLUMN, BillboardType } from '../billboard.data';
  16. import LargeBoard from './LargeBoard.vue';
  17. import { onMounted, shallowRef, ref, computed } from 'vue';
  18. import CommonTable from './CommonTable.vue';
  19. import { get } from '../utils';
  20. // import mapComponent from './components/3Dmap/index.vue';
  21. const props = defineProps<{
  22. data: Partial<BillboardType>;
  23. }>();
  24. const unavailble = computed<boolean>(() => {
  25. return props.data.sys_warndata === undefined;
  26. });
  27. const headerData = ref('/');
  28. const tableData = shallowRef<any[]>([]);
  29. function fetchData() {
  30. const info = props.data.sys_warndata;
  31. if (!info) return;
  32. const sysInfo = info.info.sysInfo;
  33. const trans = {
  34. 0: '低风险',
  35. 101: '低风险',
  36. 102: '一般风险',
  37. 103: '较大风险',
  38. 104: '重大风险',
  39. 201: '报警',
  40. };
  41. headerData.value = get(sysInfo, SUMMARY_HEADER_CONFIG.prop, '/');
  42. // 配合 SUMMARY_COLUMN 生成数据
  43. tableData.value = [
  44. {
  45. label: '火灾监测',
  46. value: get(trans, get(sysInfo, ['fireS', 'maxLevel'], 0)),
  47. },
  48. {
  49. label: '设备监测',
  50. value: get(trans, get(sysInfo, ['deviceWarnInfo', 'maxLevel'], 0)),
  51. },
  52. {
  53. label: '瓦斯监测',
  54. value: get(trans, get(sysInfo, ['gasS', 'maxLevel'], 0)),
  55. },
  56. {
  57. label: '粉尘监测',
  58. value: get(trans, get(sysInfo, ['dustS', 'maxLevel'], 0)),
  59. },
  60. {
  61. label: '通风监测',
  62. value: get(trans, get(sysInfo, ['ventS', 'maxLevel'], 0)),
  63. },
  64. ];
  65. }
  66. onMounted(() => {
  67. fetchData();
  68. });
  69. </script>
  70. <style lang="less" scoped>
  71. .value104 {
  72. color: #ff0000;
  73. }
  74. .value103 {
  75. color: #ff8800;
  76. }
  77. .value102 {
  78. color: #ffff00;
  79. }
  80. </style>