Browse Source

feat: 设备详情新增历史进出时间统计查看;

liujia 3 tuần trước cách đây
mục cha
commit
bae940d525

+ 18 - 0
src/views/device/detail/components/deviceStatsDrawer/const.ts

@@ -86,3 +86,21 @@ export const onlineColumns = [
     width: 150,
   },
 ]
+
+// 进出记录
+export const inoutColumns = [
+  {
+    title: '进入时间',
+    dataIndex: 'enterTime',
+    key: 'enterTime',
+    align: 'center',
+    width: 150,
+  },
+  {
+    title: '离开时间',
+    dataIndex: 'leaveTime',
+    key: 'leaveTime',
+    align: 'center',
+    width: 150,
+  },
+]

+ 40 - 4
src/views/device/detail/components/deviceStatsDrawer/index.vue

@@ -13,6 +13,7 @@
         <a-radio-button value="fall">跌倒统计</a-radio-button>
         <a-radio-button value="alarm">告警统计</a-radio-button>
         <a-radio-button value="online">上下线记录</a-radio-button>
+        <a-radio-button value="inout">历史进出记录</a-radio-button>
       </a-radio-group>
     </template>
 
@@ -108,12 +109,13 @@
 <script setup lang="ts">
 import { computed, ref, watch } from 'vue'
 import { useSearch } from '@/hooks/useSearch'
-import { fallColumns, alarmColumns, onlineColumns } from './const'
+import { fallColumns, alarmColumns, onlineColumns, inoutColumns } from './const'
 import * as statsApi from '@/api/stats'
 import type {
   StatsFallQueryDataRow,
   StatsAlarmQueryDataRow,
   StatsDeviceOnlineQueryDataRow,
+  StatsInoutHistoryQueryDataRow,
 } from '@/api/stats/types'
 import { useDict, type DictItem } from '@/hooks/useDict'
 import { useDictName } from '@/hooks/useDictName'
@@ -131,7 +133,7 @@ type Props = {
   clientId: string
   title?: string
   width?: number
-  type?: 'fall' | 'alarm' | 'online'
+  type?: 'fall' | 'alarm' | 'online' | 'inout'
 }
 
 const emit = defineEmits<{
@@ -148,13 +150,15 @@ const props = withDefaults(defineProps<Props>(), {
 })
 
 // 表格统计类型展示 跌倒、一般滞留、异常滞留
-const tableType = ref<'fall' | 'alarm' | 'online'>('fall')
+const tableType = ref<'fall' | 'alarm' | 'online' | 'inout'>('fall')
 
 const columns = computed(() => {
   if (tableType.value === 'alarm') {
     return alarmColumns
   } else if (tableType.value === 'online') {
     return onlineColumns
+  } else if (tableType.value === 'inout') {
+    return inoutColumns
   } else {
     return fallColumns
   }
@@ -232,7 +236,11 @@ const alarmEventTypeOptions = computed(() => [
   })),
 ])
 
-type TableList = StatsFallQueryDataRow | StatsAlarmQueryDataRow | StatsDeviceOnlineQueryDataRow
+type TableList =
+  | StatsFallQueryDataRow
+  | StatsAlarmQueryDataRow
+  | StatsDeviceOnlineQueryDataRow
+  | StatsInoutHistoryQueryDataRow
 const tableList = ref<TableList[]>([])
 const tableTotal = ref<number>(0)
 const current = ref<number>(1)
@@ -241,6 +249,7 @@ const pageSize = ref<number>(10)
 const fallList = ref<StatsFallQueryDataRow[]>([])
 const alarmList = ref<StatsAlarmQueryDataRow[]>([])
 const onlineList = ref<StatsDeviceOnlineQueryDataRow[]>([])
+const inoutList = ref<StatsInoutHistoryQueryDataRow[]>([])
 
 // 搜索
 const searchHandler = async () => {
@@ -345,6 +354,30 @@ const fetchOnlineList = async () => {
   }
 }
 
+// 获取历史进出记录
+const fetchInOutList = async () => {
+  console.log('🚀🚀🚀fetchInOutList')
+  try {
+    loading.value = true
+    const res = await statsApi.statsInoutHistoryQuery({
+      pageNo: current.value,
+      pageSize: pageSize.value,
+      devId: props.devId,
+      createTimeStart: searchState.createTimeStart,
+      createTimeEnd: searchState.createTimeEnd,
+    })
+    console.log('✅ 获取历史进出记录数据成功', res)
+    const { rows, total } = res.data
+    inoutList.value = rows as StatsInoutHistoryQueryDataRow[]
+    tableList.value = inoutList.value
+    tableTotal.value = Number(total)
+    loading.value = false
+  } catch (error) {
+    console.error('❌ 获取历史进出记录数据失败', error)
+    loading.value = false
+  }
+}
+
 const fetchList = () => {
   if (tableType.value === 'fall') {
     fetchFallList()
@@ -355,6 +388,9 @@ const fetchList = () => {
   if (tableType.value === 'online') {
     fetchOnlineList()
   }
+  if (tableType.value === 'inout') {
+    fetchInOutList()
+  }
 }
 
 watch(