GasPipeTable.vue 3.4 KB

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