refactor: tryGetDeviceTypeVal

This commit is contained in:
yangsy
2025-09-30 15:09:12 +08:00
parent 97bf9855c7
commit d0adb869da
11 changed files with 68 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { NdmDeviceAlarmLogResultVO, NdmDeviceResultVO, NdmNvrResultVO, PageParams } from '@/apis/models';
import { postNdmDeviceAlarmLogPage } from '@/apis/requests';
import { DeviceType, getDeviceTypeVal } from '@/enums/device-type';
import { DeviceType, tryGetDeviceTypeVal } from '@/enums/device-type';
import { useMutation } from '@tanstack/vue-query';
import dayjs from 'dayjs';
import { NButton, NCard, NDataTable, NPopover, NScrollbar, type DataTableColumns, type DataTableRowData, type DatePickerProps, type PaginationProps } from 'naive-ui';
@@ -33,7 +33,9 @@ const tableColumns: DataTableColumns<NdmDeviceAlarmLogResultVO> = [
key: 'faultDescription',
render: (rowData) => {
const isNvrCluster = (ndmDevice: NdmDeviceResultVO) => {
const isNvr = getDeviceTypeVal(ndmDevice.deviceType) === DeviceType.Nvr;
const deviceTypeVal = tryGetDeviceTypeVal(ndmDevice.deviceType);
if (!deviceTypeVal) return false;
const isNvr = deviceTypeVal === DeviceType.Nvr;
if (!isNvr) return false;
const maybeNvrCluster = ndmDevice as NdmNvrResultVO;
return !!maybeNvrCluster.clusterList?.trim() && maybeNvrCluster.clusterList !== maybeNvrCluster.ipAddress;