forked from drone/command-center-dashboard

chenyao
2025-04-15 828f2f412b36e03384d62874d3283f05afa7d4ea
src/hooks/useMapAggregation/useMapAggregation.js
@@ -13,6 +13,7 @@
import cesiumOperation from '@/utils/cesium-tsa'
import { getDeviceRegion, getDeviceRegionCount, getEventDetails, getMapEvents } from '@/api/home/aggregation'
import { PolyGradientMaterial } from '@/utils/cesium/Material'
import { start } from 'nprogress'
/**
 * 机巢聚合功能
 */
@@ -53,6 +54,8 @@
  const store = useStore()
  const userAreaCode = computed(() => store.state.user.userInfo.detail.areaCode)
  const selectedAreaCode = computed(() => store.state.user.selectedAreaCode)
  let saveAreaCode = null;
  let saveParams = { area_code: '',date_enum:'CURRENT_WEEK' };
  // 确定缩放比例
@@ -105,6 +108,7 @@
  // 事件散点
  let eventList = []
  function processChildren (childrens) {
    // console.log(childrens, '事件点')
    return (childrens || []).map(item => {
      const arr = processChildren(item.childrens)
      if (item.data) {
@@ -118,13 +122,15 @@
      if (arr.length !== 0) {
        returnObj.childrens = arr
      }
      console.log(returnObj, '111111')
      return returnObj
    })
  }
  // 获取事件聚合
  function getMapEventCount (area_code) {
    return getMapEvents({ area_code,date_enum:'CURRENT_WEEK' }).then(res => {
  function getMapEventCount (params) {
    console.log(5555555)
    return getMapEvents(params).then(res => {
      const resData = res?.data?.data
      if (resData?.data) {
        eventList = resData?.data
@@ -163,7 +169,10 @@
  const initMapData = async areaCode => {
    eventList = []
    if (!areaCode) return
    const list = type === 'device' ? await getDeviceCount(areaCode) : await getMapEventCount(areaCode)
    saveAreaCode = areaCode;
    saveParams.area_code = areaCode;
    console.log(type, '444')
    const list = type === 'device' ? await getDeviceCount(areaCode) : await getMapEventCount(saveParams)
    const splashedList = type === 'device'
      ? await getDeviceList(areaCode)
      : eventList.map(i => ({ eventId: i.id, latitude: Number(i.latitude), longitude: Number(i.longitude), type: 'event' }))
@@ -235,6 +244,23 @@
    { deep: true }
  )
  // 监听 日 周 月 年
  watch(() => store.state.home.eventTimeType, (newVal) => {
    if (!saveAreaCode) return
    if (newVal) {
      saveParams = { area_code:saveAreaCode,date_enum: store.state.home.eventTimeParams }
      initMapData(saveAreaCode);
    }
  });
  // 监听事件右侧日期范围
  watch(() => store.state.home.eventTimeRang, (newVal) => {
    if (!saveAreaCode) return
    if (newVal) {
      saveParams = { area_code:saveAreaCode,start_date: newVal[0], end_date: newVal[1]}
      initMapData(saveAreaCode);
    }
  });
  //散点机巢
  function splashed (row) {
    row.splashedList.forEach((item, index) => {