feat(alarm-page): ignore camera
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export * from './ndm-camera';
|
||||
export * from './ndm-camera-ignore';
|
||||
export * from './ndm-decoder';
|
||||
export * from './ndm-keyboard';
|
||||
export * from './ndm-media-server';
|
||||
|
||||
14
src/apis/model/biz/entity/video/ndm-camera-ignore.ts
Normal file
14
src/apis/model/biz/entity/video/ndm-camera-ignore.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { BaseModel, ReduceForPageQuery, ReduceForSaveVO, ReduceForUpdateVO } from '@/apis';
|
||||
|
||||
export interface NdmCameraIgnore extends BaseModel {
|
||||
deviceId: string;
|
||||
ignoreType: string;
|
||||
}
|
||||
|
||||
export type NdmCameraIgnoreResultVO = Partial<NdmCameraIgnore>;
|
||||
|
||||
export type NdmCameraIgnoreSaveVO = Partial<Omit<NdmCameraIgnore, ReduceForSaveVO>>;
|
||||
|
||||
export type NdmCameraIgnoreUpdateVO = Partial<Omit<NdmCameraIgnore, ReduceForUpdateVO>>;
|
||||
|
||||
export type NdmCameraIgnorePageQuery = Partial<Omit<NdmCameraIgnore, ReduceForPageQuery>>;
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './ndm-camera';
|
||||
export * from './ndm-camera-ignore';
|
||||
export * from './ndm-decoder';
|
||||
export * from './ndm-keyboard';
|
||||
export * from './ndm-media-server';
|
||||
|
||||
66
src/apis/request/biz/video/ndm-camera-ignore.ts
Normal file
66
src/apis/request/biz/video/ndm-camera-ignore.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { ndmClient, userClient, type NdmCameraIgnorePageQuery, type NdmCameraIgnoreResultVO, type NdmCameraIgnoreSaveVO, type NdmCameraIgnoreUpdateVO, type PageParams, type PageResult } from '@/apis';
|
||||
|
||||
export const pageCameraIgnoreApi = async (pageQuery: PageParams<NdmCameraIgnorePageQuery>, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore/page`;
|
||||
const resp = await client.post<PageResult<NdmCameraIgnoreResultVO>>(endpoint, pageQuery, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const detailCameraIgnoreApi = async (id: string, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore/detail`;
|
||||
const resp = await client.get<NdmCameraIgnoreResultVO>(endpoint, { params: { id }, signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const saveCameraIgnoreApi = async (saveVO: NdmCameraIgnoreSaveVO, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
||||
const resp = await client.post<NdmCameraIgnoreResultVO>(endpoint, saveVO, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const updateCameraIgnoreApi = async (updateVO: NdmCameraIgnoreUpdateVO, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
||||
const resp = await client.put<NdmCameraIgnoreResultVO>(endpoint, updateVO, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const removeCameraIgnoreApi = async (ids: string[], options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
@@ -1,13 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { getCameraSnapApi, exportDeviceAlarmLogApi, pageDeviceAlarmLogApi, updateDeviceAlarmLogApi, type NdmDeviceAlarmLogResultVO } from '@/apis';
|
||||
import {
|
||||
getCameraSnapApi,
|
||||
exportDeviceAlarmLogApi,
|
||||
pageDeviceAlarmLogApi,
|
||||
updateDeviceAlarmLogApi,
|
||||
pageCameraIgnoreApi,
|
||||
saveCameraIgnoreApi,
|
||||
removeCameraIgnoreApi,
|
||||
type NdmDeviceAlarmLogResultVO,
|
||||
} from '@/apis';
|
||||
import { renderAlarmDateCell, renderAlarmTypeCell, renderDeviceTypeCell, renderFaultLevelCell } from '@/components';
|
||||
import { AlarmType, DeviceType, DeviceTypeCode, DeviceTypeName, FaultLevel, tryGetDeviceTypeVal, type DeviceTypeVal } from '@/enums';
|
||||
import { useAlarmStore, useStationStore } from '@/stores';
|
||||
import { downloadByData } from '@/utils';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { CheckOutlined, EyeInvisibleOutlined, EyeOutlined } from '@vicons/antd';
|
||||
import { watchDebounced } from '@vueuse/core';
|
||||
import dayjs from 'dayjs';
|
||||
import { debounce } from 'es-toolkit';
|
||||
import {
|
||||
NForm,
|
||||
NInput,
|
||||
@@ -19,7 +28,6 @@ import {
|
||||
NSelect,
|
||||
NGridItem,
|
||||
NDatePicker,
|
||||
NTag,
|
||||
NPopconfirm,
|
||||
NModal,
|
||||
NImage,
|
||||
@@ -137,6 +145,9 @@ const snapPreviewShow = ref(false);
|
||||
const snapPreviewUrl = ref('');
|
||||
|
||||
const tableColumns: DataTableColumns<NdmDeviceAlarmLogResultVO & { snapUrl: string }> = [
|
||||
// { title: '设备ID', key: 'deviceId' },
|
||||
// { title: '故障编码', key: 'faultCode', align: 'center' },
|
||||
// { title: '故障位置', key: 'faultLocation' },
|
||||
{ title: '告警流水号', key: 'alarmNo' },
|
||||
{
|
||||
title: '告警时间',
|
||||
@@ -169,8 +180,6 @@ const tableColumns: DataTableColumns<NdmDeviceAlarmLogResultVO & { snapUrl: stri
|
||||
align: 'center',
|
||||
render: renderFaultLevelCell,
|
||||
},
|
||||
// { title: '故障编码', key: 'faultCode', align: 'center' },
|
||||
// { title: '故障位置', key: 'faultLocation' },
|
||||
{ title: '故障描述', key: 'faultDescription' },
|
||||
{ title: '修复建议', key: 'alarmRepairSuggestion' },
|
||||
{
|
||||
@@ -219,30 +228,59 @@ const tableColumns: DataTableColumns<NdmDeviceAlarmLogResultVO & { snapUrl: stri
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '告警确认',
|
||||
key: 'alarmConfirm',
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
align: 'center',
|
||||
render: (rowData) => {
|
||||
if (rowData.alarmConfirm === '1') {
|
||||
return h(NTag, { type: 'default' }, { default: () => '已确认' });
|
||||
}
|
||||
const { id } = rowData;
|
||||
return h(
|
||||
NPopconfirm,
|
||||
NFlex,
|
||||
{
|
||||
onPositiveClick: () => {
|
||||
rowData.alarmConfirm = '1';
|
||||
confirmAlarm({ id });
|
||||
},
|
||||
size: 'small',
|
||||
justify: 'center',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
trigger: () => h(NButton, { type: 'info', size: 'small' }, { default: () => '确认' }),
|
||||
default: () => '确认告警?',
|
||||
default: () => [
|
||||
rowData.alarmConfirm === '1'
|
||||
? h(NButton, { disabled: true, text: true, type: 'info', size: 'small' }, { icon: () => h(CheckOutlined) })
|
||||
: h(
|
||||
NPopconfirm,
|
||||
{
|
||||
onPositiveClick: () => confirmAlarm({ id }),
|
||||
},
|
||||
{
|
||||
trigger: () => h(NButton, { text: true, type: 'info', size: 'small' }, { icon: () => h(CheckOutlined) }),
|
||||
default: () => '确认告警?',
|
||||
},
|
||||
),
|
||||
tryGetDeviceTypeVal(rowData.deviceType) === DeviceType.Camera && [
|
||||
h(
|
||||
NPopconfirm,
|
||||
{
|
||||
onPositiveClick: () => ignoreCamera({ id }),
|
||||
},
|
||||
{
|
||||
trigger: () => h(NButton, { text: true, type: 'info', size: 'small' }, { icon: () => h(EyeInvisibleOutlined) }),
|
||||
default: () => '忽略设备?',
|
||||
},
|
||||
),
|
||||
h(
|
||||
NPopconfirm,
|
||||
{
|
||||
onPositiveClick: () => noticeCamera({ id }),
|
||||
},
|
||||
{
|
||||
trigger: () => h(NButton, { text: true, type: 'info', size: 'small' }, { icon: () => h(EyeOutlined) }),
|
||||
default: () => '取消忽略设备?',
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
// { title: '设备ID', key: 'deviceId' },
|
||||
];
|
||||
|
||||
const tableData = ref<DataTableRowData[]>([]);
|
||||
@@ -298,7 +336,6 @@ const onClickReset = () => {
|
||||
tablePagination.itemCount = 0;
|
||||
getTableData();
|
||||
};
|
||||
const onClickResetDebounced = debounce(onClickReset, 500);
|
||||
const onClickQuery = () => {
|
||||
if (searchFieldsChanged.value) {
|
||||
tablePagination.page = 1;
|
||||
@@ -324,8 +361,15 @@ const { mutateAsync: getSnapByDeviceId } = useMutation({
|
||||
|
||||
const { mutate: confirmAlarm } = useMutation({
|
||||
mutationFn: async (params: { id?: string }) => {
|
||||
const { id } = params;
|
||||
if (id) {
|
||||
const alarmLog = tableData.value.find((item) => item.id === id);
|
||||
if (alarmLog) {
|
||||
alarmLog['alarmConfirm'] = '1';
|
||||
}
|
||||
}
|
||||
await updateDeviceAlarmLogApi({
|
||||
id: params.id,
|
||||
id,
|
||||
alarmConfirm: '1',
|
||||
});
|
||||
},
|
||||
@@ -342,6 +386,61 @@ const { mutate: confirmAlarm } = useMutation({
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: ignoreCamera } = useMutation({
|
||||
mutationFn: async (params: { id?: string }) => {
|
||||
const { id } = params;
|
||||
if (!id) return;
|
||||
const alarmLog = tableData.value.find((item) => item.id === id);
|
||||
if (!alarmLog) return;
|
||||
const { records } = await pageCameraIgnoreApi({
|
||||
model: { deviceId: alarmLog.deviceId },
|
||||
extra: {},
|
||||
current: 1,
|
||||
size: 10,
|
||||
sort: 'id',
|
||||
order: 'descending',
|
||||
});
|
||||
const ignoredCamera = records.at(0);
|
||||
if (ignoredCamera) {
|
||||
window.$message.info('设备已被忽略');
|
||||
return;
|
||||
}
|
||||
await saveCameraIgnoreApi({ deviceId: alarmLog.deviceId });
|
||||
window.$message.success('忽略设备成功');
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
window.$message.error(error.message);
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: noticeCamera } = useMutation({
|
||||
mutationFn: async (params: { id?: string }) => {
|
||||
const { id } = params;
|
||||
if (!id) return;
|
||||
const alarmLog = tableData.value.find((item) => item.id === id);
|
||||
if (!alarmLog) return;
|
||||
const { records } = await pageCameraIgnoreApi({
|
||||
model: { deviceId: alarmLog.deviceId },
|
||||
extra: {},
|
||||
current: 1,
|
||||
size: 10,
|
||||
sort: 'id',
|
||||
order: 'descending',
|
||||
});
|
||||
if (records.length === 0) {
|
||||
window.$message.info('设备未被忽略');
|
||||
return;
|
||||
}
|
||||
await removeCameraIgnoreApi([...records.map((record) => record.id ?? '')]);
|
||||
window.$message.success('取消忽略设备成功');
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
window.$message.error(error.message);
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: exportTableData, isPending: exporting } = useMutation({
|
||||
mutationFn: async () => {
|
||||
const data = await exportDeviceAlarmLogApi({
|
||||
|
||||
Reference in New Issue
Block a user