GasPipeTable.vue 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <MonitorTable
  3. ref="monitorTable"
  4. columnsType="gaspipe_monitor"
  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 { ref } from 'vue';
  55. import { get } from 'lodash-es';
  56. defineProps<{
  57. scroll: { y: number };
  58. }>();
  59. defineEmits(['locate']);
  60. const [registerModal, { openModal }] = useModal();
  61. function deviceEdit(e: Event, type: string, record) {
  62. e.stopPropagation();
  63. openModal(true, {
  64. type,
  65. deviceId: record['deviceID'],
  66. });
  67. }
  68. const dataSource = ref<any[]>([]);
  69. function getDataSource() {
  70. getGasDeviceInfo({ devicetype: 'gasmonitor', pagetype: 'normal' }).then((res) => {
  71. dataSource.value = get(res, 'msgTxt[0].datalist');
  72. });
  73. }
  74. onMounted(() => {
  75. getDataSource();
  76. });
  77. </script>