|
@@ -4,17 +4,20 @@
|
|
|
class="chart"
|
|
|
:option="option"
|
|
|
ref="centerMapRef"
|
|
|
+ :loading="loading"
|
|
|
+ :loading-options="loadingOptions"
|
|
|
/>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
-import {ref, nextTick, onMounted, watch} from "vue";
|
|
|
+import {ref, onMounted, watch} from "vue";
|
|
|
import {registerMap, getMap} from "echarts/core";
|
|
|
-import {optionHandle, regionCodes} from "./center.map";
|
|
|
+import {optionHandle} from "./center.map";
|
|
|
import {loopShowTooltip} from "@/utils/tooltip-auto-show";
|
|
|
import axios from "axios";
|
|
|
import {areaDetail} from "api/home";
|
|
|
import dayjs from "dayjs";
|
|
|
+import {loadingOptions} from "@/utils/constants";
|
|
|
|
|
|
const props = defineProps({
|
|
|
dateArray: {
|
|
@@ -30,7 +33,7 @@ watch(() => props.dateArray, (val: any) => {
|
|
|
watch(() => props.dateArray, (val: any) => {
|
|
|
getData();
|
|
|
})
|
|
|
-
|
|
|
+const loading = ref(false);
|
|
|
const option = ref({});
|
|
|
const code = ref("511500"); //100000 代表中国 其他地市是行政编码
|
|
|
const dataSetHandle = async (regionCode: string, list: object[]) => {
|
|
@@ -66,12 +69,12 @@ const getGeoJson = (regionCode: string) => {
|
|
|
};
|
|
|
// 获取数据设置到地图中
|
|
|
const getData = async () => {
|
|
|
+ loading.value = true;
|
|
|
try {
|
|
|
const {result} = await areaDetail({
|
|
|
StartDate: dayjs(date.value[0]).format('YYYY-MM-DD'),
|
|
|
EndDate: dayjs(date.value[1]).format('YYYY-MM-DD')
|
|
|
});
|
|
|
-
|
|
|
const regionData = result.map((item: any) => {
|
|
|
return {
|
|
|
name: item.areaName,
|
|
@@ -79,8 +82,10 @@ const getData = async () => {
|
|
|
}
|
|
|
})
|
|
|
await dataSetHandle(code.value, regionData);
|
|
|
+ loading.value = false;
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
+ loading.value = false;
|
|
|
}
|
|
|
};
|
|
|
const tooltipTimer = ref<any>(null);
|