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

Merge branch 'algoConfg-fix' into 'dev'

fix: checkValid校验报错bug

See merge request skyeye/skyeye_frontend/skyeye-admin!38
宏耀 孙 пре 1 година
родитељ
комит
a7d03fc5ce

+ 34 - 32
src/views/cameras/preview/components/AlgorithmsSetting/AlgoParamsCard.vue

@@ -149,17 +149,10 @@
       .map((item) => item.id);
   };
 
-  const algoParams = computed(() => {
-    const countList = getCriticalCounts(selectedAlgoDetail.value.extra);
-    const index = selectedAlgoDetail.value.metaValues.findIndex((item) => item.id === props.id);
-    if (index < 0) {
-      return {} as AlgoParamMetaItem;
-    } else {
-      const param = selectedAlgoDetail.value.metaValues[index];
-      param.criticalCount = countList && countList.length > index ? countList[index] : 0;
-      return param;
-    }
-  });
+  const algoParams = ref<AlgoParamMetaItem>(
+    selectedAlgoDetail.value.metaValues?.find((item) => item.id === props.id) ||
+      ({} as AlgoParamMetaItem),
+  );
 
   const paramItems = ref([
     { label: '', type: 'label', prop: 'label' },
@@ -172,28 +165,37 @@
     () => algoParams.value.label,
     (val) => {
       if (!val) return;
-      const meta = metaObjList.value.find((item) => item.label === val);
-      algoParams.value.confidence = meta.confidence * 100;
-      algoParams.value['min_width'] = meta['min_width'];
-      algoParams.value['min_height'] = meta['min_height'];
 
-      const nexts = meta.nextObjs;
-      if (nexts) {
-        for (let i = 0; i < nexts.length; i++) {
-          const item = nexts[i];
-          paramItems.value.push({
-            label: item.label,
-            type: 'confidence',
-            prop: `${item.label}.confidence`,
-          });
-          algoParams.value[`${item.label}.confidence`] = item.confidence * 100;
-          paramItems.value.push({
-            label: item.label,
-            type: 'minArea',
-            prop: '',
-          });
-          algoParams.value[item.label + '.' + 'min_width'] = item['min_width'];
-          algoParams.value[item.label + '.' + 'min_height'] = item['min_height'];
+      const index = selectedAlgoDetail.value.metaValues.findIndex((item) => item.label === val);
+      if (selectedAlgoDetail.value.metaValues[index]['min_width']) {
+        const countList = getCriticalCounts(selectedAlgoDetail.value.extra);
+        algoParams.value = selectedAlgoDetail.value.metaValues[index];
+        algoParams.value.criticalCount =
+          countList && countList.length > index ? countList[index] : 0;
+      } else {
+        const meta = metaObjList.value.find((item) => item.label === val);
+        algoParams.value.confidence = meta.confidence * 100;
+        algoParams.value['min_width'] = meta['min_width'];
+        algoParams.value['min_height'] = meta['min_height'];
+
+        const nexts = meta.nextObjs;
+        if (nexts) {
+          for (let i = 0; i < nexts.length; i++) {
+            const item = nexts[i];
+            paramItems.value.push({
+              label: item.label,
+              type: 'confidence',
+              prop: `${item.label}.confidence`,
+            });
+            algoParams.value[`${item.label}.confidence`] = item.confidence * 100;
+            paramItems.value.push({
+              label: item.label,
+              type: 'minArea',
+              prop: '',
+            });
+            algoParams.value[item.label + '.' + 'min_width'] = item['min_width'];
+            algoParams.value[item.label + '.' + 'min_height'] = item['min_height'];
+          }
         }
       }
     },

+ 8 - 5
src/views/cameras/preview/components/AlgorithmsSetting/AlgoSettingCard.vue

@@ -62,7 +62,7 @@
         <div class="algoTimeContent">
           <div
             class="timeAdd"
-            :class="{ addDisable: unEmptyLabels.length >= selectedAlgoDetail.metaValues.length }"
+            :class="{ addDisable: unEmptyLabels.length >= metaObjList.length }"
             @click="handleAddMetaObj"
           >
             <el-icon color="#d0d0d0"><Plus /></el-icon>
@@ -251,8 +251,10 @@
       ElMessage.error('请完善检测时间段');
       return;
     }
+
     for (let i = 0; i < periodCardRefs.value.length; i++) {
       const item = periodCardRefs.value[i];
+      if (!item) continue;
       switch (item.checkValid()) {
         case 0:
           ElMessage.error('请正确填写检测时间段');
@@ -271,6 +273,7 @@
     //判断元数据是否合格
     for (let i = 0; i < paramCardRefs.value.length; i++) {
       const item = paramCardRefs.value[i];
+      if (!item) continue;
       const res = await item.checkValid();
       if (res) {
       } else {
@@ -299,8 +302,8 @@
       const val = {
         label: meta.label,
         confidence: meta.confidence / 100,
-        'min_width': meta['min_width'],
-        'min_height': meta['min_height'],
+        min_width: meta['min_width'],
+        min_height: meta['min_height'],
       } as any;
       const nextValues = [] as any[];
       obj.nextObjs.forEach((next) => {
@@ -308,8 +311,8 @@
           nextValues.push({
             label: next.label,
             confidence: meta[`${next.label}.confidence`] / 100,
-            'min_width': meta[next.label + '.' + 'min_width'],
-            'min_height': meta[next.label + '.' + 'min_height'],
+            min_width: meta[next.label + '.' + 'min_width'],
+            min_height: meta[next.label + '.' + 'min_height'],
             nextObjs: [],
           });
         }

+ 1 - 1
src/views/cameras/preview/store/useCameraAlgoStore.ts

@@ -68,7 +68,7 @@ const useCameraAlgoStore = defineStore('cameraAlgo', () => {
 
   //计算原始模板数据
   const metaObjList = computed(() => {
-    const extra = selectedAlgoDetail.value?.extra;
+    const extra = selectedAlgoDetail.value.algoInfo?.extra;
     if (!extra) return [];
     const extraObj = JSON.parse(extra);
     const params = extraObj?.inferParams;