From 4ab33d20212470dbdb377fb0d5d63e164cebbb49 Mon Sep 17 00:00:00 2001 From: yangsy Date: Wed, 19 Nov 2025 16:31:54 +0800 Subject: [PATCH] feat(device-header-card): probe button --- src/apis/requests/device/index.ts | 2 + src/apis/requests/device/ndm-probe.ts | 121 ++++++++++++++++++ .../requests/device/other/ndm-security-box.ts | 12 +- src/apis/requests/device/other/ndm-switch.ts | 12 +- src/apis/requests/device/storage/ndm-nvr.ts | 18 ++- src/apis/requests/device/video/ndm-camera.ts | 18 ++- src/apis/requests/device/video/ndm-decoder.ts | 18 ++- .../requests/device/video/ndm-keyboard.ts | 12 +- .../requests/device/video/ndm-media-server.ts | 18 ++- .../requests/device/video/ndm-video-server.ts | 18 ++- .../device-page/device-card/camera-card.vue | 2 +- .../current-diag-card/device-header-card.vue | 65 +++++++++- .../device-page/device-card/decoder-card.vue | 2 +- .../device-page/device-card/keyboard-card.vue | 2 +- .../device-page/device-card/nvr-card.vue | 2 +- .../device-card/security-box-card.vue | 2 +- .../device-page/device-card/server-card.vue | 2 +- .../device-page/device-card/switch-card.vue | 2 +- 18 files changed, 296 insertions(+), 32 deletions(-) create mode 100644 src/apis/requests/device/ndm-probe.ts diff --git a/src/apis/requests/device/index.ts b/src/apis/requests/device/index.ts index b23536e..a6121ac 100644 --- a/src/apis/requests/device/index.ts +++ b/src/apis/requests/device/index.ts @@ -16,3 +16,5 @@ export * from './video/ndm-decoder'; export * from './video/ndm-keyboard'; export * from './video/ndm-media-server'; export * from './video/ndm-video-server'; + +export * from './ndm-probe'; diff --git a/src/apis/requests/device/ndm-probe.ts b/src/apis/requests/device/ndm-probe.ts new file mode 100644 index 0000000..dfd32f5 --- /dev/null +++ b/src/apis/requests/device/ndm-probe.ts @@ -0,0 +1,121 @@ +import { ndmClient } from '@/apis/client'; +import type { NdmDeviceResultVO } from '@/apis/models'; +import { getNdmDecoderDetail, getNdmKeyboardDetail, getNdmMediaServerDetail, getNdmNvrDetail, getNdmSecurityBoxDetail, getNdmSwitchDetail, getNdmVideoServerDetail } from '@/apis/requests'; +import { DeviceType, tryGetDeviceTypeVal } from '@/enums/device-type'; + +export const probeNdmDecoderByIds = async (stationCode: string, ids: string[]) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.post(`${prefix}/api/ndm/ndmDecoder/probeByIds`, ids); + const [err] = resp; + if (err) { + throw err; + } +}; + +export const probeNdmNvrByIds = async (stationCode: string, ids: string[]) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.post(`${prefix}/api/ndm/ndmNvr/probeByIds`, ids); + const [err] = resp; + if (err) { + throw err; + } +}; + +export const probeNdmSecurityBoxByIds = async (stationCode: string, ids: string[]) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.post(`${prefix}/api/ndm/ndmSecurityBox/probeByIds`, ids); + const [err] = resp; + if (err) { + throw err; + } +}; + +export const probeNdmMediaServerByIds = async (stationCode: string, ids: string[]) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.post(`${prefix}/api/ndm/ndmMediaServer/probeByIds`, ids); + const [err] = resp; + if (err) { + throw err; + } +}; + +export const probeNdmSwitchByIds = async (stationCode: string, ids: string[]) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.post(`${prefix}/api/ndm/ndmSwitch/probeByIds`, ids); + const [err] = resp; + if (err) { + throw err; + } +}; + +export const probeNdmVideoServerByIds = async (stationCode: string, ids: string[]) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.post(`${prefix}/api/ndm/ndmVideoServer/probeByIds`, ids); + const [err] = resp; + if (err) { + throw err; + } +}; + +export const probeDeviceApi = async (stationCode: string, device: NdmDeviceResultVO) => { + const deviceType = tryGetDeviceTypeVal(device.deviceType); + const deviceDbId = device.id; + if (!deviceType || !deviceDbId) { + throw new Error('未知的设备'); + } + if (deviceType === DeviceType.Decoder) { + await probeNdmDecoderByIds(stationCode, [deviceDbId]); + return; + } + if (deviceType === DeviceType.Nvr) { + await probeNdmNvrByIds(stationCode, [deviceDbId]); + return; + } + if (deviceType === DeviceType.SecurityBox) { + await probeNdmSecurityBoxByIds(stationCode, [deviceDbId]); + return; + } + if (deviceType === DeviceType.MediaServer) { + await probeNdmMediaServerByIds(stationCode, [deviceDbId]); + return; + } + if (deviceType === DeviceType.Switch) { + await probeNdmSwitchByIds(stationCode, [deviceDbId]); + return; + } + if (deviceType === DeviceType.VideoServer) { + await probeNdmVideoServerByIds(stationCode, [deviceDbId]); + return; + } +}; + +export const getDeviceDetailApi = async (stationCode: string, id?: string, deviceType?: string): Promise => { + if (!id || !deviceType) { + throw new Error('未知的设备'); + } + if (deviceType === DeviceType.Camera) { + return await getNdmVideoServerDetail(stationCode, id); + } + if (deviceType === DeviceType.Decoder) { + return await getNdmDecoderDetail(stationCode, id); + } + if (deviceType === DeviceType.Keyboard) { + return await getNdmKeyboardDetail(stationCode, id); + } + if (deviceType === DeviceType.MediaServer) { + return await getNdmMediaServerDetail(stationCode, id); + } + if (deviceType === DeviceType.Nvr) { + return await getNdmNvrDetail(stationCode, id); + } + if (deviceType === DeviceType.SecurityBox) { + return await getNdmSecurityBoxDetail(stationCode, id); + } + if (deviceType === DeviceType.Switch) { + return await getNdmSwitchDetail(stationCode, id); + } + if (deviceType === DeviceType.VideoServer) { + return await getNdmVideoServerDetail(stationCode, id); + } + return undefined; +}; diff --git a/src/apis/requests/device/other/ndm-security-box.ts b/src/apis/requests/device/other/ndm-security-box.ts index b7198df..e3ab8b2 100644 --- a/src/apis/requests/device/other/ndm-security-box.ts +++ b/src/apis/requests/device/other/ndm-security-box.ts @@ -4,6 +4,16 @@ import type { PageParams, NdmSecurityBoxPageQuery, PageResult, NdmSecurityBoxRes export const postNdmSecurityBoxPage = async (stationCode: string, pageQuery: PageParams, signal?: AbortSignal) => { const prefix = stationCode ? `/${stationCode}` : ''; const resp = await ndmClient.post>(`${prefix}/api/ndm/ndmSecurityBox/page`, pageQuery, { signal }); + const [err, ndmSecurityBox] = resp; + if (err || !ndmSecurityBox) { + throw err; + } + return ndmSecurityBox; +}; + +export const getNdmSecurityBoxDetail = async (stationCode: string, id: string) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.get(`${prefix}/api/ndm/ndmSecurityBox/detail`, { params: { id } }); const [err, ndmSecurityBoxData] = resp; if (err || !ndmSecurityBoxData) { throw err; @@ -18,7 +28,7 @@ export const putNdmSecurityBox = async (stationCode: string, updateVO: NdmSecuri if (err || !ndmSecurityBox) { throw err; } - return ndmSecurityBox; + return await getNdmSecurityBoxDetail(stationCode, ndmSecurityBox.id ?? ''); }; export const turnStatus = async (stationCode: string, ipAddress: string, circuitIndex: number, status: number) => { diff --git a/src/apis/requests/device/other/ndm-switch.ts b/src/apis/requests/device/other/ndm-switch.ts index e6fb689..7d3826e 100644 --- a/src/apis/requests/device/other/ndm-switch.ts +++ b/src/apis/requests/device/other/ndm-switch.ts @@ -4,6 +4,16 @@ import type { PageParams, NdmSwitchPageQuery, PageResult, NdmSwitchResultVO, Ndm export const postNdmSwitchPage = async (stationCode: string, pageQuery: PageParams, signal?: AbortSignal) => { const prefix = stationCode ? `/${stationCode}` : ''; const resp = await ndmClient.post>(`${prefix}/api/ndm/ndmSwitch/page`, pageQuery, { signal }); + const [err, ndmSwitch] = resp; + if (err || !ndmSwitch) { + throw err; + } + return ndmSwitch; +}; + +export const getNdmSwitchDetail = async (stationCode: string, id: string) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.get(`${prefix}/api/ndm/ndmSwitch/detail`, { params: { id } }); const [err, ndmSwitchData] = resp; if (err || !ndmSwitchData) { throw err; @@ -18,5 +28,5 @@ export const putNdmSwitch = async (stationCode: string, updateVO: NdmSwitchUpdat if (err || !ndmSwitch) { throw err; } - return ndmSwitch; + return await getNdmSwitchDetail(stationCode, ndmSwitch.id ?? ''); }; diff --git a/src/apis/requests/device/storage/ndm-nvr.ts b/src/apis/requests/device/storage/ndm-nvr.ts index c277622..311d5ed 100644 --- a/src/apis/requests/device/storage/ndm-nvr.ts +++ b/src/apis/requests/device/storage/ndm-nvr.ts @@ -5,11 +5,21 @@ import dayjs from 'dayjs'; export const postNdmNvrPage = async (stationCode: string, pageQuery: PageParams, signal?: AbortSignal) => { const prefix = stationCode ? `/${stationCode}` : ''; const resp = await ndmClient.post>(`${prefix}/api/ndm/ndmNvr/page`, pageQuery, { signal }); - const [err, ndmNvrData] = resp; - if (err || !ndmNvrData) { + const [err, ndmNvr] = resp; + if (err || !ndmNvr) { throw err; } - return ndmNvrData; + return ndmNvr; +}; + +export const getNdmNvrDetail = async (stationCode: string, id: string) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.get(`${prefix}/api/ndm/ndmNvr/detail`, { params: { id } }); + const [err, ndmNvr] = resp; + if (err || !ndmNvr) { + throw err; + } + return ndmNvr; }; export const putNdmNvr = async (stationCode: string, updateVO: NdmNvrUpdateVO) => { @@ -19,7 +29,7 @@ export const putNdmNvr = async (stationCode: string, updateVO: NdmNvrUpdateVO) = if (err || !ndmNvr) { throw err; } - return ndmNvr; + return await getNdmNvrDetail(stationCode, ndmNvr.id ?? ''); }; export const getChannelList = async (stationCode: string, ndmNvr: NdmNvrResultVO) => { diff --git a/src/apis/requests/device/video/ndm-camera.ts b/src/apis/requests/device/video/ndm-camera.ts index 46d3e3f..528ef07 100644 --- a/src/apis/requests/device/video/ndm-camera.ts +++ b/src/apis/requests/device/video/ndm-camera.ts @@ -4,11 +4,21 @@ import type { PageParams, NdmCameraPageQuery, PageResult, NdmCameraResultVO, Ndm export const postNdmCameraPage = async (stationCode: string, pageQuery: PageParams, signal?: AbortSignal) => { const prefix = stationCode ? `/${stationCode}` : ''; const resp = await ndmClient.post>(`${prefix}/api/ndm/ndmCamera/page`, pageQuery, { signal }); - const [err, ndmCameraData] = resp; - if (err || !ndmCameraData) { + const [err, ndmCamera] = resp; + if (err || !ndmCamera) { throw err; } - return ndmCameraData; + return ndmCamera; +}; + +export const getNdmCameraDetail = async (stationCode: string, id: string) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.get(`${prefix}/api/ndm/ndmCamera/detail`, { params: { id } }); + const [err, ndmCamera] = resp; + if (err || !ndmCamera) { + throw err; + } + return ndmCamera; }; export const putNdmCamera = async (stationCode: string, updateVO: NdmCameraUpdateVO) => { @@ -18,5 +28,5 @@ export const putNdmCamera = async (stationCode: string, updateVO: NdmCameraUpdat if (err || !ndmCamera) { throw err; } - return ndmCamera; + return await getNdmCameraDetail(stationCode, ndmCamera.id ?? ''); }; diff --git a/src/apis/requests/device/video/ndm-decoder.ts b/src/apis/requests/device/video/ndm-decoder.ts index 1f81355..8492bda 100644 --- a/src/apis/requests/device/video/ndm-decoder.ts +++ b/src/apis/requests/device/video/ndm-decoder.ts @@ -4,11 +4,21 @@ import type { PageParams, NdmDecoderPageQuery, PageResult, NdmDecoderResultVO, N export const postNdmDecoderPage = async (stationCode: string, pageQuery: PageParams, signal?: AbortSignal) => { const prefix = stationCode ? `/${stationCode}` : ''; const resp = await ndmClient.post>(`${prefix}/api/ndm/ndmDecoder/page`, pageQuery, { signal }); - const [err, ndmDecoderData] = resp; - if (err || !ndmDecoderData) { + const [err, ndmDecoder] = resp; + if (err || !ndmDecoder) { throw err; } - return ndmDecoderData; + return ndmDecoder; +}; + +export const getNdmDecoderDetail = async (stationCode: string, id: string) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.get(`${prefix}/api/ndm/ndmDecoder/detail`, { params: { id } }); + const [err, ndmDecoder] = resp; + if (err || !ndmDecoder) { + throw err; + } + return ndmDecoder; }; export const putNdmDecoder = async (stationCode: string, updateVO: NdmDecoderUpdateVO) => { @@ -18,5 +28,5 @@ export const putNdmDecoder = async (stationCode: string, updateVO: NdmDecoderUpd if (err || !ndmDecoder) { throw err; } - return ndmDecoder; + return await getNdmDecoderDetail(stationCode, ndmDecoder.id ?? ''); }; diff --git a/src/apis/requests/device/video/ndm-keyboard.ts b/src/apis/requests/device/video/ndm-keyboard.ts index 9aea732..0f6eeb1 100644 --- a/src/apis/requests/device/video/ndm-keyboard.ts +++ b/src/apis/requests/device/video/ndm-keyboard.ts @@ -11,6 +11,16 @@ export const postNdmKeyboardPage = async (stationCode: string, pageQuery: PagePa return ndmKeyboardData; }; +export const getNdmKeyboardDetail = async (stationCode: string, id: string) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.get(`${prefix}/api/ndm/ndmKeyboard/detail`, { params: { id } }); + const [err, ndmKeyboardData] = resp; + if (err || !ndmKeyboardData) { + throw err; + } + return ndmKeyboardData; +}; + export const putNdmKeyboard = async (stationCode: string, updateVO: NdmKeyboardUpdateVO) => { const prefix = stationCode ? `/${stationCode}` : ''; const resp = await ndmClient.put(`${prefix}/api/ndm/ndmKeyboard`, updateVO); @@ -18,5 +28,5 @@ export const putNdmKeyboard = async (stationCode: string, updateVO: NdmKeyboardU if (err || !ndmKeyboard) { throw err; } - return ndmKeyboard; + return await getNdmKeyboardDetail(stationCode, ndmKeyboard.id ?? ''); }; diff --git a/src/apis/requests/device/video/ndm-media-server.ts b/src/apis/requests/device/video/ndm-media-server.ts index ae7b281..d05c7ff 100644 --- a/src/apis/requests/device/video/ndm-media-server.ts +++ b/src/apis/requests/device/video/ndm-media-server.ts @@ -4,11 +4,21 @@ import type { PageParams, NdmMediaServerPageQuery, PageResult, NdmMediaServerRes export const postNdmMediaServerPage = async (stationCode: string, pageQuery: PageParams, signal?: AbortSignal) => { const prefix = stationCode ? `/${stationCode}` : ''; const resp = await ndmClient.post>(`${prefix}/api/ndm/ndmMediaServer/page`, pageQuery, { signal }); - const [err, ndmMediaServerData] = resp; - if (err || !ndmMediaServerData) { + const [err, ndmMediaServer] = resp; + if (err || !ndmMediaServer) { throw err; } - return ndmMediaServerData; + return ndmMediaServer; +}; + +export const getNdmMediaServerDetail = async (stationCode: string, id: string) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.get(`${prefix}/api/ndm/ndmMediaServer/detail`, { params: { id } }); + const [err, ndmMediaServer] = resp; + if (err || !ndmMediaServer) { + throw err; + } + return ndmMediaServer; }; export const putNdmMediaServer = async (stationCode: string, updateVO: NdmMediaServerUpdateVO) => { @@ -18,5 +28,5 @@ export const putNdmMediaServer = async (stationCode: string, updateVO: NdmMediaS if (err || !ndmMediaServer) { throw err; } - return ndmMediaServer; + return await getNdmMediaServerDetail(stationCode, ndmMediaServer.id ?? ''); }; diff --git a/src/apis/requests/device/video/ndm-video-server.ts b/src/apis/requests/device/video/ndm-video-server.ts index eec6ee9..d5af841 100644 --- a/src/apis/requests/device/video/ndm-video-server.ts +++ b/src/apis/requests/device/video/ndm-video-server.ts @@ -4,11 +4,21 @@ import type { PageParams, NdmVideoServerPageQuery, PageResult, NdmVideoServerRes export const postNdmVideoServerPage = async (stationCode: string, pageQuery: PageParams, signal?: AbortSignal) => { const prefix = stationCode ? `/${stationCode}` : ''; const resp = await ndmClient.post>(`${prefix}/api/ndm/ndmVideoServer/page`, pageQuery, { signal }); - const [err, ndmVideoServerData] = resp; - if (err || !ndmVideoServerData) { + const [err, ndmVideoServer] = resp; + if (err || !ndmVideoServer) { throw err; } - return ndmVideoServerData; + return ndmVideoServer; +}; + +export const getNdmVideoServerDetail = async (stationCode: string, id: string) => { + const prefix = stationCode ? `/${stationCode}` : ''; + const resp = await ndmClient.get(`${prefix}/api/ndm/ndmVideoServer/detail`, { params: { id } }); + const [err, ndmVideoServer] = resp; + if (err || !ndmVideoServer) { + throw err; + } + return ndmVideoServer; }; export const putNdmVideoServer = async (stationCode: string, updateVO: NdmVideoServerUpdateVO) => { @@ -18,5 +28,5 @@ export const putNdmVideoServer = async (stationCode: string, updateVO: NdmVideoS if (err || !ndmVideoServer) { throw err; } - return ndmVideoServer; + return await getNdmVideoServerDetail(stationCode, ndmVideoServer.id ?? ''); }; diff --git a/src/components/device-page/device-card/camera-card.vue b/src/components/device-page/device-card/camera-card.vue index ba77050..b427120 100644 --- a/src/components/device-page/device-card/camera-card.vue +++ b/src/components/device-page/device-card/camera-card.vue @@ -68,7 +68,7 @@ const selectedTab = ref('设备状态'); - + diff --git a/src/components/device-page/device-card/current-diag-card/device-header-card.vue b/src/components/device-page/device-card/current-diag-card/device-header-card.vue index 4856433..3dabe92 100644 --- a/src/components/device-page/device-card/current-diag-card/device-header-card.vue +++ b/src/components/device-page/device-card/current-diag-card/device-header-card.vue @@ -1,16 +1,21 @@ + + diff --git a/src/components/device-page/device-card/decoder-card.vue b/src/components/device-page/device-card/decoder-card.vue index 742e771..367af79 100644 --- a/src/components/device-page/device-card/decoder-card.vue +++ b/src/components/device-page/device-card/decoder-card.vue @@ -48,7 +48,7 @@ const selectedTab = ref('设备状态'); - + diff --git a/src/components/device-page/device-card/keyboard-card.vue b/src/components/device-page/device-card/keyboard-card.vue index 2c7a7e8..b4013df 100644 --- a/src/components/device-page/device-card/keyboard-card.vue +++ b/src/components/device-page/device-card/keyboard-card.vue @@ -24,7 +24,7 @@ const selectedTab = ref('设备状态'); - + diff --git a/src/components/device-page/device-card/nvr-card.vue b/src/components/device-page/device-card/nvr-card.vue index 8673757..d25cd2e 100644 --- a/src/components/device-page/device-card/nvr-card.vue +++ b/src/components/device-page/device-card/nvr-card.vue @@ -58,7 +58,7 @@ const selectedTab = ref('设备状态'); - + diff --git a/src/components/device-page/device-card/security-box-card.vue b/src/components/device-page/device-card/security-box-card.vue index 5e3fe27..45a5c70 100644 --- a/src/components/device-page/device-card/security-box-card.vue +++ b/src/components/device-page/device-card/security-box-card.vue @@ -57,7 +57,7 @@ const selectedTab = ref('设备状态'); - + diff --git a/src/components/device-page/device-card/server-card.vue b/src/components/device-page/device-card/server-card.vue index a66ffdd..d95abbd 100644 --- a/src/components/device-page/device-card/server-card.vue +++ b/src/components/device-page/device-card/server-card.vue @@ -39,7 +39,7 @@ const selectedTab = ref('设备状态'); - + diff --git a/src/components/device-page/device-card/switch-card.vue b/src/components/device-page/device-card/switch-card.vue index 54e8e21..47e6e83 100644 --- a/src/components/device-page/device-card/switch-card.vue +++ b/src/components/device-page/device-card/switch-card.vue @@ -40,7 +40,7 @@ const selectedTab = ref('设备状态'); - +