feat: 支持查看摄像机告警画面截图

This commit is contained in:
yangsy
2025-12-30 10:43:05 +08:00
parent 118cc8be0b
commit 02e29eb4f3
6 changed files with 93 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
export * from './ndm-call-log';
export * from './ndm-device-alarm-log';
export * from './ndm-device-alarm-snap-log';
export * from './ndm-icmp-log';
export * from './ndm-record-check';
export * from './ndm-snmp-log';

View File

@@ -0,0 +1,16 @@
import type { BaseModel, ReduceForPageQuery, ReduceForSaveVO, ReduceForUpdateVO } from '@/apis';
import type { Nullable } from '@/types';
export interface NdmDeviceAlarmSnapLog extends BaseModel {
absoluteFilePath: string;
path: string;
url: string;
}
export type NdmDeviceAlarmSnapLogResultVO = Nullable<NdmDeviceAlarmSnapLog>;
export type NdmDeviceAlarmSnapLogSaveVO = Partial<Omit<NdmDeviceAlarmSnapLog, ReduceForSaveVO>>;
export type NdmDeviceAlarmSnapLogUpdateVO = Partial<Omit<NdmDeviceAlarmSnapLog, ReduceForUpdateVO>>;
export type NdmDeviceAlarmSnapLogPageQuery = Partial<Omit<NdmDeviceAlarmSnapLog, ReduceForPageQuery>>;

View File

@@ -1,5 +1,6 @@
export * from './ndm-call-log';
export * from './ndm-device-alarm-log';
export * from './ndm-device-alarm-snap-log';
export * from './ndm-icmp-log';
export * from './ndm-snmp-log';
export * from './ndm-record-check';

View File

@@ -0,0 +1,62 @@
import {
ndmClient,
userClient,
type NdmDeviceAlarmSnapLogPageQuery,
type NdmDeviceAlarmSnapLogResultVO,
type NdmDeviceAlarmSnapLogSaveVO,
type NdmDeviceAlarmSnapLogUpdateVO,
type PageParams,
type PageResult,
type Station,
} from '@/apis';
import { unwrapResponse } from '@/utils';
export const pageDeviceAlarmSnapLogApi = async (pageQuery: PageParams<NdmDeviceAlarmSnapLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog/page`;
const resp = await client.post<PageResult<NdmDeviceAlarmSnapLogResultVO>>(endpoint, pageQuery, { signal });
const data = unwrapResponse(resp);
return data;
};
export const detailDeviceAlarmSnapLogApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog/detail`;
const resp = await client.get<NdmDeviceAlarmSnapLogResultVO>(endpoint, { params: { id }, signal });
const data = unwrapResponse(resp);
return data;
};
export const saveDeviceAlarmSnapLogApi = async (saveVO: NdmDeviceAlarmSnapLogSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog`;
const resp = await client.post<NdmDeviceAlarmSnapLogResultVO>(endpoint, saveVO, { signal });
const data = unwrapResponse(resp);
return data;
};
export const updateDeviceAlarmSnapLogApi = async (updateVO: NdmDeviceAlarmSnapLogUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog`;
const resp = await client.put<NdmDeviceAlarmSnapLogResultVO>(endpoint, updateVO, { signal });
const data = unwrapResponse(resp);
return data;
};
export const deleteDeviceAlarmSnapLogApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog`;
const resp = await client.delete<boolean>(endpoint, ids, { signal });
const data = unwrapResponse(resp);
return data;
};

View File

@@ -1,4 +1,4 @@
import { getCameraSnapApi, type NdmDeviceAlarmLogResultVO } from '@/apis';
import { detailDeviceAlarmSnapLogApi, type NdmDeviceAlarmLogResultVO } from '@/apis';
import { tryGetDeviceType, DEVICE_TYPE_LITERALS } from '@/enums';
import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query';
@@ -7,11 +7,9 @@ import { h, ref, watch, type Ref } from 'vue';
export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
const { mutateAsync: getSnapByDeviceId } = useMutation({
mutationFn: async (params: { deviceAlarmLog: NdmDeviceAlarmLogResultVO }) => {
const { deviceAlarmLog } = params;
const { deviceId } = deviceAlarmLog;
if (!deviceId) throw new Error('设备ID不能为空');
const snap = await getCameraSnapApi(deviceId);
mutationFn: async (params: { id: string }) => {
const { id } = params;
const snap = await detailDeviceAlarmSnapLogApi(id);
return snap;
},
onError: (error) => {
@@ -28,15 +26,15 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
});
const cameraSnapColumn: DataTableColumn<NdmDeviceAlarmLogResultVO & { snapUrl?: string }> = {
title: '实时画面截图',
title: '告警画面截图',
key: 'snapUrl',
align: 'center',
render: (rowData) => {
const { deviceType: deviceTypeCode, snapUrl } = rowData;
const { id, deviceType: deviceTypeCode, snapUrl } = rowData;
if (!id) return null;
const deviceType = tryGetDeviceType(deviceTypeCode);
if (deviceType !== DEVICE_TYPE_LITERALS.ndmCamera) return null;
if (!snapUrl) {
const id = rowData.id ?? '';
return h(
NButton,
{
@@ -46,8 +44,9 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
onClick: async () => {
loadingMap.value[id] = true;
try {
const snap = await getSnapByDeviceId({ deviceAlarmLog: rowData });
rowData.snapUrl = snap.data.url;
const snap = await getSnapByDeviceId({ id });
if (!snap.url) return;
rowData.snapUrl = snap.url;
} finally {
loadingMap.value[id] = false;
}
@@ -60,6 +59,7 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
}
},
};
return {
cameraSnapColumn,
};

View File

@@ -139,7 +139,7 @@ const tableData = ref<DataTableRowData[]>([]);
const { cameraSnapColumn } = useCameraSnapColumn(tableData);
const { alarmActionColumn } = useAlarmActionColumn(tableData);
const tableColumns: DataTableColumns<NdmDeviceAlarmLogResultVO & { snapUrl?: string }> = [
const tableColumns: DataTableColumns<NdmDeviceAlarmLogResultVO> = [
// { title: '设备ID', key: 'deviceId' },
// { title: '故障编码', key: 'faultCode', align: 'center' },
// { title: '故障位置', key: 'faultLocation' },
@@ -234,6 +234,7 @@ const { mutate: getTableData, isPending: tableLoading } = useMutation({
signal,
},
);
return res;
},
onSuccess: (res) => {