|
|
@@ -2,7 +2,13 @@
|
|
|
<div>
|
|
|
<div class="cameraMain">
|
|
|
<div class="cameraTree">
|
|
|
- <CameraTreeCom :loading="presetListStore.loading" :camera-tree="cameraTree || []" />
|
|
|
+ <CameraTreeCom
|
|
|
+ :loading="presetListStore.loading"
|
|
|
+ :camera-tree="cameraTree || []"
|
|
|
+ :total="codeShowList.length"
|
|
|
+ :no-integration-num="noIntegrationNum"
|
|
|
+ :no-networking-num="noNetworkingNum"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div class="cameraSettingWrapper">
|
|
|
<div class="cameraView">
|
|
|
@@ -25,11 +31,54 @@
|
|
|
import { onMounted } from 'vue';
|
|
|
import { IsPtz } from '@/api/camera/camera-overview';
|
|
|
import { CameraTree, getCameraTree } from '@/api/camera/camera-preview';
|
|
|
+ import useCameraStatus from './store/useCameraStatus';
|
|
|
+
|
|
|
+ const cameraStatus = useCameraStatus();
|
|
|
+ const { noNetworkingNum, openInterval, closeInterval } = cameraStatus;
|
|
|
+
|
|
|
const cameraDetailStore = useCameraDetailStore();
|
|
|
const cameraAlgoStore = useCameraAlgoStore();
|
|
|
const fenceStore = useFenceStore();
|
|
|
const presetListStore = usePresetListStore();
|
|
|
const cameraTree = ref<CameraTree[]>([]);
|
|
|
+ const codeShowList = ref<string[]>([]);
|
|
|
+ const noIntegrationNum = ref<number>(0);
|
|
|
+
|
|
|
+ function updateNetworkingState(data, targetData) {
|
|
|
+ let integrationCount = 0;
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ const node = data[i];
|
|
|
+ const matchedNode = targetData.find((item) => item.cameraCode === node.code);
|
|
|
+ if (matchedNode) {
|
|
|
+ node.networkingState = 1;
|
|
|
+ }
|
|
|
+ if (node.integrationState === 1) {
|
|
|
+ integrationCount++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ const childIntegrationCount = updateNetworkingState(node.children, targetData);
|
|
|
+ integrationCount += childIntegrationCount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ noIntegrationNum.value = integrationCount;
|
|
|
+ return integrationCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ function getCameraList(data) {
|
|
|
+ let cameraList = [] as string[];
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ const node = data[i];
|
|
|
+ if (node.nodeType === 'camera') {
|
|
|
+ cameraList.push(node.code);
|
|
|
+ }
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ const childCameraList = getCameraList(node.children);
|
|
|
+ cameraList.push(...childCameraList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return cameraList;
|
|
|
+ }
|
|
|
|
|
|
watch(
|
|
|
() => cameraDetailStore.cameraId,
|
|
|
@@ -45,8 +94,6 @@
|
|
|
}
|
|
|
|
|
|
const detail = getCameraDetail(cameraTree.value, cameraDetailStore.cameraId);
|
|
|
-
|
|
|
- console.log('cameraDetail', detail);
|
|
|
if (detail) {
|
|
|
cameraDetailStore.setDetail(detail);
|
|
|
if (detail?.isPtz === IsPtz.disabled) {
|
|
|
@@ -69,6 +116,15 @@
|
|
|
|
|
|
onMounted(() => {
|
|
|
cameraAlgoStore.getAllAlgoList();
|
|
|
+ getCameraTree().then((res) => {
|
|
|
+ cameraTree.value = res;
|
|
|
+ codeShowList.value = getCameraList(res);
|
|
|
+ // openInterval(codeShowList.value, cameraTree.value, updateNetworkingState);
|
|
|
+ // (targetData) => { updateNetworkingState(cameraTree.value, targetData) }
|
|
|
+ openInterval(codeShowList.value, (targetData) => {
|
|
|
+ updateNetworkingState(cameraTree.value, targetData);
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
@@ -77,7 +133,7 @@
|
|
|
cameraAlgoStore.clear();
|
|
|
fenceStore.clear();
|
|
|
presetListStore.clear();
|
|
|
- console.log('camera preview onUnmounted');
|
|
|
+ closeInterval();
|
|
|
});
|
|
|
|
|
|
function getCameraDetail(tree: CameraTree[], cameraId: number): CameraTree | null {
|