|
@@ -2,52 +2,82 @@
|
|
|
<div class="area_layer_switch_container">
|
|
|
<div class="area_layer_switch_content">
|
|
|
<!-- 全国 -->
|
|
|
- <div class="national" @click="btnClick('全国')">
|
|
|
- <div class="national_text" :class="{national_text_active: activeIndex === '全国'}">全国</div>
|
|
|
+ <div class="national" @click="btnClick('全国')">
|
|
|
+ <div class="national_text" :class="{ national_text_active: commonStore.areaLayerSwitchActive === '全国' }">全国</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 片区 -->
|
|
|
<div class="region">
|
|
|
- <div class="region_shi" :class="{ region_shi_active: activeIndex === '上海市' }" @click="btnClick('上海市')"><div>上海市</div></div>
|
|
|
- <div class="region_pianqu">
|
|
|
- <div class="region_pianqu_btn" :class="{ region_pianqu_btn_active: activeIndex === item.name }" v-for="(item, index) in bottons" :key="item.name" @click="btnClick(index, item)" @dblclick="btnDblClick(index, item)" >
|
|
|
- <div>{{ item.name }}</div>
|
|
|
+ <div class="region_shi" :class="{ region_shi_active: commonStore.areaLayerSwitchActive === '上海市' }" @click="btnClick('上海市')">
|
|
|
+ <div>上海市</div>
|
|
|
+ </div>
|
|
|
+ <div class="region_pianqu" >
|
|
|
+ <div
|
|
|
+ class="region_pianqu_btn"
|
|
|
+ :class="[{ region_pianqu_btn_active: commonStore.areaLayerSwitchActive === item.name }, { region_pianqu_btn_disabled: isGlobalOrNational }]"
|
|
|
+ v-for="(item, index) in bottons"
|
|
|
+ :key="item.name"
|
|
|
+ @click="!isGlobalOrNational && btnClick(index, item)"
|
|
|
+ @dblclick="!isGlobalOrNational && btnDblClick(index, item)"
|
|
|
+ >
|
|
|
+ <template v-if="isGlobalOrNational" :key="item.name">
|
|
|
+ <el-tooltip content="请切换至上海市后再选择区域" placement="top" effect="customized" :key="item.name">
|
|
|
+ <div >{{ item.name }}</div>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <div v-else>{{ item.name }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div :class="[commonStore.activeTools['图例'] ? 'region_tuceng_active' : 'region_tuceng']" v-if="commonStore.activeIndex===1" @click="handleLegendOpen"></div>
|
|
|
+ <div :class="[legendOpen ? 'region_tuceng_active' : 'region_tuceng']" v-if="commonStore.activeIndex === 1" @click="handleLegendOpen"></div>
|
|
|
|
|
|
<div class="region_bg"></div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 全球 -->
|
|
|
- <div class="global" @click="btnClick('全球')" >
|
|
|
- <div class="global_text" :class="{global_text_active: activeIndex === '全球'}">全球</div>
|
|
|
+ <div class="global" @click="btnClick('全球')">
|
|
|
+ <div class="global_text" :class="{ global_text_active: commonStore.areaLayerSwitchActive === '全球' }">全球</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
-import { ref, watch, computed, reactive, toRefs, onBeforeMount, onMounted } from 'vue'
|
|
|
-import {changeStreet, initDistrict} from "@/utils/map/baseMethod.js";
|
|
|
-import {useEventInteractionStore} from "@/store/eventInteraction.js";
|
|
|
-import { ClearMap } from "@/utils/map/AddLayer.js";
|
|
|
-import { useCommonStore } from "@/store/common.js";
|
|
|
-let commonStore = useCommonStore();
|
|
|
-import { useRightPanelStore } from "@/store/rightPanel";
|
|
|
-const rightPanelStore = useRightPanelStore();
|
|
|
+import { ref, watch,nextTick, computed, reactive, toRefs, onBeforeMount, onMounted } from 'vue'
|
|
|
+import { changeStreet, initDistrict } from '@/utils/map/baseMethod.js'
|
|
|
+import { useEventInteractionStore } from '@/store/eventInteraction.js'
|
|
|
+import { ClearMap } from '@/utils/map/AddLayer.js'
|
|
|
+import { useCommonStore } from '@/store/common.js'
|
|
|
+let commonStore = useCommonStore()
|
|
|
+import { useRightPanelStore } from '@/store/rightPanel'
|
|
|
+const rightPanelStore = useRightPanelStore()
|
|
|
|
|
|
const emit = defineEmits(['btnClick'])
|
|
|
-const activeIndex = ref("上海市")
|
|
|
+// const activeIndex = ref('上海市')
|
|
|
+// const isGlobalOrNational = computed(() => ['全国', '全球'].includes(commonStore.areaLayerSwitchActive))
|
|
|
+const isGlobalOrNational = ref(false)
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => commonStore.areaLayerSwitchActive,
|
|
|
+ (newVal, oldVal) => {
|
|
|
+ nextTick(() => {
|
|
|
+ isGlobalOrNational.value =['全国', '全球'].includes(newVal)
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+)
|
|
|
|
|
|
const eventInteractionStore = useEventInteractionStore()
|
|
|
-const national=ref(false)
|
|
|
+const national = ref(false)
|
|
|
const global = ref(false)
|
|
|
|
|
|
function nationalChange() {
|
|
|
- national.value= !national.value
|
|
|
+ national.value = !national.value
|
|
|
}
|
|
|
function globalChange() {
|
|
|
- global.value= !global.value
|
|
|
+ global.value = !global.value
|
|
|
}
|
|
|
|
|
|
// const bottons = ref([
|
|
@@ -88,96 +118,84 @@ const bottons = ref([
|
|
|
{ id: 16, name: '崇明区', active: false }
|
|
|
])
|
|
|
|
|
|
-
|
|
|
const clickTimer = ref(null)
|
|
|
|
|
|
function btnClick(index, item) {
|
|
|
+ commonStore.areaLayerSwitchActive = index
|
|
|
//判断点击的是上海市
|
|
|
- if(index === "上海市") {
|
|
|
- activeIndex.value = index
|
|
|
- ClearMap();
|
|
|
- if(eventInteractionStore.mapType !== "shanghai"){
|
|
|
- eventInteractionStore.mapType = "shanghai"
|
|
|
+ if (index === '上海市') {
|
|
|
+ ClearMap()
|
|
|
+ if (eventInteractionStore.mapType !== 'shanghai') {
|
|
|
+ eventInteractionStore.mapType = 'shanghai'
|
|
|
}
|
|
|
- eventInteractionStore.selectDistrict = ""
|
|
|
+ eventInteractionStore.selectDistrict = ''
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if(index === "全国") {
|
|
|
- activeIndex.value = index
|
|
|
- eventInteractionStore.mapType = "china"
|
|
|
+ if (index === '全国') {
|
|
|
+ eventInteractionStore.mapType = 'china'
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if(index === "全球") {
|
|
|
- activeIndex.value = index
|
|
|
- eventInteractionStore.mapType = "world"
|
|
|
+ if (index === '全球') {
|
|
|
+ eventInteractionStore.mapType = 'world'
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if(eventInteractionStore.mapType !== "shanghai"){
|
|
|
- return;
|
|
|
+ if (eventInteractionStore.mapType !== 'shanghai') {
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- if(clickTimer.value) {
|
|
|
+ if (clickTimer.value) {
|
|
|
clearTimeout(clickTimer.value)
|
|
|
}
|
|
|
|
|
|
clickTimer.value = setTimeout(() => {
|
|
|
console.log(index, 'index', item)
|
|
|
|
|
|
- if(activeIndex.value !== item.name){
|
|
|
- activeIndex.value = item.name
|
|
|
+ if ((commonStore.areaLayerSwitchActive = index !== item.name)) {
|
|
|
+ commonStore.areaLayerSwitchActive = index = item.name
|
|
|
emit('btnClick', item)
|
|
|
-
|
|
|
changeStreet(item.name, false, true)
|
|
|
- }else{
|
|
|
- activeIndex.value = "上海市"
|
|
|
- ClearMap();
|
|
|
- eventInteractionStore.selectDistrict = ""
|
|
|
+ } else {
|
|
|
+ commonStore.areaLayerSwitchActive = '上海市'
|
|
|
+ ClearMap()
|
|
|
+ eventInteractionStore.selectDistrict = ''
|
|
|
}
|
|
|
-
|
|
|
}, 300)
|
|
|
-
|
|
|
}
|
|
|
function btnDblClick(index, item) {
|
|
|
- if(eventInteractionStore.mapType !== "shanghai"){
|
|
|
- return;
|
|
|
+ if (eventInteractionStore.mapType !== 'shanghai') {
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- if(clickTimer.value) {
|
|
|
+ if (clickTimer.value) {
|
|
|
clearTimeout(clickTimer.value)
|
|
|
}
|
|
|
|
|
|
- console.log("btnDblClick"+index, 'index')
|
|
|
- activeIndex.value = index
|
|
|
+ console.log('btnDblClick' + index, 'index')
|
|
|
+ commonStore.areaLayerSwitchActive = index
|
|
|
emit('btnDblClick', item)
|
|
|
|
|
|
eventInteractionStore.selectDistrict = item.name
|
|
|
}
|
|
|
|
|
|
-const legendOpen=ref(false)
|
|
|
+const legendOpen = ref(false)
|
|
|
|
|
|
-function handleLegendOpen () {
|
|
|
+function handleLegendOpen() {
|
|
|
commonStore.activeTools['图例'] = !commonStore.activeTools['图例']
|
|
|
- // legendOpen.value = !legendOpen.value
|
|
|
- // rightPanelStore.legendVisible = !rightPanelStore.legendVisible
|
|
|
- // if (rightPanelStore.legendVisible) {
|
|
|
- // rightPanelStore.legendVisible =false
|
|
|
- // } else {
|
|
|
- // rightPanelStore.legendVisible =true
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- legendOpen.value= rightPanelStore.legendVisible
|
|
|
+
|
|
|
})
|
|
|
|
|
|
watch(
|
|
|
- () => eventInteractionStore.selectDistrict,
|
|
|
- (val) => {
|
|
|
- activeIndex.value = val
|
|
|
- })
|
|
|
+ () => eventInteractionStore.selectDistrict,
|
|
|
+ val => {
|
|
|
+ commonStore.areaLayerSwitchActive = val
|
|
|
+ }
|
|
|
+)
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.area_layer_switch_container {
|
|
@@ -229,6 +247,7 @@ watch(
|
|
|
// justify-content: space-between;
|
|
|
justify-content: center;
|
|
|
position: relative;
|
|
|
+
|
|
|
// background-color: pink;
|
|
|
.region_shi {
|
|
|
width: 130px;
|
|
@@ -238,6 +257,7 @@ watch(
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
cursor: pointer;
|
|
|
+
|
|
|
> div {
|
|
|
font-family: Alibaba PuHuiTi 3;
|
|
|
font-weight: normal;
|
|
@@ -265,6 +285,8 @@ watch(
|
|
|
flex-wrap: wrap;
|
|
|
gap: 3px;
|
|
|
overflow: visible; // 防止内容被裁剪
|
|
|
+ z-index: 5;
|
|
|
+
|
|
|
.region_pianqu_btn {
|
|
|
width: 87px;
|
|
|
height: 42px;
|
|
@@ -277,6 +299,11 @@ watch(
|
|
|
cursor: pointer;
|
|
|
|
|
|
> div {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
font-family: Alibaba PuHuiTi 3, Alibaba PuHuiTi 30;
|
|
|
font-weight: normal;
|
|
|
font-size: 14px;
|
|
@@ -294,6 +321,7 @@ watch(
|
|
|
background-size: 100% 100%;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
.region_tuceng {
|
|
|
width: 98px;
|
|
|
height: 100%;
|
|
@@ -321,6 +349,7 @@ watch(
|
|
|
height: 63px;
|
|
|
display: flex;
|
|
|
cursor: pointer;
|
|
|
+
|
|
|
.global_text {
|
|
|
position: absolute;
|
|
|
top: 18px;
|
|
@@ -334,17 +363,43 @@ watch(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-.national_text_active{
|
|
|
- color: rgb(233, 233, 52) !important;
|
|
|
+.national_text_active {
|
|
|
+ color: rgb(233, 233, 52) !important;
|
|
|
}
|
|
|
-.global_text_active{
|
|
|
- color: rgb(233, 233, 52) !important;
|
|
|
+
|
|
|
+.global_text_active {
|
|
|
+ color: rgb(233, 233, 52) !important;
|
|
|
}
|
|
|
|
|
|
-.region_tuceng_active{
|
|
|
- width: 98px;
|
|
|
- height: 100%;
|
|
|
- background: url(../../assets/img/图层高亮.png) no-repeat;
|
|
|
- background-size: 100% 100%;
|
|
|
+.region_tuceng_active {
|
|
|
+ width: 98px;
|
|
|
+ height: 100%;
|
|
|
+ background: url(../../assets/img/图层高亮.png) no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+.region_pianqu .region_pianqu_btn.region_pianqu_btn_disabled {
|
|
|
+ cursor: not-allowed !important;
|
|
|
+ // pointer-events: none !important;
|
|
|
+ opacity: 0.6;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+</style>
|
|
|
+
|
|
|
+<style>
|
|
|
+.el-popper.is-customized {
|
|
|
+ color: #fff;
|
|
|
+ /* Set padding to ensure the height is 32px */
|
|
|
+ padding: 6px 12px;
|
|
|
+ /* background: linear-gradient(90deg, rgb(159, 229, 151), rgb(204, 229, 129)); */
|
|
|
+ background: linear-gradient(90deg, rgb(96, 195, 231, 0.3));
|
|
|
+}
|
|
|
+
|
|
|
+.el-popper.is-customized .el-popper__arrow::before {
|
|
|
+ /* background: linear-gradient(45deg, #b2e68d, #bce689); */
|
|
|
+ /* background: linear-gradient(45deg, rgb(96, 195, 231,0.3), rgb(96, 195, 231,0.3)); */
|
|
|
+ right: 0;
|
|
|
}
|
|
|
</style>
|