feat: 支持查看摄像机告警画面截图
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
export * from './ndm-call-log';
|
export * from './ndm-call-log';
|
||||||
export * from './ndm-device-alarm-log';
|
export * from './ndm-device-alarm-log';
|
||||||
|
export * from './ndm-device-alarm-snap-log';
|
||||||
export * from './ndm-icmp-log';
|
export * from './ndm-icmp-log';
|
||||||
export * from './ndm-record-check';
|
export * from './ndm-record-check';
|
||||||
export * from './ndm-snmp-log';
|
export * from './ndm-snmp-log';
|
||||||
|
|||||||
16
src/apis/model/biz/entity/log/ndm-device-alarm-snap-log.ts
Normal file
16
src/apis/model/biz/entity/log/ndm-device-alarm-snap-log.ts
Normal 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>>;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from './ndm-call-log';
|
export * from './ndm-call-log';
|
||||||
export * from './ndm-device-alarm-log';
|
export * from './ndm-device-alarm-log';
|
||||||
|
export * from './ndm-device-alarm-snap-log';
|
||||||
export * from './ndm-icmp-log';
|
export * from './ndm-icmp-log';
|
||||||
export * from './ndm-snmp-log';
|
export * from './ndm-snmp-log';
|
||||||
export * from './ndm-record-check';
|
export * from './ndm-record-check';
|
||||||
|
|||||||
62
src/apis/request/biz/log/ndm-device-alarm-snap-log.ts
Normal file
62
src/apis/request/biz/log/ndm-device-alarm-snap-log.ts
Normal 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;
|
||||||
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getCameraSnapApi, type NdmDeviceAlarmLogResultVO } from '@/apis';
|
import { detailDeviceAlarmSnapLogApi, type NdmDeviceAlarmLogResultVO } from '@/apis';
|
||||||
import { tryGetDeviceType, DEVICE_TYPE_LITERALS } from '@/enums';
|
import { tryGetDeviceType, DEVICE_TYPE_LITERALS } from '@/enums';
|
||||||
import { parseErrorFeedback } from '@/utils';
|
import { parseErrorFeedback } from '@/utils';
|
||||||
import { useMutation } from '@tanstack/vue-query';
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
@@ -7,11 +7,9 @@ import { h, ref, watch, type Ref } from 'vue';
|
|||||||
|
|
||||||
export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
|
export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
|
||||||
const { mutateAsync: getSnapByDeviceId } = useMutation({
|
const { mutateAsync: getSnapByDeviceId } = useMutation({
|
||||||
mutationFn: async (params: { deviceAlarmLog: NdmDeviceAlarmLogResultVO }) => {
|
mutationFn: async (params: { id: string }) => {
|
||||||
const { deviceAlarmLog } = params;
|
const { id } = params;
|
||||||
const { deviceId } = deviceAlarmLog;
|
const snap = await detailDeviceAlarmSnapLogApi(id);
|
||||||
if (!deviceId) throw new Error('设备ID不能为空');
|
|
||||||
const snap = await getCameraSnapApi(deviceId);
|
|
||||||
return snap;
|
return snap;
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
@@ -28,15 +26,15 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const cameraSnapColumn: DataTableColumn<NdmDeviceAlarmLogResultVO & { snapUrl?: string }> = {
|
const cameraSnapColumn: DataTableColumn<NdmDeviceAlarmLogResultVO & { snapUrl?: string }> = {
|
||||||
title: '实时画面截图',
|
title: '告警画面截图',
|
||||||
key: 'snapUrl',
|
key: 'snapUrl',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: (rowData) => {
|
render: (rowData) => {
|
||||||
const { deviceType: deviceTypeCode, snapUrl } = rowData;
|
const { id, deviceType: deviceTypeCode, snapUrl } = rowData;
|
||||||
|
if (!id) return null;
|
||||||
const deviceType = tryGetDeviceType(deviceTypeCode);
|
const deviceType = tryGetDeviceType(deviceTypeCode);
|
||||||
if (deviceType !== DEVICE_TYPE_LITERALS.ndmCamera) return null;
|
if (deviceType !== DEVICE_TYPE_LITERALS.ndmCamera) return null;
|
||||||
if (!snapUrl) {
|
if (!snapUrl) {
|
||||||
const id = rowData.id ?? '';
|
|
||||||
return h(
|
return h(
|
||||||
NButton,
|
NButton,
|
||||||
{
|
{
|
||||||
@@ -46,8 +44,9 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
|
|||||||
onClick: async () => {
|
onClick: async () => {
|
||||||
loadingMap.value[id] = true;
|
loadingMap.value[id] = true;
|
||||||
try {
|
try {
|
||||||
const snap = await getSnapByDeviceId({ deviceAlarmLog: rowData });
|
const snap = await getSnapByDeviceId({ id });
|
||||||
rowData.snapUrl = snap.data.url;
|
if (!snap.url) return;
|
||||||
|
rowData.snapUrl = snap.url;
|
||||||
} finally {
|
} finally {
|
||||||
loadingMap.value[id] = false;
|
loadingMap.value[id] = false;
|
||||||
}
|
}
|
||||||
@@ -60,6 +59,7 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cameraSnapColumn,
|
cameraSnapColumn,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ const tableData = ref<DataTableRowData[]>([]);
|
|||||||
|
|
||||||
const { cameraSnapColumn } = useCameraSnapColumn(tableData);
|
const { cameraSnapColumn } = useCameraSnapColumn(tableData);
|
||||||
const { alarmActionColumn } = useAlarmActionColumn(tableData);
|
const { alarmActionColumn } = useAlarmActionColumn(tableData);
|
||||||
const tableColumns: DataTableColumns<NdmDeviceAlarmLogResultVO & { snapUrl?: string }> = [
|
const tableColumns: DataTableColumns<NdmDeviceAlarmLogResultVO> = [
|
||||||
// { title: '设备ID', key: 'deviceId' },
|
// { title: '设备ID', key: 'deviceId' },
|
||||||
// { title: '故障编码', key: 'faultCode', align: 'center' },
|
// { title: '故障编码', key: 'faultCode', align: 'center' },
|
||||||
// { title: '故障位置', key: 'faultLocation' },
|
// { title: '故障位置', key: 'faultLocation' },
|
||||||
@@ -234,6 +234,7 @@ const { mutate: getTableData, isPending: tableLoading } = useMutation({
|
|||||||
signal,
|
signal,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user