From 7eb2abf43167d9db3fca2e7958b90ff1bea0cead Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期一, 03 三月 2025 13:54:31 +0800 Subject: [PATCH] 污染溯源模块编写中 --- src/stores/satellite-grid.js | 46 +++++++++++++++++++++++++++++++++++++--------- 1 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/stores/satellite-grid.js b/src/stores/satellite-grid.js index d88a13f..0238594 100644 --- a/src/stores/satellite-grid.js +++ b/src/stores/satellite-grid.js @@ -1,4 +1,4 @@ -import { ref } from 'vue'; +import { ref, computed } from 'vue'; import { defineStore } from 'pinia'; import gridApi from '@/api/gridApi'; import { useFetchData } from '@/composables/fetchData'; @@ -7,8 +7,26 @@ 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) { @@ -20,22 +38,32 @@ // 鑾峰彇閬ユ祴鍗曟棩鏁版嵁淇℃伅 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 -- Gitblit v1.9.3