瀏覽代碼

调整样式,增加删除和保存disabled功能

louhangfei 2 年之前
父節點
當前提交
42522d8862

+ 1 - 0
package.json

@@ -52,6 +52,7 @@
     "lodash-es": "4.17.21",
     "mockjs": "1.1.0",
     "nprogress": "0.2.0",
+    "number-precision": "1.6.0",
     "perfect-scrollbar": "1.5.5",
     "pinia": "2.0.16",
     "print-js": "1.6.0",

+ 7 - 0
pnpm-lock.yaml

@@ -68,6 +68,9 @@ dependencies:
   nprogress:
     specifier: 0.2.0
     version: 0.2.0
+  number-precision:
+    specifier: ^1.6.0
+    version: 1.6.0
   perfect-scrollbar:
     specifier: 1.5.5
     version: 1.5.5
@@ -5439,6 +5442,10 @@ packages:
       boolbase: 1.0.0
     dev: true
 
+  /number-precision@1.6.0:
+    resolution: {integrity: sha512-05OLPgbgmnixJw+VvEh18yNPUo3iyp4BEWJcrLu4X9W05KmMifN7Mu5exYvQXqxxeNWhvIF+j3Rij+HmddM/hQ==}
+    dev: false
+
   /nwsapi@2.2.7:
     resolution: {integrity: sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==}
     requiresBuild: true

+ 4 - 3
src/views/cameras/preview/components/AlgorithmsSetting/AlgoSettingCard.vue

@@ -54,7 +54,6 @@
           :min="0"
           size="small"
           style="width: 80px"
-          :precision="0"
         />
         <ElSelect size="small" style="width: 60px; margin-left: 10px" v-model="detectionUnit">
           <ElOption
@@ -67,8 +66,10 @@
         <span style="font-size: 12px; margin-left: 5px">/次</span>
       </div>
       <div style="display: flex; justify-content: flex-end">
-        <ElButton size="small" @click="handleRemoveAlgo">删除</ElButton>
-        <ElButton size="small" type="primary" @click="handleSave">保存</ElButton>
+        <ElButton size="small" @click="handleRemoveAlgo" :disabled="!selectedAlgoId">删除</ElButton>
+        <ElButton size="small" type="primary" @click="handleSave" :disabled="!selectedAlgoId"
+          >保存</ElButton
+        >
       </div>
     </div>
   </div>

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

@@ -8,7 +8,7 @@
 </script>
 <style scoped>
   .tagWrapper {
-    margin: 10px;
+    margin: 10px 0;
     cursor: pointer;
   }
 </style>

+ 3 - 1
src/views/cameras/preview/components/AlgorithmsSetting/utils.ts

@@ -1,5 +1,7 @@
 import dayjs, { Dayjs } from 'dayjs';
 import { uid } from 'uid';
+import NP from 'number-precision';
+
 import { TimeRangeItem } from './types';
 
 export const createDefaultTime = (): TimeRangeItem => {
@@ -23,7 +25,7 @@ export const getDetectionJSON = (time: number | undefined | null) => {
     for (let i = frequencyOptions.length - 1; i >= 0; i--) {
       const unit = frequencyOptions[i].value;
       if (time >= unit) {
-        return { detectionNum: Math.floor(time / unit), detectionUnit: unit };
+        return { detectionNum: NP.divide(time, unit), detectionUnit: unit };
       }
     }
   }