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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<template>
  <el-row justify="space-between">
    <el-row class="wrap">
      <el-col span="2">
        <el-row>
          <SatelliteManage
            v-show="show"
            class="satellite-manage"
            :gridDataList="satelliteGridStore.gridDataList"
            :loading="loading"
            @search="onSearch"
            @row-click="handleRowClick"
          ></SatelliteManage>
        </el-row>
      </el-col>
      <el-col span="2">
        <el-row>
          <CardButton
            name="卫星遥测数据"
            direction="right"
            @click="() => (show = !show)"
          ></CardButton>
        </el-row>
        <el-row class="flex-col">
          <GridStyleTool
            @show-rank="handleRankClick"
            @show-data="handleDataClick"
            @change-color="handleColorClick"
            @change-opacity="handleOpacityClick"
          ></GridStyleTool>
        </el-row>
      </el-col>
    </el-row>
    <GridTool></GridTool>
  </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 { ref, onMounted } from 'vue';
import gridApi from '@/api/gridApi';
import SatelliteManage from './component/SatelliteManage.vue';
import moment from 'moment';
import GridStyleTool from './component/GridStyleTool.vue';
import { SatelliteProxy } from './SatelliteProxy';
import { useFetchData } from '@/composables/fetchData';
import { useSatelliteGridStore } from '@/stores/satellite-grid';
import { useSceneStore } from '@/stores/scene';
import { useGridStore } from '@/stores/grid-info';
 
const satelliteProxy = new SatelliteProxy();
 
const gridStore = useGridStore();
gridStore.selectedSatelliteProxy = satelliteProxy;
gridStore.pushGridClz(satelliteProxy);
 
const sceneStore = useSceneStore();
const satelliteGridStore = useSatelliteGridStore();
 
const { loading, fetchData } = useFetchData(10000);
const animaLoading = ref(true);
const show = ref(true);
 
let count = 0,
  max = 0;
// 网格数据详情
const gridDataDetailMap = new Map();
const gridDataDetailList = ref([]);
 
// 查询网格信息和遥感数据组
function onSearch(options) {
  satelliteGridStore.fetchGridCell(options.id).then(() => {
    prepareGrid(satelliteGridStore.gridInfo);
    satelliteProxy.drawDistrict('长宁区');
  });
  satelliteGridStore.fetchGridData(options.id).then(() => {
    max = satelliteGridStore.gridDataList.length;
    // fetchGridDataDetail(satelliteGridStore.gridDataList);
  });
}
 
function fetchGridDataDetail(dataList) {
  dataList.forEach((d) => {
    gridApi.fetchGridDataDetail(d.id, d.groupId).then((res) => {
      gridDataDetailMap.set(d.id, res.data);
      // const gridData = res.data;
      // drawTextAndColor(gridData);
      finish();
    });
  });
}
 
function finish() {
  count++;
  if (count == max) {
    animaLoading.value = false;
    const list = [];
    gridDataDetailMap.forEach((value, key) => {
      list.push(value);
    });
 
    gridDataDetailList.value = list.sort((a, b) => {
      return a.dataId - b.dataId;
    });
    console.log(gridDataDetailList.value);
  }
}
 
function prepareGrid(gridInfo) {
  satelliteProxy.gridPrepare(gridInfo, (polygon) => {
    //鼠标移入事件
    polygon.on('mouseover', () => {
      polygon.setOptions({
        //修改多边形属性的方法
        strokeWeight: 2,
        strokeColor: 'red'
      });
    });
    //鼠标移出事件
    polygon.on('mouseout', () => {
      polygon.setOptions({
        strokeWeight: 1,
        strokeColor: 'white'
      });
    });
    //鼠标点击事件
    // polygon.on('click', () => {
    //   const [lng, lat] = polygon.getExtData();
    //   sceneStore.radius = 0.5;
    //   sceneStore.searchScene(lng, lat);
    // });
  });
  satelliteProxy.setGridEvent('click', (e) => {
    const polygon = e.target;
    const { gridCell } = polygon.getExtData();
    const cellIndex = gridCell.cellIndex;
    const gridDataDetail =
      satelliteGridStore.selectedGridDataDetail[cellIndex - 1];
    gridStore.selectedGridCellAndDataDetail = {
      gridCell,
      gridDataDetail
    };
  });
}
 
function drawGrid(useCustomColor) {
  satelliteProxy.changeVisibility({
    showGridViews: false,
    showDataTxt: false,
    showRankTxt: false
  });
  satelliteProxy.drawTagGrid({
    tag: satelliteGridStore.selectedGridData.id,
    gridDataDetail: satelliteGridStore.selectedGridDataDetail,
    useCustomColor,
    useDataTxtColor: true,
    extData: {
      name: `卫星遥测数据 - ${moment(satelliteGridStore.selectedGridData).format('YYYY-MM-DD')}`
    }
  });
}
 
function handleRowClick(row) {
  satelliteGridStore.fetchGridDataDetail(row, () => {
    drawGrid();
  });
}
 
function handleRankClick(rankVisible) {
  satelliteProxy.changeVisibility({ showRankTxt: rankVisible });
}
 
function handleDataClick(dataVisible) {
  satelliteProxy.changeVisibility({ showDataTxt: dataVisible });
}
 
function handleColorClick(isStandardColor) {
  drawGrid(!isStandardColor);
}
 
function handleOpacityClick(value) {
  satelliteProxy.changeGridOpacity({ opacityValue: value });
}
 
function handleMixDataClick(gridData) {
  handleRowClick(gridData);
}
</script>
<style scoped>
.satellite-manage {
}
 
.historical {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  color: #0077ff;
}
 
.data-mix {
  position: absolute;
  right: 0;
  top: 60px;
  /* color: #0552f7; */
}
</style>