123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import { defineStore } from "pinia";
- import { ref, watch } from "vue";
- import { useCommonStore } from "./common";
- import {
- changeStreet,
- handleCaseRelPoints,
- handleDangerStatistic,
- handleJtlxPoints,
- initDistrict
- } from "@/utils/map/baseMethod.js";
- import {addMyGraphByData_TJ, changeMapType, createMap} from "@/utils/map/AddLayer.js";
- export const useEventInteractionStore = defineStore("eventInteractionStore", () => {
- const commonStore = useCommonStore();
- //地图区分上海、全国、全球
- const mapType = ref("shanghai");
- //区县选择
- const selectDistrict = ref("");
- //地图层级scale
- const currentMapScale = ref(0);
- //是否打开风险统计
- const isDangerStatistic = ref(false);
- //是否打开病例撒点
- const isCaseShow = ref(false);
- watch(
- () => commonStore.activeIndex,
- (val) => {
- // isDangerStatistic.value = val === 0
- }
- );
- watch(
- () => mapType.value,
- (val) => {
- if(val === "shanghai"){
- createMap()
- }else{
- changeMapType(val)
- }
- }
- )
- watch(
- () => isDangerStatistic.value,
- (val) => {
- handleDangerStatistic(currentMapScale.value < 90000, val)
- }
- )
- watch(
- () => currentMapScale.value,
- (newValue,oldValue) => {
- // console.log(newValue,oldValue);
- if(commonStore.activeIndex === 0){
- if(isDangerStatistic.value){
- if(oldValue > 90000 && newValue <= 90000){
- handleDangerStatistic(true, true)
- }
- if(oldValue < 90000 && newValue >= 90000){
- handleDangerStatistic(false, true)
- }
- }
- }
- if(isCaseShow.value){
- if(oldValue > 140000 && newValue <= 140000){
- handleCaseRelPoints(true)
- handleJtlxPoints(false)
- }
- if(oldValue < 140000 && newValue >= 140000){
- handleCaseRelPoints(false)
- handleJtlxPoints(true)
- }
- }
- }
- )
- watch(
- () => selectDistrict.value,
- (val) => {
- console.log(val);
- if(commonStore.activeIndex === 0){
- if(val){
- // isDangerStatistic.value = false
- changeStreet(val, true, true)
- }else {
- // isDangerStatistic.value = true
- initDistrict()
- }
- }
- }
- )
- return {
- mapType,
- selectDistrict,
- currentMapScale,
- isDangerStatistic,
- isCaseShow
- };
- });
|