| | |
| | | import { ref } from 'vue'; |
| | | 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 gridDataList = 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) { |
| | |
| | | // 获取遥测单日数据信息 |
| | | function fetchGridData(groupId) { |
| | | return gridApi.fetchGridData(groupId).then((res) => { |
| | | gridDataList.value = res.data; |
| | | allGridDataList.value = res.data; |
| | | }); |
| | | } |
| | | |
| | | // 获取遥测单日具体网格监测数据 |
| | | function fetchGridDataDetail(gridData) { |
| | | return gridApi |
| | | .fetchGridDataDetail(gridData.id, gridData.groupId) |
| | | .then((res) => { |
| | | gridData.dataDetail = 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 |