riku
2025-03-14 8372d022614a1897120802cf1bac90d61651177f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
import gridApi from '@/api/gridApi';
import { useFetchData } from '@/composables/fetchData';
 
// 卫星遥测网格
export const useSatelliteGridStore = defineStore('satelliteGrid', () => {
  // 网格信息
  const gridInfo = ref([]);
  // 所有网格数据组
  const allGridDataList = ref([]);
  // 原始网格数据组
  const gridDataList = computed(() => {
    // return allGridDataList.value.filter((v) => {
    //   return v.type == 0;
    // });
    return allGridDataList.value;
  });
  // 融合网格数据组
  const mixGridDataList = computed(() => {
    return allGridDataList.value.filter((v) => {
      return v.type == 1;
    });
  });
  // 网格数据详情
  const gridDataDetailMap = new Map();
  const selectedGridData = ref(undefined);
 
  const selectedGridDataDetail = ref(undefined);
 
  // 获取网格信息
  function fetchGridCell(groupId) {
    return gridApi.fetchGridCell(groupId).then((res) => {
      gridInfo.value = res.data;
    });
  }
 
  // 获取遥测单日数据信息
  function fetchGridData(groupId) {
    return gridApi.fetchGridData(groupId).then((res) => {
      allGridDataList.value = res.data;
    });
  }
 
  // 获取遥测单日具体网格监测数据
  function fetchGridDataDetail(gridData, callback) {
    selectedGridData.value = gridData;
    if (gridDataDetailMap.has(gridData.id)) {
      selectedGridDataDetail.value = gridDataDetailMap.get(gridData.id);
      callback(selectedGridDataDetail.value);
    } else {
      gridApi.fetchGridDataDetail(gridData.id, gridData.groupId).then((res) => {
        gridDataDetailMap.set(gridData.id, res.data);
        selectedGridDataDetail.value = res.data;
        callback(selectedGridDataDetail.value);
      });
    }
  }
 
  return {
    gridInfo,
    allGridDataList,
    gridDataList,
    mixGridDataList,
    selectedGridData,
    selectedGridDataDetail,
    fetchGridCell,
    fetchGridData,
    fetchGridDataDetail
  };
});