GasPipeTable.vue 3.6 KB

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