refactor: tryGetDeviceTypeVal
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { NdmDeviceResultVO } from '@/apis/models';
|
||||
import { DeviceType, DeviceTypeName, getDeviceTypeVal, type DeviceTypeVal } from '@/enums/device-type';
|
||||
import { DeviceType, DeviceTypeName, tryGetDeviceTypeVal, type DeviceTypeVal } from '@/enums/device-type';
|
||||
import { NButton, NCard, NFlex, NTag } from 'naive-ui';
|
||||
import { computed, toRefs } from 'vue';
|
||||
|
||||
@@ -12,7 +12,11 @@ const props = defineProps<{
|
||||
|
||||
const { device } = toRefs(props);
|
||||
|
||||
const type = computed(() => DeviceTypeName[getDeviceTypeVal(device.value.deviceType)]);
|
||||
const type = computed(() => {
|
||||
const deviceTypeVal = tryGetDeviceTypeVal(device.value.deviceType);
|
||||
if (!deviceTypeVal) return '-';
|
||||
return DeviceTypeName[deviceTypeVal];
|
||||
});
|
||||
const name = computed(() => device.value.name ?? '-');
|
||||
const ipAddr = computed(() => device.value.ipAddress ?? '-');
|
||||
const gbCode = computed(() => Reflect.get(device.value, 'gbCode') as string | undefined);
|
||||
@@ -20,7 +24,8 @@ const status = computed(() => device.value.deviceStatus);
|
||||
|
||||
const canOpenMgmtPage = computed(() => {
|
||||
const mgmtableDeviceTypes: DeviceTypeVal[] = [DeviceType['Camera'], DeviceType['Decoder'], DeviceType['Switch']];
|
||||
return mgmtableDeviceTypes.includes(getDeviceTypeVal(device.value.deviceType));
|
||||
const deviceTypeVal = tryGetDeviceTypeVal(device.value.deviceType);
|
||||
return deviceTypeVal && mgmtableDeviceTypes.includes(deviceTypeVal);
|
||||
});
|
||||
|
||||
const onClickOpenMgmtPage = () => {
|
||||
|
||||
Reference in New Issue
Block a user