2026-03-31 14:17:30 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="mapLegendView">
|
|
|
|
|
<div class="legendTitle">
|
|
|
|
|
图例
|
|
|
|
|
<span class="legendBtn" @click="isOpen = !isOpen">
|
|
|
|
|
<i class="icon iconfont" :class="isOpen ? 'icon-fold' : 'icon-unFold'"></i>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="legendContent" v-show="isOpen">
|
2026-04-03 16:04:16 +08:00
|
|
|
<a-spin :spinning="legendData.length === 0">
|
|
|
|
|
<div class="legendGroup" v-for="i in legendData">
|
|
|
|
|
<div class="groupTitle">{{ i.name }} {{ i.layerCode }}</div>
|
2026-03-31 14:17:30 +08:00
|
|
|
<div class="groupContent">
|
2026-04-03 16:04:16 +08:00
|
|
|
<template v-for="j in i.childrenList" :key="j.name">
|
|
|
|
|
<LegendItem v-if="j.layerCode" :item="j" @click="legendItemClick(j)" />
|
|
|
|
|
<div
|
|
|
|
|
v-else-if="j.childrenList && j.childrenList.length > 0"
|
|
|
|
|
class="legendGroup"
|
|
|
|
|
>
|
|
|
|
|
<div class="groupTitle">{{ j.name }}</div>
|
|
|
|
|
<div class="groupContent">
|
|
|
|
|
<LegendItem
|
|
|
|
|
v-for="item in j.childrenList"
|
|
|
|
|
:key="item.layerCode"
|
|
|
|
|
:item="item"
|
|
|
|
|
@click="legendItemClick(item)"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-03-31 14:17:30 +08:00
|
|
|
</div>
|
2026-04-03 16:04:16 +08:00
|
|
|
</template>
|
2026-03-31 14:17:30 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</a-spin>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
2026-04-03 16:04:16 +08:00
|
|
|
import { onMounted, ref, computed, watch } from "vue";
|
|
|
|
|
import { useMapStore } from "@/store/modules/map";
|
|
|
|
|
import LegendItem from "@/components/mapLegend/LegendItem.vue";
|
|
|
|
|
const mapStore: any = useMapStore();
|
|
|
|
|
// 图层数据
|
|
|
|
|
const legendData = ref(mapStore.legendDataSelected);
|
|
|
|
|
const legendItemClick = (item: any) => {
|
|
|
|
|
if (item.canBeChecked == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
item.checked = item.checked == 0 ? 1 : 0;
|
|
|
|
|
};
|
|
|
|
|
watch(
|
|
|
|
|
() => mapStore.legendDataSelected,
|
|
|
|
|
(newValue) => {
|
|
|
|
|
// layerConfigs.value = newValue;
|
|
|
|
|
console.log(newValue);
|
|
|
|
|
legendData.value = newValue;
|
|
|
|
|
// for (let i = 0; i < newValue.length; i++) {
|
|
|
|
|
// console.log(mapStore.layerData[i]);
|
|
|
|
|
// if (newValue[i].key != "-") {
|
|
|
|
|
// if (newValue[i].checked == 1) {
|
|
|
|
|
// if (newValue[i].children?.length > 0) {
|
|
|
|
|
// legendData.value.push(newValue[i]);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true, deep: true }
|
|
|
|
|
);
|
2026-03-31 14:17:30 +08:00
|
|
|
onMounted(() => {
|
2026-04-03 16:04:16 +08:00
|
|
|
// for (let i = 0; i < mapStore.layerData.length; i++) {
|
|
|
|
|
// console.log(mapStore.layerData[i]);
|
|
|
|
|
// if (mapStore.layerData[i].key != "-") {
|
|
|
|
|
// if (mapStore.layerData[i].checked == 1) {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// console.log(layerConfigs.value)
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// data.value = 10;
|
|
|
|
|
// }, 1000);
|
|
|
|
|
// console.log(data.value);
|
2026-03-31 14:17:30 +08:00
|
|
|
});
|
|
|
|
|
const isOpen = ref(true);
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.mapLegendView {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
min-width: 72px;
|
|
|
|
|
margin: 24px 0 16px 16px;
|
|
|
|
|
border: 1px solid #ccdae7;
|
|
|
|
|
padding: 6px;
|
|
|
|
|
z-index: 9;
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
}
|
|
|
|
|
.legendTitle {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
.legendBtn {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.legendContent {
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
max-width: 450px;
|
|
|
|
|
max-height: 392px;
|
|
|
|
|
overflow-x: scroll;
|
|
|
|
|
overflow-y: scroll;
|
|
|
|
|
border-top: 1px solid #eeeeee;
|
|
|
|
|
.legendGroup {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
vertical-align: top;
|
|
|
|
|
padding: 0 4px;
|
|
|
|
|
.groupTitle {
|
|
|
|
|
text-align: left;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.groupContent {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
padding: 10px 0;
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
.gray {
|
|
|
|
|
filter: grayscale(100%);
|
|
|
|
|
color: #00000073;
|
|
|
|
|
}
|
2026-04-03 16:04:16 +08:00
|
|
|
.disabled {
|
|
|
|
|
cursor: not-allowed !important;
|
2026-03-31 14:17:30 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|