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) {
|
if (gridDataDetailMap.has(gridData.id)) {
|
selectedGridData.value = gridDataDetailMap.get(gridData.id);
|
callback(selectedGridData.value);
|
} else {
|
gridApi.fetchGridDataDetail(gridData.id, gridData.groupId).then((res) => {
|
gridDataDetailMap.set(gridData.id, res.data);
|
selectedGridData.value = res.data;
|
callback(selectedGridData.value);
|
});
|
}
|
}
|
|
return {
|
gridInfo,
|
allGridDataList,
|
gridDataList,
|
mixGridDataList,
|
selectedGridData,
|
fetchGridCell,
|
fetchGridData,
|
fetchGridDataDetail
|
};
|
});
|