GasPipeTable.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <MonitorTable
  3. ref="monitorTable"
  4. :columns="gasPipeColumns"
  5. :dataSource="dataSource"
  6. design-scope="device_monitor"
  7. :isShowActionColumn="true"
  8. :isShowSelect="false"
  9. title="设备监测"
  10. :scroll="{ y: scroll.y - 60 }"
  11. >
  12. <template #action="{ record }">
  13. <TableAction
  14. :actions="[
  15. {
  16. ifShow: () => showDetailButton,
  17. label: '详情',
  18. onClick: () => $emit('detail', record),
  19. },
  20. {
  21. label: '定位',
  22. onClick: () => $emit('locate', record),
  23. },
  24. ]"
  25. />
  26. </template>
  27. <template #filterCell="{ column, record }">
  28. <a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == 0 ? 'green' : record.warnFlag == 1 ? '#FF5812' : 'gray'">
  29. {{ record.warnFlag == 0 ? '正常' : record.warnFlag == 1 ? '报警' : record.warnFlag == 2 ? '断开' : '未监测' }}
  30. </a-tag>
  31. <a-tag v-if="column.dataIndex === 'isBlock'" :color="record.isBlock == 0 ? 'green' : record.isBlock == 1 ? '#FF5812' : 'gray'">
  32. {{ record.isBlock == 0 ? '否' : record.isBlock == 1 ? '是' : '未监测' }}</a-tag
  33. >
  34. <template v-else-if="column.dataIndex === 'warnLevel'">
  35. <a-tag v-if="record.warnLevel == '101'" color="green">低风险</a-tag>
  36. <a-tag v-else-if="record.warnLevel == '102'" color="#FF5812">一般风险</a-tag>
  37. <a-tag v-else-if="record.warnLevel == '103'" color="#FF5812">较大风险</a-tag>
  38. <a-tag v-else-if="record.warnLevel == '104'" color="#FF5812">重大风险</a-tag>
  39. <a-tag v-else-if="record.warnLevel == '201'" color="#FF0000">报警</a-tag>
  40. <a-tag v-else-if="record.warnLevel == '10000'" color="#FF5812">数据超限</a-tag>
  41. <a-tag v-else-if="record.warnLevel == '1001'" color="default">网络中断</a-tag>
  42. <a-tag v-else color="green">正常</a-tag>
  43. </template>
  44. <a-tag v-if="column.dataIndex === 'netStatus'" :color="record.netStatus == '0' ? '#f00' : 'green'">
  45. {{ record.netStatus == '0' ? '断开' : '连接' }}
  46. </a-tag>
  47. <span v-if="column.dataIndex === 'isLeakage'" :color="record.isLeakage == '0' ? 'green' : '#f00'">
  48. {{ record.isLeakage == '0' ? '未泄露' : `${record.ld_x}m处泄露` }}
  49. </span>
  50. </template>
  51. </MonitorTable>
  52. <!-- <DeviceBaseInfo @register="registerModal" device-type="gaspipe" /> -->
  53. </template>
  54. <script lang="ts" setup>
  55. import MonitorTable from './MonitorTable.vue';
  56. // import DeviceBaseInfo from './components/DeviceBaseInfo.vue';
  57. import { TableAction } from '/@/components/Table';
  58. // import { useModal } from '/@/components/Modal';
  59. import { onMounted } from 'vue';
  60. import { getGasDeviceInfo } from './comment.api';
  61. import { gasPipeColumns } from './comment.data';
  62. import { ref } from 'vue';
  63. import { forEach, get } from 'lodash-es';
  64. withDefaults(
  65. defineProps<{
  66. scroll: { y: number };
  67. showDetailButton?: boolean;
  68. }>(),
  69. {
  70. showDetailButton: false,
  71. }
  72. );
  73. defineEmits(['locate', 'detail']);
  74. // const [registerModal, { openModal }] = useModal();
  75. // function deviceEdit(e: Event, type: string, record) {
  76. // e.stopPropagation();
  77. // openModal(true, {
  78. // type,
  79. // deviceId: record['deviceID'],
  80. // });
  81. // }
  82. const dataSource = ref<any[]>([]);
  83. function getDataSource() {
  84. getGasDeviceInfo({ devicetype: 'gasmonitor', pagetype: 'normal' }).then((res) => {
  85. dataSource.value = get(res, 'msgTxt[0].datalist', []).map((e) => {
  86. const start = {
  87. ...e.start.readData,
  88. ...e.start,
  89. readData: null,
  90. };
  91. const end = {
  92. ...e.end.readData,
  93. ...e.end,
  94. readData: null,
  95. };
  96. const gasGlFaultDia = JSON.parse(e.gasGlFaultDia);
  97. forEach(end, (val, key) => {
  98. end[`${key}_end`] = val;
  99. delete end[key];
  100. });
  101. return {
  102. ...start,
  103. ...end,
  104. ...gasGlFaultDia,
  105. };
  106. });
  107. });
  108. }
  109. onMounted(() => {
  110. getDataSource();
  111. });
  112. </script>