index.vue
5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<template>
<n-layout has-sider sider-placement="right">
<n-layout-content>
<!-- 图表拖拽区域 -->
<content-edit></content-edit>
</n-layout-content>
<n-layout-sider
collapse-mode="transform"
:collapsed-width="0"
:width="350"
:collapsed="collapsed"
:native-scrollbar="false"
show-trigger="bar"
@collapse="collapsedHandle"
@expand="expandHandle"
>
<content-box class="go-content-configurations go-boderbox" :show-top="false" :depth="2">
<!-- 页面配置 -->
<n-tabs v-if="!selectTarget" class="tabs-box" size="small" type="segment">
<n-tab-pane
v-for="item in globalTabList"
:key="item.key"
:name="item.key"
size="small"
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>
<!-- 编辑 -->
<n-tabs v-if="selectTarget" v-model:value="tabsSelect" class="tabs-box" size="small" type="segment">
<n-tab-pane
v-for="item in selectTarget.isGroup ? chartsDefaultTabList : chartsTabList"
:key="item.key"
:name="item.key"
size="small"
display-directive="show:lazy"
>
<template #tab>
<div style="display: flex; flex-wrap: nowrap; justify-content: space-between; align-items: center">
<n-ellipsis style="max-width: 65px">
{{ item.title }}
</n-ellipsis>
<n-icon style="margin-left: 2px" size="16" class="icon-position">
<component :is="item.icon"></component>
</n-icon>
</div>
</template>
<component :is="item.render"></component>
</n-tab-pane>
</n-tabs>
</content-box>
</n-layout-sider>
</n-layout>
</template>
<script setup lang="ts">
import { ref, toRefs, watch, computed } from 'vue'
import { icon } from '@/plugins'
import { loadAsyncComponent } from '@/utils'
import { ContentBox } from '../../ContentBox/index'
import { TabsEnum } from './index.d'
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
const { getDetails } = toRefs(useChartLayoutStore())
const { setItem } = useChartLayoutStore()
const chartEditStore = useChartEditStore()
const { ConstructIcon, FlashIcon, DesktopOutlineIcon, LeafIcon, RocketIcon, AlbumsIcon } = icon.ionicons5
const ContentEdit = loadAsyncComponent(() => import('../../ContentEdit/index.vue'))
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 ThingsKitChartData = loadAsyncComponent(() => import('../components/external/ThingsKitChartData/index.vue')) //新增ThingsKit自定义分组数据页面
const ChartEvent = loadAsyncComponent(() => import('../components/ChartEvent/index.vue'))
const ChartAnimation = loadAsyncComponent(() => import('../components/ChartAnimation/index.vue'))
const collapsed = ref<boolean>(getDetails.value)
const tabsSelect = ref<TabsEnum>(TabsEnum.CHART_SETTING)
const t = window['$t']
const collapsedHandle = () => {
collapsed.value = true
setItem(ChartLayoutStoreEnum.DETAILS, true)
}
const expandHandle = () => {
collapsed.value = false
setItem(ChartLayoutStoreEnum.DETAILS, false)
}
const selectTarget = computed(() => {
const selectId = chartEditStore.getTargetChart.selectId
// 排除多个
if (selectId.length !== 1) return undefined
// const target = chartEditStore.componentList[chartEditStore.fetchTargetIndex()]
const target = chartEditStore.getComponentList[chartEditStore.fetchTargetIndex()]
if (target?.isGroup) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
tabsSelect.value = TabsEnum.CHART_SETTING
}
return target
})
watch(getDetails, newData => {
if (newData) {
collapsedHandle()
} else {
expandHandle()
}
})
// 页面设置
const globalTabList = [
{
key: TabsEnum.PAGE_SETTING,
title: t('external.pageConfigText'),
icon: DesktopOutlineIcon,
render: CanvasPage
}
]
//THINGS_KIT 新增分组支持数据绑定
const chartsDefaultTabList = [
{
key: TabsEnum.CHART_SETTING,
title: t('external.settingText'),
icon: ConstructIcon,
render: ChartSetting
},
{
key: TabsEnum.CHART_ANIMATION,
title: t('external.animationText'),
icon: LeafIcon,
render: ChartAnimation
},
{
key: TabsEnum.CHART_DATA,
title: t('external.dataText'),
icon: FlashIcon,
render: ChartData
},
{
key: TabsEnum.THINGS_KIT_CHART_DATA,
title: t('external.groupText'),
icon: AlbumsIcon,
render: ThingsKitChartData
}
]
const chartsTabList = [
...chartsDefaultTabList.slice(0, 2),
{
key: TabsEnum.CHART_DATA,
title: t('external.dataText'),
icon: FlashIcon,
render: ChartData
},
{
key: TabsEnum.CHART_EVENT,
title: t('external.eventText'),
icon: RocketIcon,
render: ChartEvent
}
]
</script>
<style lang="scss" scoped>
@include go(content-configurations) {
overflow: hidden;
.tabs-box {
padding: 10px;
.icon-position {
padding-top: 2px;
}
}
}
</style>