93 lines
2.4 KiB
Vue
Raw Normal View History

2022-01-05 18:04:41 +08:00
<template>
<n-space class="header-left-btn" :size="25">
2022-01-11 20:56:19 +08:00
<n-button size="small" quaternary @click="goHomeHandle()">
<template #icon>
<n-icon :depth="3">
<HomeIcon />
</n-icon>
</template>
</n-button>
<n-space>
2022-01-16 22:17:34 +08:00
<n-tooltip v-for="item in btnList" :key="item.key" placement="bottom" trigger="hover">
<template #trigger>
2022-01-16 22:17:34 +08:00
<n-button :type="styleHandle(item)" size="small" ghost @click="clickHandle(item)">
<component :is="item.icon"></component>
</n-button>
</template>
<span>{{ item.title }}</span>
</n-tooltip>
</n-space>
2022-01-05 18:04:41 +08:00
</n-space>
</template>
<script setup lang="ts">
import { toRefs, Ref, reactive } from 'vue'
2022-01-09 19:22:55 +08:00
import { renderIcon, goDialog, goHome } from '@/utils'
2022-01-05 20:52:49 +08:00
import { icon } from '@/plugins'
const { LayersIcon, BarChartIcon, PrismIcon, HomeIcon } = icon.ionicons5
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
2022-01-20 21:25:35 +08:00
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
2022-02-03 22:54:31 +08:00
import { useRemoveKeyboard } from '../ContentEdit/hooks/useKeyboard.hook'
2022-01-05 20:52:49 +08:00
2022-01-08 14:27:56 +08:00
const { setItem } = useChartLayoutStore()
const { getLayers, getCharts, getDetails } = toRefs(useChartLayoutStore())
2022-01-05 18:04:41 +08:00
type ItemType = {
2022-01-11 20:56:19 +08:00
key: string
select: Ref<boolean> | boolean
title: string
icon: any
}
const btnList = reactive<ItemType[]>([
2022-01-05 18:04:41 +08:00
{
2022-01-20 21:25:35 +08:00
key: ChartLayoutStoreEnum.CHARTS,
2022-01-08 14:27:56 +08:00
select: getCharts,
2022-01-05 18:04:41 +08:00
title: '图表组件',
icon: renderIcon(BarChartIcon)
2022-01-05 20:52:49 +08:00
},
{
2022-01-20 21:25:35 +08:00
key: ChartLayoutStoreEnum.LAYERS,
select: getLayers,
title: '图层控制',
icon: renderIcon(LayersIcon)
},
2022-01-05 20:52:49 +08:00
{
2022-01-20 21:25:35 +08:00
key: ChartLayoutStoreEnum.DETAILS,
2022-01-08 14:27:56 +08:00
select: getDetails,
2022-01-05 20:52:49 +08:00
title: '详情设置',
icon: renderIcon(PrismIcon)
2022-01-05 18:04:41 +08:00
}
2022-01-08 14:27:56 +08:00
])
2022-01-16 22:17:34 +08:00
// store 描述的是展示的值,所以和 ContentDetails 的 collapsed 是相反的
const styleHandle = (item: ItemType) => {
2022-01-20 21:25:35 +08:00
if (item.key === ChartLayoutStoreEnum.DETAILS) {
2022-01-16 22:17:34 +08:00
return item.select ? '' : 'success'
}
return item.select ? 'success' : ''
}
const clickHandle = (item: ItemType) => {
2022-01-08 14:27:56 +08:00
setItem(item.key, !item.select)
}
2022-01-09 19:22:55 +08:00
const goHomeHandle = () => {
goDialog({
message: '返回将不会保存任何操作',
isMaskClosable: true,
2022-02-03 22:54:31 +08:00
onPositiveCallback: () => {
goHome()
useRemoveKeyboard()
}
2022-01-09 19:22:55 +08:00
})
}
2022-01-05 18:04:41 +08:00
</script>
2022-01-05 20:52:49 +08:00
<style lang="scss" scoped>
.header-left-btn {
margin-left: -37px;
padding-right: 149px;
2022-01-05 20:52:49 +08:00
}
</style>