Browse Source

fix(设备详情): 修复告警计划区域数据格式和类型定义

修正告警计划提交时区域数据格式,将空数组改为字符串'[]'以保持类型一致
添加AlarmPlan类型定义并完善组件中的类型声明
liujia 1 month ago
parent
commit
36ce34c

+ 1 - 1
src/views/device/detail/components/alarmPlanModal/index.vue

@@ -795,7 +795,7 @@ const submit = () => {
         param: JSON.stringify(paramData), // 事件参数 与 eventVal 有联动关系
         region: [1, 2, 3, 9].includes(formState.eventType as number)
           ? JSON.stringify(formState.region)
-          : [], // 检测区域
+          : '[]', // 检测区域
         enable: Number(formState.enable) as 0 | 1, // 是否启用 0否 1是
 
         // 生效方式

+ 33 - 2
src/views/device/detail/index.vue

@@ -250,7 +250,7 @@
                         :loading="plan.loading"
                         @click="swtichAlarmItem(plan.id, plan.enable, plan)"
                       />
-                      <EditOutlined @click="editAlarmItem(plan.data)" />
+                      <EditOutlined @click="editAlarmItem(plan.data as AlarmPlanItem)" />
                       <DeleteOutlined @click="deleteAlarmItem(plan.id)" />
                     </a-space>
                   </div>
@@ -293,7 +293,7 @@
         v-model:open="alarmPlanVisible"
         :client-id="clientId"
         :alarm-plan-id="alarmPlanId"
-        :data="alarmPlanData"
+        :data="alarmPlanData as AlarmPlan"
         :area="{
           width: (detailState.width as number) ?? 0,
           height: (detailState.length as number) ?? 0,
@@ -697,6 +697,37 @@ const fetchAlarmPlanList = async () => {
 }
 fetchAlarmPlanList()
 
+type AlarmPlan = {
+  id: number
+  uuid: ID
+  name: string
+  clientId: string
+  enable: SwitchType
+  region: string
+  eventVal: number
+  alarmTimePlanId: ID
+  thresholdTime: ID
+  mergeTime: ID
+  param: string
+  createTime: string
+  updateTime: string
+  remark: string | null
+  alarmTimePlan: {
+    createId: ID
+    updateId: ID
+    createTime: ID
+    updateTime: ID
+    isDeleted: SwitchType | null
+    remark: ID
+    id: ID
+    startDate: string
+    stopDate: string
+    timeRange: string
+    monthDays: string
+    weekdays: string
+  }
+}
+
 interface AlarmPlanItem {
   id?: number
   loading?: boolean