riku
2025-05-13 6c75516f1ba668873807cef33aa996d25cdf16c4
src/views/realtimemode/RealtimeMode.vue
@@ -14,6 +14,7 @@
        class="m-t-2"
        :factor="factorDatas.factor[factorType]"
      ></FactorLegend>
      <!-- <SourceTrace></SourceTrace> -->
    </el-row>
    <DashBoard class="dash-board" :factor-datas="factorDatas"></DashBoard>
    <RealTimeTrend
@@ -26,24 +27,27 @@
<script>
import moment from 'moment';
import mapUtil from '@/utils/map/util';
import { useFetchData } from '@/composables/fetchData';
import { TYPE0 } from '@/constant/device-type';
import { radioOptions } from '@/constant/radio-options';
import { defaultOptions } from '@/constant/radio-options';
import { FactorDatas } from '@/model/FactorDatas';
import DashBoard from './component/DashBoard.vue';
import RealTimeTrend from './component/RealTimeTrend.vue';
import DeviceChange from './component/DeviceChange.vue';
import SourceTrace from '@/views/sourcetrace/SourceTrace.vue';
import { realTimeMapAnimation } from '@/utils/map/animation';
import {
  fetchHistoryData,
  startLoopFetchRealTimeData,
  clearFetchingTask
} from '@/utils/factor/data';
import thirdPartyDataApi from '@/api/thirdPartyDataApi';
// const mapAnimation = new MapAnimation();
export default {
  components: { DashBoard, RealTimeTrend, DeviceChange },
  components: { DashBoard, RealTimeTrend, DeviceChange, SourceTrace },
  setup() {
    const { loading, fetchData } = useFetchData(10000);
    return { loading, fetchData };
@@ -54,7 +58,7 @@
      deviceType: TYPE0,
      deviceCode: '',
      // 监测因子的类型编号
      factorType: radioOptions(TYPE0)[0].value,
      factorType: defaultOptions(TYPE0).value,
      // 新获取的监测数据
      factorDatas: new FactorDatas(),
      // 全部监测数据
@@ -102,19 +106,23 @@
    },
    fetchRealTimeData() {
      this.fetchData((page) => {
        return fetchHistoryData({
          deviceCode: this.deviceCode,
          // startTime: '2024-08-20 06:00:00',
          // endTime: '2024-08-20 06:02:00',
          page,
          perPage: 100
        }).then((res) => {
        return fetchHistoryData(
          {
            deviceCode: this.deviceCode,
            // startTime: '2024-08-20 06:00:00',
            // endTime: '2024-08-20 06:02:00',
            page,
            perPage: 100
          },
          false
        ).then((res) => {
          this.onFetchData(res.data);
          this.onMapData(res.data);
          // if (res.data.length > 0) {
          //   this.fetchNextData(res.data[res.data.length - 1].time);
          // }
          this.fetchNextData();
          thirdPartyDataApi.fetchLatestData(this.deviceType, this.deviceCode);
        });
      });
    },
@@ -133,6 +141,7 @@
        (res) => {
          this.onFetchData(res.data);
          this.onMapData(res.data);
          thirdPartyDataApi.fetchLatestData(this.deviceType, this.deviceCode);
        }
      );
    },
@@ -143,7 +152,7 @@
        this.notFirstFetch = true;
      }
      startIndex = startIndex < 0 ? 0 : startIndex;
      return new Promise((resolve, reject) => {
      return new Promise(() => {
        this.allFactorDatas.addData(dataList, this.drawMode, () => {
          realTimeMapAnimation.moveAnimation(
            this.allFactorDatas,
@@ -167,6 +176,7 @@
  unmounted() {
    this.clearFetchingTask();
    realTimeMapAnimation.stop();
    mapUtil.clearMap();
  }
};
</script>