|
@ -1,40 +1,43 @@ |
|
|
<template> |
|
|
<template> |
|
|
<DataSearchBar @getDate="getDate" /> |
|
|
<SearchBar @search="getDate" /> |
|
|
<HistoryData ref="childRef" class="mt-4" /> |
|
|
<HistoryData ref="childRef" class="mt-4" /> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script setup> |
|
|
<script setup> |
|
|
import DataSearchBar from 'components/data-search-bar.vue'; |
|
|
import SearchBar from 'components/search-bar-data.vue'; |
|
|
import HistoryData from 'components/history-data.vue'; |
|
|
import HistoryData from 'components/history-data.vue'; |
|
|
import { computed, ref } from 'vue'; |
|
|
import { computed, ref } from 'vue'; |
|
|
import { useStore } from 'vuex'; |
|
|
import { useStore } from 'vuex'; |
|
|
|
|
|
import { getHistories } from 'apis/index'; |
|
|
|
|
|
|
|
|
const childRef = ref(null); |
|
|
const childRef = ref(null); |
|
|
|
|
|
|
|
|
let timer = null; |
|
|
let timer = null; |
|
|
|
|
|
const page = ref({ page: 2, size: 10 }); |
|
|
|
|
|
const data = ref(null); |
|
|
|
|
|
const search = ref({}); |
|
|
const store = useStore(); |
|
|
const store = useStore(); |
|
|
const token = computed(() => store.getters['user/token']); |
|
|
const token = computed(() => store.getters['user/token']); |
|
|
const realtimeData = computed(() => store.state.statistics.realtimeData); |
|
|
|
|
|
|
|
|
|
|
|
// 实时数据统计 |
|
|
// 实时数据统计 |
|
|
const getDate = async options => { |
|
|
const getDate = async () => { |
|
|
|
|
|
try { |
|
|
if (token) { |
|
|
if (token) { |
|
|
const params = { |
|
|
const params = { search: { ...search.value }, page: { page: page.value.page, size: page.value.size } }; |
|
|
deviceId: options && options.deviceId ? options.deviceId : '', // 站点 设备id |
|
|
const resData = await getHistories(params); |
|
|
date: options && options.date && options.date.length ? options.date : [], // 年月时间段 |
|
|
data.value = resData.data; |
|
|
sort: 1, // 1 -> 按时间正序 -1->按时间倒序 |
|
|
page.value = resData.page; |
|
|
page: 1, // 第几页 |
|
|
|
|
|
size: 10, // 每页多少条 |
|
|
|
|
|
}; |
|
|
|
|
|
await store.dispatch('statistics/getRealtimeData', params); |
|
|
|
|
|
timer && clearTimeout(timer); |
|
|
timer && clearTimeout(timer); |
|
|
timer = null; |
|
|
timer = null; |
|
|
childRef.value.changeDate(realtimeData.value); |
|
|
childRef.value.changeDate(data.value); |
|
|
} else { |
|
|
} else { |
|
|
timer = setTimeout(() => { |
|
|
timer = setTimeout(() => { |
|
|
getDate(); |
|
|
getDate(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.log('error: ', error); |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
getDate(); |
|
|
getDate(); |
|
|