|
@@ -0,0 +1,148 @@
|
|
|
+<!-- 此组件只对矢量数据维护工具的状态进行逻辑判断与维护 -->
|
|
|
+<!-- 具体监听事件仍在主页面/views/index.vue中进行 -->
|
|
|
+<template>
|
|
|
+ <div class="layer-modify-tool">
|
|
|
+ <div class="label">工具栏:</div>
|
|
|
+ <div class="tools-box">
|
|
|
+ <div v-for="tool in tools" :key="tool.id" class="tool-item" :title="tool.title">
|
|
|
+ <img :src="tool.active ? tool.activeIcon : tool.icon" :style="tool.style" alt=""
|
|
|
+ @click="handleToolClick(tool)">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { onMounted, watch, ref, onBeforeUnmount } from 'vue';
|
|
|
+
|
|
|
+import selectIcon from '/@/assets/images/mapTools/select.png';
|
|
|
+import delIcon from '/@/assets/images/mapTools/del.png';
|
|
|
+import addPointIcon from '/@/assets/images/mapTools/add-point.png';
|
|
|
+import selectActiveIcon from '/@/assets/images/mapTools/select-a.png';
|
|
|
+import delActiveIcon from '/@/assets/images/mapTools/del-a.png';
|
|
|
+import addPointActiveIcon from '/@/assets/images/mapTools/add-point-a.png';
|
|
|
+
|
|
|
+import { useMapToolsStore } from '/@/store/modules/mapTools';
|
|
|
+const mapToolsStore = useMapToolsStore();
|
|
|
+// 数据集名称
|
|
|
+const dataSet = ref(mapToolsStore.getCurrentLayerDataSet);
|
|
|
+
|
|
|
+// 监听数据集变化
|
|
|
+watch(
|
|
|
+ () => mapToolsStore.getCurrentLayerDataSet,
|
|
|
+ (newVal, oldVal) => {
|
|
|
+ dataSet.value = newVal;
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ // 重置工具状态
|
|
|
+ resetToolStatus()
|
|
|
+})
|
|
|
+
|
|
|
+// 工具列表
|
|
|
+const tools = ref([
|
|
|
+ {
|
|
|
+ title: "选择",
|
|
|
+ id: "select",
|
|
|
+ icon: selectIcon,
|
|
|
+ activeIcon: selectActiveIcon,
|
|
|
+ active: false,
|
|
|
+ disabled: false,
|
|
|
+ style: {
|
|
|
+ width: '15px',
|
|
|
+ height: '16px',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "删除",
|
|
|
+ id: "del",
|
|
|
+ icon: delIcon,
|
|
|
+ activeIcon: delActiveIcon,
|
|
|
+ active: false,
|
|
|
+ disabled: false,
|
|
|
+ style: {
|
|
|
+ width: '16px',
|
|
|
+ height: '16px',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "新增点",
|
|
|
+ id: "addPoint",
|
|
|
+ icon: addPointIcon,
|
|
|
+ activeIcon: addPointActiveIcon,
|
|
|
+ active: false,
|
|
|
+ disabled: false,
|
|
|
+ style: {
|
|
|
+ width: '16.5px',
|
|
|
+ height: '14px',
|
|
|
+ }
|
|
|
+ }
|
|
|
+])
|
|
|
+// 配置默认选中状态
|
|
|
+tools.value.forEach(tool => {
|
|
|
+ if (tool.id === mapToolsStore.getLayerFunction) {
|
|
|
+ tool.active = true;
|
|
|
+ }
|
|
|
+})
|
|
|
+// 重置状态
|
|
|
+const resetToolStatus = () => {
|
|
|
+ tools.value.forEach(tool => {
|
|
|
+ tool.active = false;
|
|
|
+ })
|
|
|
+ mapToolsStore.setLayerFunction('')
|
|
|
+}
|
|
|
+// 点击工具事件
|
|
|
+const handleToolClick = (tool) => {
|
|
|
+ if (tool.disabled) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 重置其他工具状态
|
|
|
+ tools.value.forEach(t => {
|
|
|
+ if (t.id !== tool.id) {
|
|
|
+ t.active = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 设置当前工具状态
|
|
|
+ tool.active = true;
|
|
|
+ // 设置当前工具功能
|
|
|
+ mapToolsStore.setLayerFunction(tool.id)
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.layer-modify-tool {
|
|
|
+ height: 34px;
|
|
|
+ // width: auto;
|
|
|
+ padding: 10px 0 10px 10px;
|
|
|
+ border-radius: 178px;
|
|
|
+ background: rgba(8, 66, 118, 0.7);
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .label {
|
|
|
+ font-family: 思源黑体;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tools-box {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .tool-item {
|
|
|
+ padding: 0 15px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ border-right: 1px solid #fff;
|
|
|
+
|
|
|
+ &:last-child{
|
|
|
+ border-right: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ img {
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|