You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
3.3 KiB
Vue

1 month ago
<!--
工具栏组件
add by RYG
-->
<template>
<div class="flex-container">
<div v-if="!isInside" class="flex-container">
1 month ago
<img src="/img/KEP001.svg" class="align-item" />
1 month ago
<span class="text-item">KE Platform</span>
</div>
1 month ago
<ImageButton v-for="btn in buttons" :key="btn.key" :imageUrl="btn.imageUrl" :text="btn.text"
@click="handleButtonClick(btn)" class="imgBtn" :class="{ active: activeIndex === btn.index }" />
<ImageButton :key="layerButton.key" :imageUrl="layerButton.imageUrl" :text="layerButton.text"
@click="handleButtonClick(layerButton)" class="imgBtn" :class="{ active: layerShow }" />
1 month ago
</div>
</template>
<script setup>
import { ref } from "vue";
1 month ago
// import { emitter } from "~/utils/eventBus";
// import { EMIT_COMMAND } from "~/utils/commandTypes";
1 month ago
const activeIndex = ref(-1);
1 month ago
const layerShow = ref(false);
const props = defineProps({
tokenKey: { type: String, default: 'drawerToken' }
});
1 month ago
1 month ago
const emit = defineEmits([
'default',
'zoom_in',
'zoom_out',
'refresh',
'center',
'part',
'all',
'move',
'choose',
'save',
'layer',
])
1 month ago
const isInside = ref(true);
const buttons = [
{
1 month ago
imageUrl: "/img/default.svg",
1 month ago
text: "默认",
key: "default",
index: 0,
1 month ago
canActive: true,
1 month ago
},
{
1 month ago
imageUrl: "/img/zoom_in.svg",
1 month ago
text: "放大",
key: "zoom_in",
index: 1,
1 month ago
canActive: false,
1 month ago
},
{
1 month ago
imageUrl: "/img/zoom_out.svg",
1 month ago
text: "缩小",
key: "zoom_out",
index: 2,
1 month ago
canActive: false,
1 month ago
},
{
1 month ago
imageUrl: "/img/refresh.svg",
1 month ago
text: "刷新",
key: "refresh",
index: 3,
1 month ago
canActive: false,
1 month ago
},
{
1 month ago
imageUrl: "/img/center.svg",
1 month ago
text: "居中",
key: "center",
index: 4,
1 month ago
canActive: false,
1 month ago
},
{
1 month ago
imageUrl: "/img/part.svg",
1 month ago
text: "局部",
key: "part",
index: 5,
1 month ago
canActive: true,
1 month ago
},
{
1 month ago
imageUrl: "/img/all.svg",
1 month ago
text: "全部",
key: "all",
index: 6,
1 month ago
canActive: false,
1 month ago
},
{
1 month ago
imageUrl: "/img/move.svg",
1 month ago
text: "移动",
key: "move",
index: 7,
1 month ago
canActive: true,
1 month ago
},
{
1 month ago
imageUrl: "/img/choose_arrow.svg",
1 month ago
text: "选择",
key: "choose",
index: 8,
1 month ago
canActive: true,
1 month ago
},
{
1 month ago
imageUrl: "/img/save.svg",
1 month ago
text: "保存",
key: "save",
index: 9,
1 month ago
canActive: false,
1 month ago
},
1 month ago
// {
// imageUrl: "/img/image_layer_tree.svg",
// text: "图层",
// key: "layer",
// index: 10,
// canActive: false,
// },
1 month ago
];
1 month ago
const layerButton = {
imageUrl: "/img/image_layer_tree.svg",
text: "图层",
key: "layer",
index: 10,
canActive: false,
};
1 month ago
const handleButtonClick = (btn) => {
1 month ago
emit(btn.key);
if (btn.canActive) {
activeIndex.value = btn.index;
}
// emitter.emit(EMIT_COMMAND.BUTTON_CLICK, { key: btn.key, index: btn.index, tokenKey: props.tokenKey });
1 month ago
};
1 month ago
onMounted(() => {
emitter.on("showLayers", () => {
layerShow.value = !layerShow.value;
});
});
onBeforeUnmount(() => {
emitter.off("showLayers");
})
1 month ago
</script>
<style scoped>
.flex-container {
display: flex;
flex-direction: row;
align-items: center;
/* 元素间距 */
gap: 12px;
1 month ago
padding-left: 15px;
1 month ago
}
.align-item {
width: 30px;
height: 35px;
}
.text-item {
font-size: 20px;
}
.active {
background-color: #fff;
color: rgb(24, 144, 255);
}
.imgBtn {
height: 35px;
width: 30px;
}
.imgBtn :hover {
color: rgb(24, 144, 255);
}
</style>