Просмотр исходного кода

feat: 设备配置新增坐摔参数配置与回显;

liujia 3 недель назад
Родитель
Сommit
0526495755
2 измененных файлов с 170 добавлено и 0 удалено
  1. 16 0
      src/api/device/types.ts
  2. 154 0
      src/views/device/detail/components/deviceBaseConfig/index.vue

+ 16 - 0
src/api/device/types.ts

@@ -217,6 +217,14 @@ export interface DeviceDetailData {
   updateTime: string // 修改时间
   age: ID // 监护对象年龄
   guardianshipType: ID // 监护对象类型
+  fallSettingEnabled?: SwitchType // 是否开启坐摔检测,1:开启,0:关闭
+  lowHighSnrRatio?: number | null // 目标低部分的信噪比与高部分的信信噪比之比
+  lowMidSnrRatio?: number | null // 目标低部分信噪比与中间部分信噪比对
+  lowSnrThr?: number | null // 启动ToG事件的阈值
+  lowZMax?: number | null // 检测到坐摔的最低Z轴高度,范围0.1-2.5,单位m (坐摔最低高度)
+  humanPredThreshold?: number | null // 判断当前是否坐摔的门限值 (坐摔最低高度)
+  minEventsForDetection?: number | null // 最小连续多次的满足坐摔检测才会触发坐摔判断,范围 1-100 (坐摔判断阈值)
+  minHumanEventsForDetection?: number | null // 最小连续多次的满足坐摔检测才会触发坐摔检测状态改变,范围 1-100 (坐摔判断阈值)
 }
 
 /**
@@ -259,6 +267,14 @@ export interface UpdateDeviceParams {
   fallingConfirm?: ID // 设备跌倒确认时间 通常180s
   age?: number | null // 监护对象年龄
   guardianshipType?: string | null // 监护对象类型
+  fallSettingEnabled?: SwitchType // 是否开启坐摔检测,1:开启,0:关闭
+  lowHighSnrRatio?: number | null // 目标低部分的信噪比与高部分的信信噪比之比
+  lowMidSnrRatio?: number | null // 目标低部分信噪比与中间部分信噪比对
+  lowSnrThr?: number | null // 启动ToG事件的阈值
+  lowZMax?: number | null // 检测到坐摔的最低Z轴高度,范围0.1-2.5,单位m (坐摔最低高度)
+  humanPredThreshold?: number | null // 判断当前是否坐摔的门限值 (坐摔最低高度)
+  minEventsForDetection?: number | null // 最小连续多次的满足坐摔检测才会触发坐摔判断,范围 1-100 (坐摔判断阈值)
+  minHumanEventsForDetection?: number | null // 最小连续多次的满足坐摔检测才会触发坐摔检测状态改变,范围 1-100 (坐摔判断阈值)
 }
 
 /**

+ 154 - 0
src/views/device/detail/components/deviceBaseConfig/index.vue

@@ -235,6 +235,86 @@
         </a-select>
       </a-form-item>
 
+      <a-form-item label="坐摔检测开关" name="fallSwitch">
+        <a-switch v-model:checked="baseFormState.fallSwitch" />
+      </a-form-item>
+
+      <a-form-item v-if="baseFormState.fallSwitch" label="坐摔最低高度" name="fallHeightThreshold">
+        <a-input
+          v-model:value.trim="baseFormState.fallHeightThreshold"
+          placeholder="请输入坐摔最低高度"
+          :style="inputStyle"
+        >
+          <template #suffix>
+            <a-tooltip>
+              <template #title>
+                <div>参考范围:0.1 - 2.5 m</div>
+              </template>
+              <info-circle-outlined style="color: rgba(0, 0, 0, 0.45)" />
+            </a-tooltip>
+          </template>
+        </a-input>
+      </a-form-item>
+      <a-form-item
+        v-if="baseFormState.fallSwitch"
+        label="坐摔门限值"
+        name="fallConfidenceThreshold"
+      >
+        <a-input
+          v-model:value.trim="baseFormState.fallConfidenceThreshold"
+          placeholder="请输入坐摔门限值"
+          :style="inputStyle"
+          :disabled="!baseFormState.fallSwitch"
+        >
+          <template #suffix>
+            <a-tooltip>
+              <template #title>
+                <div>参考范围:1 - 100</div>
+              </template>
+              <info-circle-outlined style="color: rgba(0, 0, 0, 0.45)" />
+            </a-tooltip>
+          </template>
+        </a-input>
+      </a-form-item>
+      <a-form-item v-if="baseFormState.fallSwitch" label="坐摔判断阈值" name="fallTriggerCount">
+        <a-input
+          v-model:value.trim="baseFormState.fallTriggerCount"
+          placeholder="请输入坐摔判断阈值"
+          :style="inputStyle"
+          :disabled="!baseFormState.fallSwitch"
+        >
+          <template #suffix>
+            <a-tooltip>
+              <template #title>
+                <div>参考范围:1 -100</div>
+              </template>
+              <info-circle-outlined style="color: rgba(0, 0, 0, 0.45)" />
+            </a-tooltip>
+          </template>
+        </a-input>
+      </a-form-item>
+      <a-form-item
+        v-if="baseFormState.fallSwitch"
+        label="坐摔状态阈值"
+        name="fallStatusChangeCount"
+      >
+        <a-input
+          v-model:value.trim="baseFormState.fallStatusChangeCount"
+          placeholder="请输入坐摔状态阈值"
+          :style="inputStyle"
+          :disabled="!baseFormState.fallSwitch"
+        >
+          <template #suffix>
+            <a-tooltip>
+              <template #title>
+                <div>参考范围:1 - 100</div>
+              </template>
+              <info-circle-outlined style="color: rgba(0, 0, 0, 0.45)" />
+            </a-tooltip>
+          </template>
+        </a-input>
+      </a-form-item>
+
       <div class="footer" :style="{ marginLeft: '100px' }">
         <a-space>
           <a-button
@@ -298,6 +378,11 @@ interface BaseFormState {
   fallingConfirm: ID // 跌倒确认
   guardAge?: ID // 监护对象年龄
   guardType?: ID // 监护对象类型
+  fallSwitch?: boolean // 坐摔检测开关
+  fallHeightThreshold?: ID // 坐摔最低高度阈值(米)
+  fallConfidenceThreshold?: ID // 坐摔门限阈值
+  fallTriggerCount?: ID // 坐摔判断触发次数
+  fallStatusChangeCount?: ID // 坐摔状态变更触发次数
 }
 
 const spinning = ref(false)
@@ -317,6 +402,11 @@ const baseFormState = reactive<BaseFormState>({
   fallingConfirm: 53,
   guardAge: null,
   guardType: null,
+  fallSwitch: false,
+  fallHeightThreshold: null,
+  fallConfidenceThreshold: null,
+  fallTriggerCount: null,
+  fallStatusChangeCount: null,
 })
 
 // 范围输入框尺寸
@@ -359,6 +449,28 @@ const saveBaseConfig = async () => {
               : null,
           age: baseFormState?.guardAge ? Number(baseFormState?.guardAge) : null,
           guardianshipType: baseFormState?.guardType ? String(baseFormState?.guardType) : null,
+          fallSettingEnabled:
+            baseFormState?.fallSwitch && baseFormState?.fallSwitch === true ? 1 : 0,
+          lowZMax: baseFormState?.fallSwitch
+            ? Number(baseFormState?.fallHeightThreshold) > 0
+              ? Number(baseFormState?.fallHeightThreshold)
+              : null
+            : null,
+          humanPredThreshold: baseFormState?.fallSwitch
+            ? Number(baseFormState?.fallConfidenceThreshold) > 0
+              ? Number(baseFormState?.fallConfidenceThreshold)
+              : null
+            : null,
+          minEventsForDetection: baseFormState?.fallSwitch
+            ? Number(baseFormState?.fallTriggerCount) > 0
+              ? Number(baseFormState?.fallTriggerCount)
+              : null
+            : null,
+          minHumanEventsForDetection: baseFormState?.fallSwitch
+            ? Number(baseFormState?.fallStatusChangeCount) > 0
+              ? Number(baseFormState?.fallStatusChangeCount)
+              : null
+            : null,
         })
         saveBaseLoading.value = false
         message.success('保存成功')
@@ -405,6 +517,19 @@ const saveBaseConfig = async () => {
 //   }
 // }
 
+const numberValidator = (_rule: Rule, value: string) => {
+  console.log('numberValidator', _rule, value)
+  if (!value) return Promise.resolve()
+
+  const validPattern = /^\d+(\.\d{1,2})?$/
+
+  if (!validPattern.test(value)) {
+    return Promise.reject(new Error('只能输入数字,保留两位小数'))
+  }
+
+  return Promise.resolve()
+}
+
 // 统一校验规则
 const rules: Record<string, Rule[]> = {
   installWay: [
@@ -432,6 +557,30 @@ const rules: Record<string, Rule[]> = {
       trigger: ['change', 'blur'],
     },
   ],
+  fallHeightThreshold: [
+    {
+      validator: numberValidator,
+      trigger: ['change', 'blur'],
+    },
+  ],
+  fallConfidenceThreshold: [
+    {
+      validator: numberValidator,
+      trigger: ['change', 'blur'],
+    },
+  ],
+  fallTriggerCount: [
+    {
+      validator: numberValidator,
+      trigger: ['change', 'blur'],
+    },
+  ],
+  fallStatusChangeCount: [
+    {
+      validator: numberValidator,
+      trigger: ['change', 'blur'],
+    },
+  ],
   // xRangeStart: [
   //   {
   //     required: true,
@@ -534,6 +683,11 @@ const fetchDeviceBaseInfo = async () => {
     baseFormState.fallingConfirm = res.data.fallingConfirm
     baseFormState.guardAge = res.data.age
     baseFormState.guardType = res.data.guardianshipType
+    baseFormState.fallSwitch = Boolean(res.data.fallSettingEnabled) ?? false
+    baseFormState.fallHeightThreshold = res.data.lowZMax ?? null
+    baseFormState.fallConfidenceThreshold = res.data.humanPredThreshold ?? null
+    baseFormState.fallTriggerCount = res.data.minEventsForDetection ?? null
+    baseFormState.fallStatusChangeCount = res.data.minHumanEventsForDetection ?? null
   } catch (error) {
     console.error('❌获取设备详情失败', error)
   }