feat: 设备树添加管理功能
- 新增设备导入、导出、删除功能及相关API - 封装设备管理逻辑,拆分设备选择与设备管理逻辑 - 添加右键菜单支持设备管理操作
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import type { Nullable } from '@/types';
|
||||
import type { NdmAlarmHost } from './alarm';
|
||||
import type { NdmSecurityBox, NdmSwitch } from './other';
|
||||
import type { NdmNvr } from './storage';
|
||||
import type { NdmAlarmHost, NdmAlarmHostPageQuery } from './alarm';
|
||||
import type { NdmSecurityBox, NdmSecurityBoxPageQuery, NdmSwitch, NdmSwitchPageQuery } from './other';
|
||||
import type { NdmNvr, NdmNvrPageQuery } from './storage';
|
||||
import type {
|
||||
NdmCamera,
|
||||
NdmCameraPageQuery,
|
||||
NdmDecoder,
|
||||
NdmDecoderPageQuery,
|
||||
NdmKeyboard,
|
||||
NdmKeyboardPageQuery,
|
||||
NdmMediaServer,
|
||||
NdmMediaServerPageQuery,
|
||||
NdmMediaServerResultVO,
|
||||
@@ -19,6 +22,16 @@ import type {
|
||||
} from './video';
|
||||
|
||||
export type NdmDevice = NdmAlarmHost | NdmCamera | NdmDecoder | NdmKeyboard | NdmMediaServer | NdmNvr | NdmSecurityBox | NdmSwitch | NdmVideoServer;
|
||||
export type NdmDevicePageQuery =
|
||||
| NdmAlarmHostPageQuery
|
||||
| NdmCameraPageQuery
|
||||
| NdmDecoderPageQuery
|
||||
| NdmKeyboardPageQuery
|
||||
| NdmMediaServerPageQuery
|
||||
| NdmNvrPageQuery
|
||||
| NdmSecurityBoxPageQuery
|
||||
| NdmSwitchPageQuery
|
||||
| NdmVideoServerPageQuery;
|
||||
|
||||
export type NdmDeviceResultVO = Nullable<NdmDevice>;
|
||||
|
||||
|
||||
13
src/apis/model/common/import-msg.ts
Normal file
13
src/apis/model/common/import-msg.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export interface ImportMsg {
|
||||
wrongLines: WrongLine[];
|
||||
wrongNum: number;
|
||||
updateNum: number;
|
||||
insertNum: number;
|
||||
unchangedNum: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface WrongLine {
|
||||
rowNum: number;
|
||||
msg: string;
|
||||
}
|
||||
1
src/apis/model/common/index.ts
Normal file
1
src/apis/model/common/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './import-msg';
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './base';
|
||||
export * from './biz';
|
||||
export * from './common';
|
||||
export * from './system';
|
||||
|
||||
32
src/apis/request/biz/composed/delete-device.ts
Normal file
32
src/apis/request/biz/composed/delete-device.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
deleteAlarmHostApi,
|
||||
deleteCameraApi,
|
||||
deleteDecoderApi,
|
||||
deleteKeyboardApi,
|
||||
deleteMediaServerApi,
|
||||
deleteNvrApi,
|
||||
deleteSecurityBoxApi,
|
||||
deleteSwitchApi,
|
||||
deleteVideoServerApi,
|
||||
type Station,
|
||||
} from '@/apis';
|
||||
import { DEVICE_TYPE_LITERALS, type DeviceType } from '@/enums';
|
||||
|
||||
export const deleteDeviceApi = async (deviceType: DeviceType, id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||
const apiRecord = {
|
||||
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: deleteAlarmHostApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmCamera]: deleteCameraApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmDecoder]: deleteDecoderApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmKeyboard]: deleteKeyboardApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmMediaServer]: deleteMediaServerApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmNvr]: deleteNvrApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmSecurityBox]: deleteSecurityBoxApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmSwitch]: deleteSwitchApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmVideoServer]: deleteVideoServerApi,
|
||||
};
|
||||
|
||||
const deleteApi = apiRecord[deviceType];
|
||||
if (!deleteApi) throw new Error('接口不存在');
|
||||
|
||||
return deleteApi([id], options);
|
||||
};
|
||||
34
src/apis/request/biz/composed/export-device.ts
Normal file
34
src/apis/request/biz/composed/export-device.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
exportAlarmHostApi,
|
||||
exportCameraApi,
|
||||
exportDecoderApi,
|
||||
exportKeyboardApi,
|
||||
exportMediaServerApi,
|
||||
exportNvrApi,
|
||||
exportSecurityBoxApi,
|
||||
exportSwitchApi,
|
||||
exportVideoServerApi,
|
||||
type NdmDevicePageQuery,
|
||||
type PageParams,
|
||||
type Station,
|
||||
} from '@/apis';
|
||||
import { DEVICE_TYPE_LITERALS, type DeviceType } from '@/enums';
|
||||
|
||||
export const exportDeviceApi = async (deviceType: DeviceType, pageQuery: PageParams<NdmDevicePageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||
const apiRecord = {
|
||||
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: exportAlarmHostApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmCamera]: exportCameraApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmDecoder]: exportDecoderApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmKeyboard]: exportKeyboardApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmMediaServer]: exportMediaServerApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmNvr]: exportNvrApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmSecurityBox]: exportSecurityBoxApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmSwitch]: exportSwitchApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmVideoServer]: exportVideoServerApi,
|
||||
};
|
||||
|
||||
const exportApi = apiRecord[deviceType];
|
||||
if (!exportApi) throw new Error('接口不存在');
|
||||
|
||||
return exportApi(pageQuery, options);
|
||||
};
|
||||
32
src/apis/request/biz/composed/import-device.ts
Normal file
32
src/apis/request/biz/composed/import-device.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
importAlarmHostApi,
|
||||
importCameraApi,
|
||||
importDecoderApi,
|
||||
importKeyboardApi,
|
||||
importMediaServerApi,
|
||||
importNvrApi,
|
||||
importSecurityBoxApi,
|
||||
importSwitchApi,
|
||||
importVideoServerApi,
|
||||
type Station,
|
||||
} from '@/apis';
|
||||
import { DEVICE_TYPE_LITERALS, type DeviceType } from '@/enums';
|
||||
|
||||
export const importDeviceApi = async (deviceType: DeviceType, file: File, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||
const apiRecord = {
|
||||
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: importAlarmHostApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmCamera]: importCameraApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmDecoder]: importDecoderApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmKeyboard]: importKeyboardApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmMediaServer]: importMediaServerApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmNvr]: importNvrApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmSecurityBox]: importSecurityBoxApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmSwitch]: importSwitchApi,
|
||||
[DEVICE_TYPE_LITERALS.ndmVideoServer]: importVideoServerApi,
|
||||
};
|
||||
|
||||
const importApi = apiRecord[deviceType];
|
||||
if (!importApi) throw new Error('接口不存在');
|
||||
|
||||
return importApi(file, options);
|
||||
};
|
||||
@@ -1,2 +1,5 @@
|
||||
export * from './delete-device';
|
||||
export * from './detail-device';
|
||||
export * from './export-device';
|
||||
export * from './import-device';
|
||||
export * from './probe-device';
|
||||
|
||||
Reference in New Issue
Block a user