feat(vimp): 新增摄像头和告警通道的全局索引记录及构建方法
在摄像头、告警的Pinia存储中新增对应的数据记录与构建函数,并在渠道查询组合式函数中调用生成全局索引映射数据
This commit is contained in:
@@ -134,6 +134,7 @@ export const useChannelsQuery = () => {
|
||||
codeSites,
|
||||
compiledCodeAreas,
|
||||
});
|
||||
cameraStore.buildCameraRecord(siteCodeToCamerasMap);
|
||||
|
||||
alarmStore.buildLineTabPanes({
|
||||
sites: alarmSites,
|
||||
@@ -142,6 +143,7 @@ export const useChannelsQuery = () => {
|
||||
codeSites,
|
||||
compiledCodeAreas,
|
||||
});
|
||||
alarmStore.buildAlarmRecord(siteCodeToAlarmsMap);
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
@@ -16,6 +16,7 @@ const buildSubAreaNodeKey = (siteCode: string, areaCode: string) => `${siteCode}
|
||||
|
||||
export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
||||
const lineTabPanes = shallowRef<AlarmLineTabPane[]>([]);
|
||||
const alarmRecord = shallowRef<Record<string, VimpChannel>>({});
|
||||
|
||||
const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
|
||||
const { sites, siteCodeToAlarmsMap, codeLines, codeSites, compiledCodeAreas } = params;
|
||||
@@ -154,8 +155,21 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
||||
lineTabPanes.value = result;
|
||||
};
|
||||
|
||||
const buildAlarmRecord = (siteCodeToAlarmsMap: Map<string, VimpChannel[]>) => {
|
||||
const record: Record<string, VimpChannel> = {};
|
||||
for (const [, alarms] of siteCodeToAlarmsMap) {
|
||||
for (const alarm of alarms) {
|
||||
record[alarm.code] = alarm;
|
||||
}
|
||||
}
|
||||
alarmRecord.value = record;
|
||||
};
|
||||
|
||||
return {
|
||||
lineTabPanes,
|
||||
alarmRecord,
|
||||
|
||||
buildLineTabPanes,
|
||||
buildAlarmRecord,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import type { VimpChannel, VimpSite } from '../apis';
|
||||
import { shallowRef } from 'vue';
|
||||
import { ref, shallowRef } from 'vue';
|
||||
import type { CameraMainAreaNodeOption, CameraNodeOption, CodeLines, CodeSites, CameraLineTabPane, CameraSiteNodeOption, CameraSubAreaNodeOption, CompiledCodeAreas } from '../types';
|
||||
|
||||
interface BuildLineTabPanesParams {
|
||||
@@ -16,6 +16,7 @@ const buildSubAreaNodeKey = (siteCode: string, areaCode: string) => `${siteCode}
|
||||
|
||||
export const useCameraStore = defineStore('vimp-camera-store', () => {
|
||||
const lineTabPanes = shallowRef<CameraLineTabPane[]>([]);
|
||||
const cameraRecord = shallowRef<Record<string, VimpChannel>>({});
|
||||
|
||||
const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
|
||||
const { sites, siteCodeToCamerasMap, codeLines, codeSites, compiledCodeAreas } = params;
|
||||
@@ -153,8 +154,21 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
||||
lineTabPanes.value = result;
|
||||
};
|
||||
|
||||
const buildCameraRecord = (siteCodeToCamerasMap: Map<string, VimpChannel[]>) => {
|
||||
const record: Record<string, VimpChannel> = {};
|
||||
for (const [, cameras] of siteCodeToCamerasMap) {
|
||||
for (const camera of cameras) {
|
||||
record[camera.code] = camera;
|
||||
}
|
||||
}
|
||||
cameraRecord.value = record;
|
||||
};
|
||||
|
||||
return {
|
||||
lineTabPanes,
|
||||
cameraRecord,
|
||||
|
||||
buildLineTabPanes,
|
||||
buildCameraRecord,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user