173 lines
4.9 KiB
Vue
Raw Normal View History

2022-01-06 13:45:51 +08:00
<template>
2022-01-16 22:17:34 +08:00
<n-layout has-sider sider-placement="right">
<n-layout-content>
2022-01-20 21:25:35 +08:00
<!-- 图表拖拽区域 -->
2022-03-14 19:52:01 +08:00
<content-edit></content-edit>
2022-01-16 22:17:34 +08:00
</n-layout-content>
<n-layout-sider
collapse-mode="transform"
:collapsed-width="0"
:width="350"
:collapsed="collapsed"
:native-scrollbar="false"
show-trigger="bar"
2022-08-09 21:08:25 +08:00
@collapse="collapsedHandle"
@expand="expandHandle"
2022-01-16 22:17:34 +08:00
>
2022-08-09 21:08:25 +08:00
<content-box class="go-content-layers go-boderbox" :show-top="false" :depth="2">
2022-02-25 21:26:56 +08:00
<!-- 页面配置 -->
2022-08-09 21:08:25 +08:00
<n-tabs v-if="!selectTarget" class="tabs-box" size="small" type="segment">
2022-02-07 20:55:40 +08:00
<n-tab-pane
v-for="item in globalTabList"
:key="item.key"
:name="item.key"
size="small"
display-directive="show:lazy"
>
2022-02-06 01:04:05 +08:00
<template #tab>
<n-space>
2022-02-07 20:55:40 +08:00
<span>{{ item.title }}</span>
2022-02-06 01:04:05 +08:00
<n-icon size="16" class="icon-position">
2022-02-07 20:55:40 +08:00
<component :is="item.icon"></component>
2022-02-06 01:04:05 +08:00
</n-icon>
</n-space>
</template>
2022-02-07 20:55:40 +08:00
<component :is="item.render"></component>
2022-02-06 01:04:05 +08:00
</n-tab-pane>
</n-tabs>
<!-- 编辑 -->
<n-tabs v-if="selectTarget" v-model:value="tabsSelect" class="tabs-box" size="small" type="segment">
2022-01-16 22:17:34 +08:00
<n-tab-pane
2022-08-09 21:08:25 +08:00
v-for="item in selectTarget.isGroup ? chartsDefaultTabList : chartsTabList"
2022-01-16 22:17:34 +08:00
:key="item.key"
:name="item.key"
2022-02-06 01:04:05 +08:00
size="small"
2022-01-16 22:17:34 +08:00
display-directive="show:lazy"
>
<template #tab>
<n-space>
<span>{{ item.title }}</span>
<n-icon size="16" class="icon-position">
<component :is="item.icon"></component>
</n-icon>
</n-space>
</template>
<component :is="item.render"></component>
</n-tab-pane>
</n-tabs>
2022-03-14 19:52:01 +08:00
</content-box>
2022-01-16 22:17:34 +08:00
</n-layout-sider>
</n-layout>
2022-01-06 13:45:51 +08:00
</template>
<script setup lang="ts">
2022-02-16 15:54:23 +08:00
import { ref, toRefs, watch, computed } from 'vue'
2022-01-06 13:45:51 +08:00
import { icon } from '@/plugins'
2022-02-16 15:54:23 +08:00
import { loadAsyncComponent } from '@/utils'
2022-01-06 15:37:44 +08:00
import { ContentBox } from '../ContentBox/index'
import { TabsEnum } from './index.d'
2022-01-08 21:01:52 +08:00
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
2022-01-20 21:25:35 +08:00
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
2022-03-04 20:57:36 +08:00
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
2022-01-08 21:01:52 +08:00
2022-01-16 22:17:34 +08:00
const { getDetails } = toRefs(useChartLayoutStore())
const { setItem } = useChartLayoutStore()
2022-03-04 20:57:36 +08:00
const chartEditStore = useChartEditStore()
2022-02-06 01:04:05 +08:00
const { ConstructIcon, FlashIcon, DesktopOutlineIcon, LeafIcon, RocketIcon } = icon.ionicons5
2022-01-06 15:37:44 +08:00
const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue'))
2022-08-09 21:08:25 +08:00
const CanvasPage = loadAsyncComponent(() => import('./components/CanvasPage/index.vue'))
const ChartSetting = loadAsyncComponent(() => import('./components/ChartSetting/index.vue'))
const ChartData = loadAsyncComponent(() => import('./components/ChartData/index.vue'))
const ChartEvent = loadAsyncComponent(() => import('./components/ChartEvent/index.vue'))
2022-08-09 21:08:25 +08:00
const ChartAnimation = loadAsyncComponent(() => import('./components/ChartAnimation/index.vue'))
2022-01-08 21:01:52 +08:00
2022-01-16 22:17:34 +08:00
const collapsed = ref<boolean>(getDetails.value)
const tabsSelect = ref<TabsEnum>(TabsEnum.CHART_SETTING)
2022-01-16 22:17:34 +08:00
2022-08-09 21:08:25 +08:00
const collapsedHandle = () => {
2022-01-16 22:17:34 +08:00
collapsed.value = true
2022-01-20 21:25:35 +08:00
setItem(ChartLayoutStoreEnum.DETAILS, true)
2022-01-16 22:17:34 +08:00
}
2022-08-09 21:08:25 +08:00
const expandHandle = () => {
2022-01-16 22:17:34 +08:00
collapsed.value = false
2022-01-20 21:25:35 +08:00
setItem(ChartLayoutStoreEnum.DETAILS, false)
2022-01-16 22:17:34 +08:00
}
2022-02-06 01:04:05 +08:00
const selectTarget = computed(() => {
2022-03-04 20:57:36 +08:00
const selectId = chartEditStore.getTargetChart.selectId
// 排除多个
if (selectId.length !== 1) return undefined
2022-08-09 21:08:25 +08:00
const target = chartEditStore.componentList[chartEditStore.fetchTargetIndex()]
if (target?.isGroup) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
tabsSelect.value = TabsEnum.CHART_SETTING
}
2022-08-09 21:08:25 +08:00
return target
2022-02-06 01:04:05 +08:00
})
watch(getDetails, newData => {
2022-01-16 22:17:34 +08:00
if (newData) {
2022-08-09 21:08:25 +08:00
collapsedHandle()
2022-01-16 22:17:34 +08:00
} else {
2022-08-09 21:08:25 +08:00
expandHandle()
2022-01-16 22:17:34 +08:00
}
})
2022-01-19 21:29:04 +08:00
// 页面设置
2022-02-08 19:39:57 +08:00
const globalTabList = [
2022-02-07 20:55:40 +08:00
{
key: TabsEnum.PAGE_SETTING,
2022-02-07 20:55:40 +08:00
title: '页面配置',
icon: DesktopOutlineIcon,
render: CanvasPage
}
2022-02-08 19:39:57 +08:00
]
2022-01-19 21:29:04 +08:00
2022-08-09 21:08:25 +08:00
const chartsDefaultTabList = [
2022-01-08 21:01:52 +08:00
{
key: TabsEnum.CHART_SETTING,
2022-02-07 20:55:40 +08:00
title: '定制',
2022-02-06 01:04:05 +08:00
icon: ConstructIcon,
2022-02-07 20:55:40 +08:00
render: ChartSetting
2022-01-08 21:01:52 +08:00
},
2022-03-09 09:21:47 +08:00
{
key: TabsEnum.CHART_ANIMATION,
2022-03-09 09:21:47 +08:00
title: '动画',
icon: LeafIcon,
render: ChartAnimation
2022-08-09 21:08:25 +08:00
}
]
const chartsTabList = [
...chartsDefaultTabList,
2022-01-08 21:01:52 +08:00
{
key: TabsEnum.CHART_DATA,
2022-02-04 18:28:02 +08:00
title: '数据',
2022-01-10 09:49:08 +08:00
icon: FlashIcon,
2022-02-22 15:32:57 +08:00
render: ChartData
2022-10-11 18:31:29 +08:00
},
{
key: TabsEnum.CHART_EVENT,
title: '事件',
icon: RocketIcon,
2022-10-11 18:31:29 +08:00
render: ChartEvent
2022-03-09 09:21:47 +08:00
}
2022-02-08 19:39:57 +08:00
]
2022-01-06 13:45:51 +08:00
</script>
2022-01-06 15:37:44 +08:00
<style lang="scss" scoped>
@include go(content-layers) {
2022-01-08 21:01:52 +08:00
overflow: hidden;
2022-02-25 21:26:56 +08:00
.tabs-box {
padding: 10px;
.icon-position {
padding-top: 2px;
}
2022-01-06 15:37:44 +08:00
}
}
2022-01-06 13:45:51 +08:00
</style>