DustingTable.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <MonitorTable
  3. ref="monitorTable"
  4. :columnsType="`${deviceType}_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="deviceType" />
  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 { ref } from 'vue';
  53. defineProps<{
  54. deviceType: string;
  55. dataSource: any[];
  56. scroll: { y: number };
  57. }>();
  58. defineEmits(['locate']);
  59. const [registerModal, { openModal }] = useModal();
  60. function deviceEdit(e: Event, type: string, record) {
  61. e.stopPropagation();
  62. openModal(true, {
  63. type,
  64. deviceId: record['deviceID'],
  65. });
  66. }
  67. </script>