Эх сурвалжийг харах

feat: 设备列表最后离开时间改为活动状态;设备详情告警计划弹窗交互优化;

liujia 1 сар өмнө
parent
commit
e708aba

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

@@ -15,7 +15,7 @@
         :label-col="{ style: { width: '80px' } }"
         hideRequiredMark
       >
-        <a-form-item v-if="props.type === 'plan'" label="计划模板" name="planName">
+        <a-form-item v-if="props.type === 'plan'" label="计划模板">
           <div style="display: flex; align-items: center; gap: 8px">
             <a-select
               v-model:value="planTemplateId"
@@ -56,7 +56,7 @@
 
         <a-form-item
           label="计划备注"
-          name="planName"
+          name="remark"
           :rules="[{ required: true, message: '请输入计划备注' }]"
         >
           <a-input
@@ -767,7 +767,10 @@ const echoFormState = (val: SourceData) => {
     thresholdTime: typeof val.thresholdTime === 'number' ? val.thresholdTime : null,
     mergeTime: typeof val.mergeTime === 'number' ? val.mergeTime : null,
     eventType: val.eventVal ?? null,
-    statisticsTime: [paramObj.start_time ?? null, paramObj.end_time ?? null] as string[],
+    statisticsTime:
+      paramObj?.start_time && paramObj?.end_time
+        ? ([paramObj.start_time, paramObj.end_time] as string[])
+        : [],
     count: paramObj.count ?? null,
     timeThreshold: paramObj.time_threshold ?? null,
     planTime: planTimes,

+ 3 - 3
src/views/device/list/const.ts

@@ -22,9 +22,9 @@ export const columns = [
     align: 'center',
   },
   {
-    title: '最后离开时间',
-    key: 'lastTargetTime',
-    dataIndex: 'lastTargetTime',
+    title: '活动状态',
+    key: 'activeState',
+    dataIndex: 'activeState',
     align: 'center',
     width: 200,
   },

+ 18 - 0
src/views/device/list/index.vue

@@ -76,6 +76,12 @@
             <a-tag v-if="record.online === 0" :bordered="false" color="red">离线</a-tag>
             <a-tag v-if="record.online === 1" :bordered="false" color="green">在线</a-tag>
           </template>
+          <template v-if="column.key === 'activeState'">
+            <a-tag v-if="isToday(record.presenceChangeTime)" :bordered="false" color="green"
+              >有</a-tag
+            >
+            <a-tag v-else :bordered="false" color="#ccc">无</a-tag>
+          </template>
           <template v-if="column.key === 'action'">
             <a-button type="link" @click="detailHandler(record.devId, record.clientId)"
               >查看详情</a-button
@@ -395,6 +401,18 @@ const uploadDeviceHandler = () => {
   console.log('批量上传设备')
   uploadDeviceOpen.value = true
 }
+
+// 是否为今天
+function isToday(dateStr: string): boolean {
+  const inputDate = new Date(dateStr)
+  const now = new Date()
+
+  return (
+    inputDate.getFullYear() === now.getFullYear() &&
+    inputDate.getMonth() === now.getMonth() &&
+    inputDate.getDate() === now.getDate()
+  )
+}
 </script>
 
 <style scoped lang="less">