|
@@ -1,6 +1,7 @@
|
|
|
<template>
|
|
|
<div class="tools_container">
|
|
|
- <div v-for="item in tools" :key="item.name" @click="selectTool(item.name)" :class="{ active: activeTool === item.name }" class="tools_item">
|
|
|
+ <div v-for="item in tools" :key="item.name" @click="toggleTool(item.name)"
|
|
|
+ :class="{ active: commonStore.activeTools[item.name] }" class="tools_item">
|
|
|
<img :src="getToolImg(item.name)" alt="" />
|
|
|
</div>
|
|
|
</div>
|
|
@@ -8,49 +9,54 @@
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
-import {setDistrictResult} from "@/utils/map/AddLayer.js";
|
|
|
-import {useEventInteractionStore} from "@/store/eventInteraction.js";
|
|
|
-import {handleJtlxPoints} from "@/utils/map/baseMethod.js";
|
|
|
+import { setDistrictResult } from "@/utils/map/AddLayer.js";
|
|
|
+import { useEventInteractionStore } from "@/store/eventInteraction.js";
|
|
|
+import { handleJtlxPoints } from "@/utils/map/baseMethod.js";
|
|
|
const eventInteractionStore = useEventInteractionStore()
|
|
|
+import { useDialogStore } from '@/store/dialog'
|
|
|
+let dialogStore = useDialogStore()
|
|
|
+import { useCommonStore } from '@/store/common.js'
|
|
|
+let commonStore = useCommonStore()
|
|
|
+import { useRightPanelStore } from "@/store/rightPanel";
|
|
|
+const rightPanelStore = useRightPanelStore();
|
|
|
|
|
|
// 公共路径
|
|
|
const basePath = '../../../../../assets/img/'
|
|
|
|
|
|
// 工具配置数据
|
|
|
const tools = ref([
|
|
|
- {
|
|
|
- name: '风险列表',
|
|
|
- img: '风险列表1.png',
|
|
|
- activeImg: '风险列表2.png'
|
|
|
- },
|
|
|
- {
|
|
|
- name: '图例',
|
|
|
- img: '图例1.png',
|
|
|
- activeImg: '图例2.png'
|
|
|
- },
|
|
|
- {
|
|
|
- name: '色阶图',
|
|
|
- img: '色阶图1.png',
|
|
|
- activeImg: '色阶图2.png'
|
|
|
- }
|
|
|
+ { name: '风险列表', img: '风险列表1.png', activeImg: '风险列表2.png' },
|
|
|
+ { name: '图例', img: '图例1.png', activeImg: '图例2.png' },
|
|
|
+ { name: '色阶图', img: '色阶图1.png', activeImg: '色阶图2.png' }
|
|
|
])
|
|
|
|
|
|
-// 当前激活的工具
|
|
|
-const activeTool = ref('')
|
|
|
-
|
|
|
// 预处理图片路径
|
|
|
const imgMap = ref({})
|
|
|
|
|
|
-// 选择工具
|
|
|
-const selectTool = name => {
|
|
|
- if(activeTool.value === name){
|
|
|
- activeTool.value = ""
|
|
|
- }else{
|
|
|
- activeTool.value = name
|
|
|
+// 切换工具选中状态
|
|
|
+const toggleTool = name => {
|
|
|
+ if (commonStore.activeTools[name]) {
|
|
|
+ handleToolClose(name) // 关闭操作
|
|
|
+ commonStore.activeTools[name] = false
|
|
|
+ } else {
|
|
|
+ commonStore.activeTools[name] = true
|
|
|
+ handleToolAction(name) // 激活操作
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- if(name === "色阶图"){
|
|
|
- let data = [
|
|
|
+// 工具激活时执行的操作
|
|
|
+const handleToolAction = name => {
|
|
|
+ console.log(`${name} 已激活,执行对应操作`)
|
|
|
+ if (name === '风险列表') {
|
|
|
+ console.log('显示风险列表...')
|
|
|
+ // dialogStore.setPublicHealthRiskDialogOpen(true)
|
|
|
+ } else if (name === '图例') {
|
|
|
+ console.log('展示图例...')
|
|
|
+ rightPanelStore.legendVisible = true
|
|
|
+ // handleCase()
|
|
|
+ } else if (name === '色阶图') {
|
|
|
+ console.log('加载色阶图数据...')
|
|
|
+ let data = [
|
|
|
{
|
|
|
"name": "黄浦区",
|
|
|
"count": 48
|
|
@@ -100,14 +106,30 @@ const selectTool = name => {
|
|
|
"name": "长宁区",
|
|
|
"count": 36
|
|
|
}]
|
|
|
- setDistrictResult(activeTool.value === "色阶图", data)
|
|
|
- eventInteractionStore.isDangerStatistic = activeTool.value === "色阶图"
|
|
|
+ commonStore.activeTools[name]
|
|
|
+ setDistrictResult(commonStore.activeTools[name], data)
|
|
|
+ eventInteractionStore.isDangerStatistic = commonStore.activeTools[name]
|
|
|
|
|
|
- handleJtlxPoints(activeTool.value !== "色阶图")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 预加载图片路径
|
|
|
+// 工具取消高亮时执行的操作
|
|
|
+const handleToolClose = name => {
|
|
|
+ console.log(`${name} 取消激活,执行关闭操作`)
|
|
|
+ if (name === '风险列表') {
|
|
|
+ console.log('隐藏风险列表...')
|
|
|
+ // dialogStore.setPublicHealthRiskDialogOpen(false)
|
|
|
+ } else if (name === '图例') {
|
|
|
+ console.log('隐藏图例...')
|
|
|
+ rightPanelStore.legendVisible=false
|
|
|
+ } else if (name === '色阶图') {
|
|
|
+ console.log('清除色阶图数据...')
|
|
|
+ // setDistrictResult(commonStore.activeTools[name])
|
|
|
+ // handleJtlxPoints(!commonStore.activeTools[name])
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 预加载图片路径并初始化第一个工具
|
|
|
onMounted(() => {
|
|
|
tools.value.forEach(item => {
|
|
|
imgMap.value[item.name] = {
|
|
@@ -115,11 +137,23 @@ onMounted(() => {
|
|
|
active: new URL(`${basePath}${item.activeImg}`, import.meta.url).href
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ // 默认高亮第一个工具
|
|
|
+ if (tools.value.length > 0) {
|
|
|
+ // const firstTool = tools.value[0].name
|
|
|
+ // const firstTool2 = tools.value[2].name
|
|
|
+ // const firstTool3 = tools.value[1].name
|
|
|
+ // commonStore.activeTools[firstTool] = true
|
|
|
+ // commonStore.activeTools[firstTool2] = true
|
|
|
+ // commonStore.activeTools[firstTool3] = true
|
|
|
+ // activeTools[firstTool3] = true
|
|
|
+ // handleToolAction(firstTool) // 确保默认工具生效
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
// 获取工具图片
|
|
|
const getToolImg = name => {
|
|
|
- return activeTool.value === name ? imgMap.value[name]?.active : imgMap.value[name]?.default
|
|
|
+ return commonStore.activeTools[name] ? imgMap.value[name]?.active : imgMap.value[name]?.default
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -136,6 +170,7 @@ const getToolImg = name => {
|
|
|
top: 70px;
|
|
|
right: -61px;
|
|
|
}
|
|
|
+
|
|
|
.tools_item {
|
|
|
width: 51px;
|
|
|
height: 51px;
|