Explorar o código

Merge branch 'all-v4-lhf' into 'all-v4'

fix: 切换到其他预置位时要把currentFenceGroupId清空

See merge request skyeye/skyeye_frontend/skyeye-admin!404
楼航飞 hai 1 ano
pai
achega
bfbb7208aa

+ 4 - 3
src/modules/algo-params-setting-base/store/useFenceStore.ts

@@ -32,8 +32,9 @@ export const useFenceStore = defineStore('fencePolygonStore', () => {
     if (!param.algoId || !param.cameraId || !param.presetToken) return;
     return getFenceApi(param)
       .then((res) => {
-        const fence = res.electronicFencePolygon
-          ? (JSON.parse(res.electronicFencePolygon) as [])
+        currentFenceGroupId.value = res?.id;
+        const fence = res?.electronicFencePolygon
+          ? (JSON.parse(res?.electronicFencePolygon) as [])
           : ([] as { polygon: string }[]);
         // const pointsJSON = points.poly
         const newFence = fence.map((x) => {
@@ -41,7 +42,6 @@ export const useFenceStore = defineStore('fencePolygonStore', () => {
         }) as unknown as ServerLineInfos;
         allFences.value = newFence;
         initialFence.value = newFence;
-        currentFenceGroupId.value = res.id;
       })
       .catch(() => {
         currentFenceId.value = null;
@@ -49,6 +49,7 @@ export const useFenceStore = defineStore('fencePolygonStore', () => {
       })
       .finally(() => {
         loading.value = false;
+        currentFenceId.value = null;
       });
   };