forked from drone/command-center-dashboard

chenyao
2025-04-15 828f2f412b36e03384d62874d3283f05afa7d4ea
src/views/Home/EventOverviewDetail/EventOverviewDetailRight.vue
@@ -114,11 +114,17 @@
import cesiumOperation from '@/utils/cesium-tsa'
import CommonTitle from '@/components/CommonTitle.vue'
import { pxToRem } from '@/utils/rem'
import { useStore } from 'vuex'
const store = useStore()
// const eventTimeRange = computed(() => store.state.home.eventTimeRange)
const timeFormat = 'YYYY-MM-DD HH:mm:ss'
const today = dayjs().format(timeFormat)
const oneWeekAgo = dayjs().subtract(7, 'day').format(timeFormat)
const timeArr = ref([oneWeekAgo, today])
// const oneWeekAgo = dayjs().subtract(7, 'day').format(timeFormat)
// const timeArr = ref([oneWeekAgo, today])
const startOfWeek = dayjs().startOf('week').add(1, 'day').format(timeFormat)
const endOfWeek = dayjs().endOf('week').add(1, 'day').format(timeFormat)
const timeArr = ref([startOfWeek, endOfWeek])
const deviceList = ref([])
const total = ref(0)
@@ -211,6 +217,8 @@
   const [start_date, end_date] = timeArr.value
   params.value.start_date = start_date
   params.value.end_date = end_date
   // 提交数据,更新聚合
   store.commit('setEventTimeRang', timeArr.value);
   // 重置
   getEventStatusNumFun()
   getEventList()
@@ -237,6 +245,24 @@
   })
}
const getDateRange = unit => {
  if (unit === 'today') {
    return [dayjs().format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')];
  }
  return [dayjs().startOf(unit).format('YYYY-MM-DD HH:mm:ss'), dayjs().endOf(unit).format('YYYY-MM-DD HH:mm:ss')];
};
// 监听事件时间范围变化
watch(() => store.state.home.eventTimeType, (newVal) => {
   timeArr.value = getDateRange(newVal);
   const [start_date, end_date] = getDateRange(newVal);
   params.value.start_date = start_date
   params.value.end_date = end_date
   getEventStatusNumFun()
   getEventList()
   getList()
}, { immediate: false,deep: true })
onMounted(() => {
   getDeviceList()
   getDictList()