Переглянути джерело

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

louhangfei 1 рік тому
батько
коміт
04a2c3f67e

+ 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;
       });
   };