瀏覽代碼

fix: 部分文案和criticalCount转化

sunhongyao341504 1 年之前
父節點
當前提交
2d79ea0f3d

二進制
public/favicon.ico


+ 1 - 0
src/views/cameras/preview/components/AlgorithmsSetting/AddAlgoDialog.vue

@@ -81,6 +81,7 @@
       getCameraAlgoList(cameraDetailStore.cameraId);
       visible.value = false;
       ElMessage.success('添加成功,请完成算法参数配置后生效');
+      visible.value = false;
     });
   };
 

+ 14 - 8
src/views/cameras/preview/components/AlgorithmsSetting/AlgoParamsCard.vue

@@ -31,10 +31,10 @@
           <ElInputNumber
             v-model="algoParams[item.prop]"
             controls-position="right"
-            :min="0"
             :step="1"
             style="width: 186px; margin-right: 5px"
             :disabled="!algoParams.label"
+            placeholder="请输入检测数量"
           />
         </el-form-item>
         <el-form-item
@@ -115,6 +115,7 @@
   import { Delete, Edit } from '@element-plus/icons-vue';
   import { SaveOutline } from '@vicons/ionicons5';
   import { labelNameMap } from './types';
+  import { getCriticalCounts } from './utils';
 
   const props = defineProps<{
     id: string;
@@ -147,11 +148,17 @@
       .map((item) => item.id);
   };
 
-  const algoParams = computed(
-    () =>
-      selectedAlgoDetail.value.metaValues.find((item) => item.id === props.id) ||
-      ({} as AlgoParamMetaItem),
-  );
+  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 paramItems = ref([
     { label: '', type: 'label', prop: 'label' },
@@ -165,7 +172,6 @@
     (val) => {
       if (!val) return;
       const meta = metaObjList.value.find((item) => item.label === val);
-      algoParams.value.criticalCount = 0;
       algoParams.value.confidence = meta.confidence * 100;
       algoParams.value['min-width'] = meta['min-width'];
       algoParams.value['min-height'] = meta['min-height'];
@@ -208,7 +214,7 @@
         ];
       }
       if (param.type === 'criticalCount') {
-        rule[`${param.label}.criticalCount`] = [
+        rule[`${param.label}${param.label ? '.' : ''}criticalCount`] = [
           {
             required: true,
             message: '请输入检测数量',

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

@@ -29,7 +29,11 @@
             <!-- <span style="font-size: 10px; margin-left: 20px; color: #262626"
               >备注:请绘制电子围栏</span
             > -->
-            <el-radio-group v-model="selectedAlgoDetail.regionJudge" class="ml-4">
+            <el-radio-group
+              v-model="selectedAlgoDetail.regionJudge"
+              :disabled="!selectedAlgoDetail.electronicFenceBool"
+              class="ml-3"
+            >
               <el-radio :label="0">内</el-radio>
               <el-radio :label="1">外</el-radio>
             </el-radio-group>
@@ -106,6 +110,7 @@
           :min="1"
           size="small"
           style="width: 186px"
+          placeholder="请输入允许的最长时间"
         />
         <span style="font-size: 12px; margin-left: 5px">S</span>
       </div>
@@ -283,10 +288,10 @@
     const detail = selectedAlgoDetail.value;
     if (!detail) return;
     const timeRanges = detail.timeRangeArr;
-    if (timeRanges.length == 0) {
-      ElMessage.error('至少添加一个检测时间段');
-      return;
-    }
+    // if (timeRanges.length == 0) {
+    //   ElMessage.error('至少添加一个检测时间段');
+    //   return;
+    // }
     const metaValues = detail.metaValues;
     if (metaValues.length == 0) {
       ElMessage.error('至少添加一个检测元数据');

+ 8 - 0
src/views/cameras/preview/components/AlgorithmsSetting/utils.ts

@@ -104,6 +104,14 @@ export const getInferCode = (extra: string | undefined | null) => {
   return extraObj?.inferCode || '';
 };
 
+export const getCriticalCounts = (extra: string | undefined | null) => {
+  if (!extra) return [];
+  const extraObj = JSON.parse(extra);
+  const infers = extraObj?.inferParams;
+  if (!infers || infers.length === 0) return [];
+  return infers[0]?.criticalCounts || [];
+};
+
 export const getExtraCommonInfo = (detail: CameraAlgoItem | undefined | null) => {
   if (!detail) return {};
   let extraValue = getCommonInfo(detail.extra);