Просмотр исходного кода

Merge branch 'all-v4-liufei' into 'all-v4'

1. 算法配置部分v4 api 对接  2. 解决菜单不可见情况下左侧菜单失焦问题

See merge request skyeye/skyeye_frontend/skyeye-admin!250
Fei Liu 1 год назад
Родитель
Сommit
b6c29e3867

+ 30 - 6
src/api/camera/camera-preview.ts

@@ -89,7 +89,11 @@ export interface AlgoItem {
   updatedAt?: string;
   extra: string;
 }
-/** 查询所有的算法 */
+
+
+/**
+ * v4: 获取所有算法列表
+ */
 export const getAllAlgosApi = () => {
   return http.request<AlgoItem[]>({
     url: '/admin/algo/queryAlgoInfo',
@@ -105,6 +109,17 @@ export const getAlgosByCameraCode = (cameraCode: string) => {
   });
 };
 
+/**
+ * v4: 根据相机ID获取绑定的算法
+ */
+export const getAlgosByCameraId = (cameraId: number) => {
+  return http.request<AlgoItem[]>({
+    url: `/admin/algo/queryAllAlgoInfoByCameraId?cameraId=${cameraId}`,
+    method: 'POST'
+  });
+};
+
+
 /** 相机关联的算法信息 */
 export interface CameraAlgoItem {
   id?: number;
@@ -399,12 +414,17 @@ interface AlgoPresetType {
   status: number;
 }
 
-//查询相机算法预设列表
+
+/**
+ * v4: 查询指定相机的算法预设列表
+ * @param cameraId 
+ * @returns 
+ */
 export const getCameraAlgoPresetList = (
-  cameraCode: string,
+  cameraId: number,
 ): Promise<{ algoInfoVOList: AlgoInfoType[] }> => {
   return http.request({
-    url: `/cameraPreview/getCameraAlgoPresetList?cameraCode=${cameraCode}`,
+    url: `/admin/cameraPreview/queryCameraAlgoPresetList?cameraId=${cameraId}`,
     method: 'get',
   });
 };
@@ -423,10 +443,14 @@ export const updateFenceDisplayStatus = (data: UpdateFenceType) => {
   });
 };
 
-// 根据相机id查询相机detail
+/**
+ * v4: 根据相机id查询相机detail
+ * @param id 
+ * @returns 
+ */
 export const getCameraDeatilById = (id: number) => {
   return http.request({
-    url: `/cameraPreview/queryCameraDetailById?id=${id}`,
+    url: `/admin/cameraPreview/queryCameraDetailById?id=${id}`,
     method: 'post',
   });
 };

+ 12 - 4
src/router/full-routes.ts

@@ -1,7 +1,8 @@
 /**
  * 1. 前端维护的完整路由表, 用于创建"菜单"
  * 2. component 是 string,并不是 组件对象。
- * 3. 生成菜单,关注的 path,name,component,icon
+ * 3. 生成菜单,关注的 path,name,component,icon。
+ * 4. 部分路由组件是菜单不可见的,当访问该路由时,左侧菜单的menu item会失去active状态。需要设置 meta.activeMenu 保持选中状态。
  */
 import { AppRouteRecordRaw } from './types';
 import { getTreeItem } from '@/utils';
@@ -143,7 +144,8 @@ const fullRoutes: AppRouteRecordRaw[] = [
         component: '/page-config/PageSceneList',
         meta: {
           icon: '',
-          title: '场景布局列表'
+          title: '场景布局列表',
+          activeMenu: 'LayoutScene',
         }
       },
       {
@@ -153,7 +155,8 @@ const fullRoutes: AppRouteRecordRaw[] = [
         component: '/page-config/ConfigEdit',
         meta: {
           icon: '',
-          title: '场景布局配置'
+          title: '场景布局配置',
+          activeMenu: 'LayoutScene',
         }
       },
       {
@@ -174,6 +177,7 @@ const fullRoutes: AppRouteRecordRaw[] = [
         meta: { 
           icon: '',
           title: '相机布局列表',
+          activeMenu: 'LayoutCamera',
         }
       },
       {
@@ -184,6 +188,7 @@ const fullRoutes: AppRouteRecordRaw[] = [
         meta: { 
           icon: '',
           title: '相机布局配置',
+          activeMenu: 'LayoutCamera',
         }
       }
     ]
@@ -309,7 +314,8 @@ const fullRoutes: AppRouteRecordRaw[] = [
         component: '/message/reportmessage/ReportOperation',
         meta: { 
           icon: '',
-          title: '报表推送配置' 
+          title: '报表推送配置',
+          activeMenu: 'MessageReport',
         },
       },
       {
@@ -330,6 +336,7 @@ const fullRoutes: AppRouteRecordRaw[] = [
         meta: { 
           icon: '',
           title: '报警推送配置',
+          activeMenu: 'MessageAlarm',
         },
       },
       {
@@ -350,6 +357,7 @@ const fullRoutes: AppRouteRecordRaw[] = [
         meta: { 
           icon: '',
           title: '系统通知配置',
+          activeMenu: 'MessageSysNotification',
         },
       }, 
       {

+ 1 - 0
src/views/cameras/preview/CameraPreview.vue

@@ -38,6 +38,7 @@
       isShowFence.value = false;
       fenceStore.clear();
       if (cameraId) {
+        // FIXME: 缺 后端v4 api 
         const presetList = await presetListStore.getPresetList(cameraId);
         getCameraDeatilById(cameraId).then((res) => {
           cameraDetailStore.setDetail(res);

+ 10 - 6
src/views/cameras/preview/components/AlgorithmsSetting/AddAlgoDialog.vue

@@ -48,7 +48,7 @@
   import { createCameraAlgoApi } from '@/api/camera/camera-preview';
   import useCameraDetailStore from '../../store/useCameraDetailStore';
   import AlgoAddBtn from '../AlgoSwitchCard/AlgoAddBtn.vue';
-  import { AlgoItem, getAlgosByCameraCode } from '@/api/camera/camera-preview';
+  import { AlgoItem, getAlgosByCameraCode, getAlgosByCameraId } from '@/api/camera/camera-preview';
 
   const selectedIds = ref<number[]>([]);
   const cameraAlgoStore = useCameraAlgoStore();
@@ -67,10 +67,14 @@
 
   const curOptionsByCode = ref<AlgoItem[]>([]);
   watch(
-    () => detail.value?.code,
-    (newCode) => {
-      if (!newCode) return;
-      getAlgosByCameraCode(newCode).then((res) => {
+    () => detail.value?.id,
+    (newId) => {
+      if (!newId) return;
+      // getAlgosByCameraCode(newCode).then((res) => {
+      //   curOptionsByCode.value = res;
+      // });
+
+      getAlgosByCameraId(newId).then(res => {
         curOptionsByCode.value = res;
       });
     },
@@ -105,7 +109,7 @@
 
   const showDialog = () => {
     visible.value = true;
-    selectedIds.value = undefined;
+    selectedIds.value = [];
   };
 </script>
 <style scoped>

+ 1 - 1
src/views/cameras/preview/components/CameraTree/CameraTree.vue

@@ -184,7 +184,7 @@
       const node = data[i];
       const matchedNode = targetData.find((item) => item.cameraCode === node.code);
       if (matchedNode) {
-        node.networkingState = matchedNode.status;
+        node.networkingState = matchedNode.networkingState;
         node.integrationState = matchedNode.integrationState;
       }
       if (node.integrationState === 1) {

+ 5 - 4
src/views/cameras/preview/components/FenceAppSetting/FenceAppSetting.vue

@@ -48,13 +48,14 @@
   });
 
   watch(
-    () => detail.value?.code,
-    (newCode) => {
-      if (!newCode) return;
-      getCameraAlgoPresetList(newCode).then((res) => {
+    () => detail.value?.id,
+    (newId) => {
+      if (!newId) return;
+      getCameraAlgoPresetList(newId).then((res) => {
         options.value = renameKeys(res.algoInfoVOList);
       });
 
+      // FIXME: 该 api 还没有提供
       getAppCameraAlgoPreset(newCode).then((res) => {
         appFenceCameraDetail.value = res;
         valuePreset.value = [res.algoCode, res.presetToken];

+ 1 - 1
src/views/datamanager/playback/Playback.vue

@@ -52,7 +52,7 @@
       const node = data[i];
       const matchedNode = targetData.find((item) => item.cameraCode === node.code);
       if (matchedNode) {
-        node.networkingState = matchedNode.status;
+        node.networkingState = matchedNode.networkingState;
         node.integrationState = matchedNode.integrationState;
       }
       if (node.integrationState === 1) {

+ 2 - 0
src/views/system/menu/MenuForm.vue

@@ -362,6 +362,7 @@
     frameSrc: '',
     openType: 1, 
     query: '',
+    activeMenu: '',
   };
   const formParams = ref({ ...defaultFormParams });
 
@@ -423,6 +424,7 @@
     formParams.value.component = currentRoute.component;
     formParams.value.icon = currentRoute.meta.icon as string;
     formParams.value.menuName = currentRoute.meta.title as string;
+    formParams.value.activeMenu = currentRoute.meta.activeMenu as string || '';
   });
 
   function setData(data: MenuDetailItem) {