From a0ac379b28daeac8deddfae34f0015935a811bac Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 07 二月 2025 17:39:47 +0800 Subject: [PATCH] 修改细分网格的展示逻辑 --- src/views/satellitetelemetry/SatelliteTelemetry.vue | 234 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 177 insertions(+), 57 deletions(-) diff --git a/src/views/satellitetelemetry/SatelliteTelemetry.vue b/src/views/satellitetelemetry/SatelliteTelemetry.vue index 9260b30..bcbba00 100644 --- a/src/views/satellitetelemetry/SatelliteTelemetry.vue +++ b/src/views/satellitetelemetry/SatelliteTelemetry.vue @@ -1,48 +1,117 @@ <template> - <div> - <!-- <el-button - class="p-events-auto" - type="info" - icon="Memo" - plain - @click="draw" - > - 缁樺埗缃戞牸 - </el-button> --> - <SatelliteManage - class="satellite-manage" - :gridDataList="gridDataList" - :loading="loading" - @search="onSearch" - @row-click="handleRowClick" - ></SatelliteManage> - <el-row class="historical" justify="center"> - <SatelliteAnimation - :loading="animaLoading" - :grid-data="gridDataDetailList" - :mapViews="mapViews" - ></SatelliteAnimation> - </el-row> - </div> + <el-row class="wrap"> + <el-col span="2"> + <!-- <div class="p-events-auto"> + <el-button + type="primary" + class="el-button-custom" + size="small" + @click="previousGrid" + > + 涓婁竴涓� + </el-button> + <el-button + type="primary" + class="el-button-custom" + size="small" + @click="nextGrid" + > + 涓嬩竴涓� + </el-button> + </div> --> + <el-row> + <SatelliteManage + v-show="show" + class="satellite-manage" + :gridDataList="satelliteGridStore.gridDataList" + :loading="loading" + @search="onSearch" + @row-click="handleRowClick" + @show-rank="handleRankClick" + @show-data="handleDataClick" + @change-color="handleColorClick" + ></SatelliteManage> + </el-row> + </el-col> + <el-col span="2"> + <el-row> + <CardButton + name="鍗槦閬ユ祴鏁版嵁" + direction="right" + @click="() => (show = !show)" + ></CardButton> + </el-row> + </el-col> + </el-row> + <SatelliteDataMix class="data-mix" @mix-data="handleMixDataClick"> + </SatelliteDataMix> + <!-- <el-row class="historical" justify="center"> + <SatelliteAnimation + :loading="animaLoading" + :grid-data="gridDataDetailList" + :mapViews="mapViews" + ></SatelliteAnimation> + </el-row> --> </template> <script setup> -import { map } from '@/utils/map/index_old'; +import { map, onMapMounted } from '@/utils/map/index_old'; import calculate from '@/utils/map/calculate'; import marks from '@/utils/map/marks'; import grid from '@/utils/map/grid'; -import { ref } from 'vue'; +import { ref, onMounted } from 'vue'; import gridApi from '@/api/gridApi'; import SatelliteManage from './component/SatelliteManage.vue'; +import SatelliteDataMix from './component/SatelliteDataMix.vue'; import SatelliteProxy from './SatelliteProxy'; import { useFetchData } from '@/composables/fetchData'; +import { useSatelliteGridStore } from '@/stores/satellite-grid'; +// onMounted(() => { +// initDistrict(); +// }); +// 鏌ヨ闀垮畞鍖鸿鏀垮尯鍒� +let polygon; +function initDistrict() { + onMapMounted(() => { + if (polygon) { + map.remove(polygon); + map.add(polygon); + map.setFitView(); + return + } + // eslint-disable-next-line no-undef + var district = new AMap.DistrictSearch({ + extensions: 'all', //杩斿洖琛屾斂鍖鸿竟鐣屽潗鏍囩瓑鍏蜂綋淇℃伅 + level: 'district' //璁剧疆鏌ヨ琛屾斂鍖虹骇鍒负鍖� + }); + district.search('闀垮畞鍖�', function (status, result) { + var bounds = result.districtList[0].boundaries; //鑾峰彇鏈濋槼鍖虹殑杈圭晫淇℃伅 + if (bounds) { + for (var i = 0; i < bounds.length; i++) { + //鐢熸垚琛屾斂鍖哄垝 polygon + // eslint-disable-next-line no-undef + polygon = new AMap.Polygon({ + map: map, //鏄剧ず璇ヨ鐩栫墿鐨勫湴鍥惧璞� + strokeWeight: 3, //杞粨绾垮搴� + path: bounds[i], //澶氳竟褰㈣疆寤撶嚎鐨勮妭鐐瑰潗鏍囨暟缁� + fillOpacity: 0.1, //澶氳竟褰㈠~鍏呴�忔槑搴� + fillColor: '#CCF3FF', //澶氳竟褰㈠~鍏呴鑹� + // strokeColor: '#ffffff' //绾挎潯棰滆壊 + strokeColor: '#0077ff' //绾挎潯棰滆壊 + }); + } + map.setFitView(); //灏嗚鐩栫墿璋冩暣鍒板悎閫傝閲� + } + }); + }); +} + +const satelliteGridStore = useSatelliteGridStore(); const { loading, fetchData } = useFetchData(10000); const animaLoading = ref(true); -// 缃戞牸淇℃伅 -let gridInfo = []; -// 缃戞牸鏁版嵁缁� -const gridDataList = ref([]); +const show = ref(true); + let count = 0, max = 0; // 缃戞牸鏁版嵁璇︽儏 @@ -53,27 +122,14 @@ // 鏌ヨ缃戞牸淇℃伅鍜岄仴鎰熸暟鎹粍 function onSearch(options) { - fetchGridCell(options.id); - fetchGridData(options.id); -} - -// 鑾峰彇缃戞牸淇℃伅 -function fetchGridCell(groupId) { - return fetchData(() => { - return gridApi.fetchGridCell(groupId).then((res) => { - gridInfo = res.data; - drawGrid(gridInfo); - }); + satelliteGridStore.fetchGridCell(options.id).then(() => { + SatelliteProxy.clearText(mapViews); + drawGrid(satelliteGridStore.gridInfo); + initDistrict() }); -} - -// 鑾峰彇閬ユ劅鏁版嵁缁� -function fetchGridData(groupId) { - return gridApi.fetchGridData(groupId).then((res) => { - gridDataList.value = res.data; - count = 0; - max = res.data.length; - fetchGridDataDetail(res.data); + satelliteGridStore.fetchGridData(options.id).then(() => { + max = satelliteGridStore.gridDataList.length; + // fetchGridDataDetail(satelliteGridStore.gridDataList); }); } @@ -107,31 +163,88 @@ function drawGrid(gridInfo) { SatelliteProxy.clearAll(mapViews); mapViews = SatelliteProxy.drawPolyline(gridInfo); + // mapViews = SatelliteProxy.drawPolyline([gridInfo[0]]); +} + +let index = 0; +function previousGrid() { + index--; + if (index < 0) { + index = 0; + } + SatelliteProxy.clearAll(mapViews); + mapViews = SatelliteProxy.drawPolyline([satelliteGridStore.gridInfo[index]]); +} + +function nextGrid() { + index++; + if (index > satelliteGridStore.gridInfo.length - 1) { + index = satelliteGridStore.gridInfo.length - 1; + } + SatelliteProxy.clearAll(mapViews); + mapViews = SatelliteProxy.drawPolyline([satelliteGridStore.gridInfo[index]]); } // 缁樺埗缃戞牸閬ユ劅鏁版嵁鍊煎拰缃戞牸棰滆壊 function drawTextAndColor(gridData) { - // SatelliteProxy.clearText(mapViews); // 鏂囨湰鏍囪 - mapViews.textViews = SatelliteProxy.drawDataText( - mapViews.points, - gridData, - mapViews.textViews - ); + const { textViews: dataTxt, labelsLayer: dataLayer } = + SatelliteProxy.drawDataText( + mapViews.points, + gridData, + mapViews.dataTxt, + mapViews.dataLayer + ); + mapViews.dataTxt = dataTxt; + mapViews.dataLayer = dataLayer; + const { textViews: rankTxt, labelsLayer: rankLayer } = + SatelliteProxy.drawRankText( + mapViews.points, + gridData, + mapViews.rankTxt, + mapViews.rankLayer + ); + mapViews.rankTxt = rankTxt; + mapViews.rankLayer = rankLayer; SatelliteProxy.drawColor(mapViews.gridViews, gridData); } +let selectedGridData; function handleRowClick(row) { if (gridDataDetailMap.has(row.id)) { const gridData = gridDataDetailMap.get(row.id); + selectedGridData = gridData; drawTextAndColor(gridData); } else { gridApi.fetchGridDataDetail(row.id, row.groupId).then((res) => { gridDataDetailMap.set(row.id, res.data); const gridData = res.data; + selectedGridData = gridData; drawTextAndColor(gridData); }); } +} + +function handleRankClick(rankVisible) { + // rankVisible ? map.add(mapViews.rankLayer) : map.remove(mapViews.rankLayer); + rankVisible ? map.add(mapViews.rankTxt) : map.remove(mapViews.rankTxt); +} + +function handleDataClick(dataVisible) { + // dataVisible ? map.add(mapViews.dataLayer) : map.remove(mapViews.dataLayer); + dataVisible ? map.add(mapViews.dataTxt) : map.remove(mapViews.dataTxt); +} + +function handleColorClick(isStandardColor) { + SatelliteProxy.drawColor( + mapViews.gridViews, + selectedGridData, + !isStandardColor + ); +} + +function handleMixDataClick(gridData) { + handleRowClick(gridData); } </script> <style scoped> @@ -143,5 +256,12 @@ bottom: 10px; left: 0; right: 0; + color: #0077ff; +} + +.data-mix { + position: absolute; + right: 0; + top: 60px; } </style> -- Gitblit v1.9.3