Преглед изворни кода

fix: 下线相机校验+默认相机可以删除

sunhongyao341504 пре 2 година
родитељ
комит
38d2b15382
2 измењених фајлова са 44 додато и 10 уклоњено
  1. 1 1
      .env.development
  2. 43 9
      src/views/map-config/mini-map/MapBase/KonvaMap.vue

+ 1 - 1
.env.development

@@ -22,7 +22,7 @@ VITE_GLOB_API_URL =
 VITE_GLOB_UPLOAD_URL=  
 VITE_GLOB_UPLOAD_URL=  
 
 
 # 图片前缀地址
 # 图片前缀地址
-VITE_GLOB_IMG_URL = //192.168.1.102/skyeye_static/
+VITE_GLOB_IMG_URL = //58.144.197.158:19980/skyeye_static/
 
 
 
 
 # 接口前缀
 # 接口前缀

+ 43 - 9
src/views/map-config/mini-map/MapBase/KonvaMap.vue

@@ -36,7 +36,7 @@
 
 
 <script setup lang="ts">
 <script setup lang="ts">
   import { ref, onMounted, onBeforeUnmount, watch } from 'vue';
   import { ref, onMounted, onBeforeUnmount, watch } from 'vue';
-  import { ElMessage } from 'element-plus';
+  import { ElMessage, ElMessageBox } from 'element-plus';
   import { useGlobSetting } from '@/hooks/setting';
   import { useGlobSetting } from '@/hooks/setting';
   import DefaultTip from '../components/DefaultTip.vue';
   import DefaultTip from '../components/DefaultTip.vue';
   import urlJoin from 'url-join';
   import urlJoin from 'url-join';
@@ -44,9 +44,14 @@
   import favoritesImgSrc from '@/assets/camera/favorites.png';
   import favoritesImgSrc from '@/assets/camera/favorites.png';
   import { TipPositionEnum, camerasGroupType } from '../type';
   import { TipPositionEnum, camerasGroupType } from '../type';
   import { cloneDeep } from 'lodash-es';
   import { cloneDeep } from 'lodash-es';
+  import useMiniMap from '../use-mini-map';
+  import { storeToRefs } from 'pinia';
 
 
   const globSetting = useGlobSetting();
   const globSetting = useGlobSetting();
 
 
+  const miniMap = useMiniMap();
+  const { shopCameraList } = storeToRefs(miniMap);
+
   const emit = defineEmits(['changeDefaultCamera', 'sendCameraId']);
   const emit = defineEmits(['changeDefaultCamera', 'sendCameraId']);
 
 
   const camImg = new Image();
   const camImg = new Image();
@@ -313,11 +318,27 @@
   const handleKeyDown = (e) => {
   const handleKeyDown = (e) => {
     if (e.keyCode === 46 || e.code === 'Delete') {
     if (e.keyCode === 46 || e.code === 'Delete') {
       if (lastClickedGroupId.value === defaultCameraId.value) {
       if (lastClickedGroupId.value === defaultCameraId.value) {
-        ElMessage.error({
-          message: '无法删除默认相机',
-        });
-        return;
+        // ElMessage.error({
+        //   message: '无法删除默认相机',
+        // });
+        // return;
+        ElMessageBox.confirm('此相机为默认相机,您确认要删除此相机?', 'Warning', {
+          confirmButtonText: '确认',
+          cancelButtonText: '取消',
+          type: 'warning',
+        })
+          .then(() => {
+            const index = cameras.value.findIndex((item) => item.id === lastClickedGroupId.value);
+            index >= 0 && cameras.value.splice(index, 1);
+            lastClickedGroupId.value = '';
+
+            //取消transformer
+            const transformerNode = transformer.value.getNode();
+            transformerNode.nodes([]);
+          })
+          .catch(() => {});
       }
       }
+
       const index = cameras.value.findIndex((item) => item.id === lastClickedGroupId.value);
       const index = cameras.value.findIndex((item) => item.id === lastClickedGroupId.value);
       index >= 0 && cameras.value.splice(index, 1);
       index >= 0 && cameras.value.splice(index, 1);
       lastClickedGroupId.value = '';
       lastClickedGroupId.value = '';
@@ -340,12 +361,25 @@
   /** 导入布局json */
   /** 导入布局json */
   const createMap = (layout) => {
   const createMap = (layout) => {
     addBg(layout.bgImgUrl).then((_res) => {
     addBg(layout.bgImgUrl).then((_res) => {
+      const unExitList = [] as any[];
       stageConfig.value = layout.stageConfig;
       stageConfig.value = layout.stageConfig;
       defaultCameraId.value = layout.defaultCameraId;
       defaultCameraId.value = layout.defaultCameraId;
-      layout.cameraList = layout.cameraList?.map((item) => {
-        item.config.image = camImg;
-        return item;
-      });
+      layout.cameraList = layout.cameraList
+        ?.map((item) => {
+          item.config.image = camImg;
+          return item;
+        })
+        ?.filter((cam) => {
+          if (shopCameraList.value.findIndex((x) => x.code === cam.code) >= 0) {
+            return true;
+          } else {
+            unExitList.push(cam.code);
+            return false;
+          }
+        });
+      if (unExitList.length > 0) {
+        ElMessage.warning('部分相机不存在,已为您删除!');
+      }
       cameras.value = layout.cameraList;
       cameras.value = layout.cameraList;
     });
     });
   };
   };