Summary.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <Row justify="space-around">
  4. <Col v-for="(item, i) in SUMMARY_HEADER_CONFIG" :key="`svvhbcgs${i}`" :span="10">
  5. <LargeBoard :label="item.label" :value="headerData[item.prop]" :type="item.type" />
  6. </Col>
  7. </Row>
  8. <CommonTable class="mt-10px" :columns="SUMMARY_COLUMN" :data="tableData" />
  9. </template>
  10. <script lang="ts" setup>
  11. import { Row, Col } from 'ant-design-vue';
  12. import { SUMMARY_HEADER_CONFIG, SUMMARY_COLUMN, DEFAULT_TEST_DATA, BillboardType } from '../billboard.data';
  13. import LargeBoard from './LargeBoard.vue';
  14. import { watch, shallowRef } from 'vue';
  15. import CommonTable from './CommonTable.vue';
  16. // import mapComponent from './components/3Dmap/index.vue';
  17. const props = withDefaults(
  18. defineProps<{
  19. data?: BillboardType;
  20. }>(),
  21. {
  22. data: () => DEFAULT_TEST_DATA,
  23. }
  24. );
  25. const headerData = shallowRef({});
  26. const tableData = shallowRef<BillboardType['gasInfo']['gasTypeList']>([]);
  27. function fetchData() {
  28. const info = props.data.gasInfo || DEFAULT_TEST_DATA.gasInfo;
  29. const trans = {
  30. 0: '低风险',
  31. 101: '低风险',
  32. 102: '一般风险',
  33. 103: '较大风险',
  34. 104: '重大风险',
  35. 201: '报警',
  36. 1001: '网络断开',
  37. };
  38. headerData.value = {
  39. gasWarnLevel: trans[info.gasWarnLevel],
  40. gasJudgeLevel: '低风险',
  41. };
  42. tableData.value = info.gasTypeList.map((e) => {
  43. return {
  44. ...e,
  45. warnLevelStr: trans[e.warnLevel],
  46. };
  47. });
  48. }
  49. watch(
  50. () => props.data,
  51. () => {
  52. console.log('debug');
  53. fetchData();
  54. },
  55. { immediate: true }
  56. );
  57. </script>
  58. <style lang="less" scoped></style>