Commit 6fcb269ede9f6f17082e162dd3c00665ac8c4caa
Merge branch 'ft' into 'main_dev'
perf(src/): 优化给分组这个整体绑定动态数据,其下所有子组件共享分组数据,子组件支持动态设置自身数据 See merge request yunteng/thingskit-view!110
Showing
25 changed files
with
848 additions
and
12 deletions
8.96 KB
1 | import { ref, toRefs, toRaw, watch } from 'vue' | 1 | import { ref, toRefs, toRaw, watch } from 'vue' |
2 | import type VChart from 'vue-echarts' | 2 | import type VChart from 'vue-echarts' |
3 | import { useChartDataPondFetch } from '@/hooks/' | 3 | import { useChartDataPondFetch } from '@/hooks/' |
4 | -import { CreateComponentType, ChartFrameEnum } from '@/packages/index.d' | 4 | +import { CreateComponentType, ChartFrameEnum, CreateComponentGroupType } from '@/packages/index.d' |
5 | import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | 5 | import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' |
6 | import { isPreview, intervalUnitHandle } from '@/utils' | 6 | import { isPreview, intervalUnitHandle } from '@/utils' |
7 | import { setOption } from '@/packages/public/chart' | 7 | import { setOption } from '@/packages/public/chart' |
@@ -110,7 +110,18 @@ export const useChartDataFetch = ( | @@ -110,7 +110,18 @@ export const useChartDataFetch = ( | ||
110 | 110 | ||
111 | if (isPreview()) { | 111 | if (isPreview()) { |
112 | requestIntervalFn() | 112 | requestIntervalFn() |
113 | + const chartEditStore = useChartEditStore() | ||
113 | const { initial } = useChartDataSocket() | 114 | const { initial } = useChartDataSocket() |
115 | + /** | ||
116 | + * 支持分组也可以接受ws | ||
117 | + * 如果是分组并且绑定了ws | ||
118 | + */ | ||
119 | + chartEditStore.componentList.forEach((item:CreateComponentType | CreateComponentGroupType)=>{ | ||
120 | + if(item.request.requestUrl?.includes('ws')){ | ||
121 | + initial(item, useChartEditStore, updateCallback) | ||
122 | + } | ||
123 | + }) | ||
124 | + // | ||
114 | initial(targetComponent, useChartEditStore, updateCallback) | 125 | initial(targetComponent, useChartEditStore, updateCallback) |
115 | } | 126 | } |
116 | return { vChartRef } | 127 | return { vChartRef } |
1 | +import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public' | ||
2 | +import { OverrideDialConfig } from './index' | ||
3 | +import { CreateComponentType } from '@/packages/index.d' | ||
4 | +import cloneDeep from 'lodash/cloneDeep' | ||
5 | + | ||
6 | +export const includes = [] | ||
7 | +const option = { | ||
8 | + backgroundColor: '#0E1327', | ||
9 | + dataset:70, | ||
10 | + series: [{ | ||
11 | + type: "gauge", | ||
12 | + data: [{ | ||
13 | + value: 70, | ||
14 | + itemStyle: { // 指针样式 | ||
15 | + color: '#2AF4FF' | ||
16 | + } | ||
17 | + }], | ||
18 | + min: 0, //最小刻度 | ||
19 | + max: 100, //最大刻度 | ||
20 | + splitNumber: 10, //刻度数量 | ||
21 | + center: ['50%', '55%'], | ||
22 | + radius: '80%', | ||
23 | + axisLine: { | ||
24 | + lineStyle: { | ||
25 | + color: [ | ||
26 | + [0, 'rgba(0,212,230,0.5)'], | ||
27 | + [1, 'rgba(28,128,245,0)'] | ||
28 | + ], | ||
29 | + width: 170 | ||
30 | + } | ||
31 | + }, | ||
32 | + axisLabel: { // 文字样式 | ||
33 | + color: '#eee', | ||
34 | + fontSize: 14, | ||
35 | + }, | ||
36 | + axisTick: { | ||
37 | + show: false, | ||
38 | + }, | ||
39 | + splitLine: { | ||
40 | + show: false, | ||
41 | + }, | ||
42 | + detail: { | ||
43 | + show: false, | ||
44 | + }, | ||
45 | + pointer: { | ||
46 | + length: '80%', | ||
47 | + width: 4 | ||
48 | + }, | ||
49 | + animationDuration: 2000, | ||
50 | + }, | ||
51 | + { | ||
52 | + name: '外部刻度', | ||
53 | + type: 'gauge', | ||
54 | + center: ['50%', '55%'], | ||
55 | + radius: '90%', | ||
56 | + axisLine: { | ||
57 | + show: true, | ||
58 | + lineStyle: { | ||
59 | + width: 25, | ||
60 | + color: [ // 表盘外部颜色 | ||
61 | + [0, '#1369E380'], | ||
62 | + [1, '#1369E380'] | ||
63 | + ], | ||
64 | + } | ||
65 | + }, | ||
66 | + axisLabel: { | ||
67 | + show:false, | ||
68 | + }, | ||
69 | + axisTick: { | ||
70 | + splitNumber: 5, | ||
71 | + lineStyle: { //刻度颜色 | ||
72 | + color: '#42E5FB', | ||
73 | + width: 2, | ||
74 | + }, | ||
75 | + }, | ||
76 | + splitLine: { | ||
77 | + length: 15, | ||
78 | + lineStyle: { | ||
79 | + color: '#42E5FB', | ||
80 | + } | ||
81 | + }, | ||
82 | + }, | ||
83 | + ] | ||
84 | +}; | ||
85 | + | ||
86 | +export default class Config extends PublicConfigClass implements CreateComponentType { | ||
87 | + public key: string = OverrideDialConfig.key | ||
88 | + public chartConfig = cloneDeep(OverrideDialConfig) | ||
89 | + // 图表配置项 | ||
90 | + public option = echartOptionProfixHandle(option, includes) | ||
91 | +} |
1 | +<template> | ||
2 | + <!-- 遍历 seriesList --> | ||
3 | + <CollapseItem :name="`圆环`" :expanded="true"> | ||
4 | + <SettingItemBox name="数据"> | ||
5 | + <SettingItem name="数值"> | ||
6 | + <n-input-number v-model:value="config.dataset" :min="dialConfig.min" :max="dialConfig.max" :step="1" size="small" placeholder="数值"> | ||
7 | + </n-input-number> | ||
8 | + </SettingItem> | ||
9 | + </SettingItemBox> | ||
10 | + <!-- Echarts 全局设置 --> | ||
11 | + <!-- 表盘刻度字体 --> | ||
12 | + <SettingItemBox name="字体"> | ||
13 | + <SettingItem name="颜色"> | ||
14 | + <n-color-picker size="small" :modes="['hex']" v-model:value="dialConfig.axisLabel.color"></n-color-picker> | ||
15 | + </SettingItem> | ||
16 | + <SettingItem name="字体大小"> | ||
17 | + <n-input-number | ||
18 | + v-model:value="dialConfig.axisLabel.fontSize" | ||
19 | + :min="0" | ||
20 | + :step="1" | ||
21 | + size="small" | ||
22 | + placeholder="字体大小" | ||
23 | + > | ||
24 | + </n-input-number> | ||
25 | + </SettingItem> | ||
26 | + </SettingItemBox> | ||
27 | + <!-- 表盘 --> | ||
28 | + <SettingItemBox name="表盘外部"> | ||
29 | + <SettingItem name="颜色" > | ||
30 | + <n-color-picker size="small" :modes="['hex']" v-model:value="config.series[1].axisLine.lineStyle.color[1][1]"></n-color-picker> | ||
31 | + </SettingItem> | ||
32 | + </SettingItemBox> | ||
33 | + <!-- 指针 --> | ||
34 | + <SettingItemBox name="指针"> | ||
35 | + <SettingItem name="颜色" > | ||
36 | + <n-color-picker size="small" :modes="['hex']" v-model:value="dialConfig.data[0].itemStyle.color"></n-color-picker> | ||
37 | + </SettingItem> | ||
38 | + <SettingItem name="宽度"> | ||
39 | + <n-input-number v-model:value="dialConfig.pointer.width" :min="0" :step="1" size="small" placeholder="数值"> | ||
40 | + </n-input-number> | ||
41 | + </SettingItem> | ||
42 | + </SettingItemBox> | ||
43 | + <SettingItemBox name="刻度"> | ||
44 | + <SettingItem name="最小值"> | ||
45 | + <n-input-number v-model:value="dialConfig.min" :min="0" :step="1" size="small" placeholder="数值"> | ||
46 | + </n-input-number> | ||
47 | + </SettingItem> | ||
48 | + <SettingItem name="最大值"> | ||
49 | + <n-input-number v-model:value="dialConfig.max" :min="0" :step="1" size="small" placeholder="数值"> | ||
50 | + </n-input-number> | ||
51 | + </SettingItem> | ||
52 | + <SettingItem name="颜色" > | ||
53 | + <n-color-picker size="small" :modes="['hex']" v-model:value="config.series[1].axisTick.lineStyle.color" @update:value="updateClick"></n-color-picker> | ||
54 | + </SettingItem> | ||
55 | + </SettingItemBox> | ||
56 | + | ||
57 | + </CollapseItem> | ||
58 | + </template> | ||
59 | + | ||
60 | + <script setup lang="ts"> | ||
61 | + import { PropType, computed } from 'vue' | ||
62 | + import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | ||
63 | + import { GlobalThemeJsonType } from '@/settings/chartThemes' | ||
64 | + | ||
65 | + const props = defineProps({ | ||
66 | + optionData: { | ||
67 | + type: Object as PropType<GlobalThemeJsonType>, | ||
68 | + required: true | ||
69 | + } | ||
70 | + }) | ||
71 | + | ||
72 | + const config = computed(() => { | ||
73 | + return props.optionData | ||
74 | + }) | ||
75 | + | ||
76 | + const dialConfig = computed(() => { | ||
77 | + return props.optionData.series[0] | ||
78 | + }) | ||
79 | + | ||
80 | + const updateClick = (val: any) => { | ||
81 | + props.optionData.series[1].splitLine.lineStyle.color=val | ||
82 | + } | ||
83 | + </script> | ||
84 | + |
1 | +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' | ||
2 | +import { ChatCategoryEnum, ChatCategoryEnumName } from '@/packages/components/Charts/index.d' | ||
3 | +import { useWidgetKey } from '@/packages/external/useWidgetKey' | ||
4 | + | ||
5 | +const { key, conKey, chartKey } = useWidgetKey('OverrideDial', true) | ||
6 | + | ||
7 | +export const OverrideDialConfig: ConfigType = { | ||
8 | + key, | ||
9 | + chartKey, | ||
10 | + conKey, | ||
11 | + title: '自定义表盘', | ||
12 | + category: ChatCategoryEnum.MORE, | ||
13 | + categoryName: ChatCategoryEnumName.MORE, | ||
14 | + package: PackagesCategoryEnum.CHARTS, | ||
15 | + chartFrame: ChartFrameEnum.COMMON, | ||
16 | + image: 'dial.png' | ||
17 | +} |
1 | +<template> | ||
2 | + <v-chart :theme="themeColor" :init-options="initOptions" :option="option.value" autoresize> </v-chart> | ||
3 | +</template> | ||
4 | + | ||
5 | +<script setup lang="ts"> | ||
6 | +import { PropType, reactive, watch } from 'vue' | ||
7 | +import VChart from 'vue-echarts' | ||
8 | +import { useCanvasInitOptions } from '@/hooks/useCanvasInitOptions.hook' | ||
9 | +import { use } from 'echarts/core' | ||
10 | +import { CanvasRenderer } from 'echarts/renderers' | ||
11 | +import { PieChart } from 'echarts/charts' | ||
12 | +import { mergeTheme } from '@/packages/public/chart' | ||
13 | +import config, { includes } from './config' | ||
14 | +import { useChartDataFetch } from '@/hooks' | ||
15 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
16 | +import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent, TitleComponent } from 'echarts/components' | ||
17 | + | ||
18 | +const props = defineProps({ | ||
19 | + themeSetting: { | ||
20 | + type: Object, | ||
21 | + required: true | ||
22 | + }, | ||
23 | + themeColor: { | ||
24 | + type: Object, | ||
25 | + required: true | ||
26 | + }, | ||
27 | + chartConfig: { | ||
28 | + type: Object as PropType<config>, | ||
29 | + required: true | ||
30 | + } | ||
31 | +}) | ||
32 | + | ||
33 | +const initOptions = useCanvasInitOptions(props.chartConfig.option, props.themeSetting) | ||
34 | + | ||
35 | +use([DatasetComponent, CanvasRenderer, PieChart, GridComponent, TooltipComponent, LegendComponent, TitleComponent]) | ||
36 | + | ||
37 | +const option:any = reactive({ | ||
38 | + value: {} | ||
39 | +}) | ||
40 | + | ||
41 | +const dataHandle = (newData: any) => { | ||
42 | + let config = props.chartConfig.option | ||
43 | + config.series[0].data[0].value = newData | ||
44 | + option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes) | ||
45 | + option.value = props.chartConfig.option | ||
46 | +} | ||
47 | + | ||
48 | +// 配置时 | ||
49 | +watch( | ||
50 | + () => props.chartConfig.option.dataset, | ||
51 | + newData => { | ||
52 | + try { | ||
53 | + dataHandle(newData) | ||
54 | + } catch (error) { | ||
55 | + console.log(error) | ||
56 | + } | ||
57 | + }, | ||
58 | + { | ||
59 | + immediate: true, | ||
60 | + deep: false | ||
61 | + } | ||
62 | +) | ||
63 | + | ||
64 | +// 预览时 | ||
65 | +useChartDataFetch(props.chartConfig, useChartEditStore, (resData: any) => { | ||
66 | + if (Object.prototype.toString.call(resData) === '[object Object]') { | ||
67 | + const key = Object.keys(resData?.data) | ||
68 | + const value = Object.fromEntries(resData?.data[key[0]]) | ||
69 | + const singleKey = Object.keys(value) | ||
70 | + const singleValue = value[singleKey[0]] | ||
71 | + option.value.series[0].data[0].value = singleValue | ||
72 | + } else { | ||
73 | + option.value.series[0].data[0].value = resData | ||
74 | + } | ||
75 | +}) | ||
76 | +</script> |
@@ -12,6 +12,6 @@ export const ButtonConfig: ConfigType = { | @@ -12,6 +12,6 @@ export const ButtonConfig: ConfigType = { | ||
12 | category: ChatCategoryEnum.INPUTS, | 12 | category: ChatCategoryEnum.INPUTS, |
13 | categoryName: ChatCategoryEnumName.INPUTS, | 13 | categoryName: ChatCategoryEnumName.INPUTS, |
14 | package: PackagesCategoryEnum.INFORMATIONS, | 14 | package: PackagesCategoryEnum.INFORMATIONS, |
15 | - chartFrame: ChartFrameEnum.STATIC, | 15 | + chartFrame: ChartFrameEnum.COMMON, |
16 | image: 'button.png' | 16 | image: 'button.png' |
17 | } | 17 | } |
@@ -13,6 +13,6 @@ export const OverrideInputsDateConfig: ConfigType = { | @@ -13,6 +13,6 @@ export const OverrideInputsDateConfig: ConfigType = { | ||
13 | category: ChatCategoryEnum.INPUTS, | 13 | category: ChatCategoryEnum.INPUTS, |
14 | categoryName: ChatCategoryEnumName.INPUTS, | 14 | categoryName: ChatCategoryEnumName.INPUTS, |
15 | package: PackagesCategoryEnum.INFORMATIONS, | 15 | package: PackagesCategoryEnum.INFORMATIONS, |
16 | - chartFrame: ChartFrameEnum.STATIC, | 16 | + chartFrame: ChartFrameEnum.COMMON, |
17 | image: 'inputs_date.png' | 17 | image: 'inputs_date.png' |
18 | } | 18 | } |
1 | +import cloneDeep from 'lodash/cloneDeep' | ||
2 | +import { PublicConfigClass } from '@/packages/public' | ||
3 | +import { CreateComponentType } from '@/packages/index.d' | ||
4 | +import { chartInitConfig } from '@/settings/designSetting' | ||
5 | +import { COMPONENT_INTERACT_EVENT_KET } from '@/enums/eventEnum' | ||
6 | +import { interactActions, ComponentInteractEventEnum } from './interact' | ||
7 | +import { TreeConfig } from './index' | ||
8 | + | ||
9 | +export const option = { | ||
10 | + // 时间组件展示类型,必须和 interactActions 中定义的数据一致 | ||
11 | + [COMPONENT_INTERACT_EVENT_KET]: ComponentInteractEventEnum.DATA, | ||
12 | + // 暴露配置内容给用户 | ||
13 | + dataset: [ | ||
14 | + { | ||
15 | + id: '1', | ||
16 | + name: '根组织', | ||
17 | + children: [ | ||
18 | + { | ||
19 | + id: '11', | ||
20 | + name: '第一级' | ||
21 | + }, | ||
22 | + { | ||
23 | + id: '12', | ||
24 | + name: '第二级' | ||
25 | + }, | ||
26 | + { | ||
27 | + id: '13', | ||
28 | + name: '第三级' | ||
29 | + } | ||
30 | + ] | ||
31 | + } | ||
32 | + ], | ||
33 | + treeConfig: { | ||
34 | + accordion: false, | ||
35 | + checkable: false, | ||
36 | + defaultExpandAll: false | ||
37 | + } | ||
38 | +} | ||
39 | + | ||
40 | +export default class Config extends PublicConfigClass implements CreateComponentType { | ||
41 | + public key = TreeConfig.key | ||
42 | + public attr = { ...chartInitConfig, w: 300, h: 40, zIndex: -1 } | ||
43 | + public chartConfig = cloneDeep(TreeConfig) | ||
44 | + public interactActions = interactActions | ||
45 | + public option = cloneDeep(option) | ||
46 | +} |
1 | +<template> | ||
2 | + <collapse-item name="树配置" :expanded="true"> | ||
3 | + <setting-item-box name="手风琴"> | ||
4 | + <setting-item name="是否开启"> | ||
5 | + <n-switch v-model:value="optionData.treeConfig.accordion" /> | ||
6 | + </setting-item> | ||
7 | + </setting-item-box> | ||
8 | + <setting-item-box name="选择框"> | ||
9 | + <setting-item name="是否开启"> | ||
10 | + <n-switch v-model:value="optionData.treeConfig.checkable" /> | ||
11 | + </setting-item> | ||
12 | + </setting-item-box> | ||
13 | + <setting-item-box name="展开"> | ||
14 | + <setting-item name="是否开启"> | ||
15 | + <n-switch v-model:value="optionData.treeConfig.defaultExpandAll" /> | ||
16 | + </setting-item> | ||
17 | + </setting-item-box> | ||
18 | + </collapse-item> | ||
19 | +</template> | ||
20 | + | ||
21 | +<script lang="ts" setup> | ||
22 | +import { PropType } from 'vue' | ||
23 | +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | ||
24 | +import { option } from './config' | ||
25 | + | ||
26 | +defineProps({ | ||
27 | + optionData: { | ||
28 | + type: Object as PropType<typeof option>, | ||
29 | + required: true | ||
30 | + } | ||
31 | +}) | ||
32 | +</script> | ||
33 | +<style lang="scss" scoped></style> |
1 | +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' | ||
2 | +import { ChatCategoryEnum, ChatCategoryEnumName } from '@/packages/components/Informations/index.d' | ||
3 | +import { useWidgetKey } from '@/packages/external/useWidgetKey' | ||
4 | + | ||
5 | +const { key, conKey, chartKey } = useWidgetKey('Tree', true) | ||
6 | + | ||
7 | +export const TreeConfig: ConfigType = { | ||
8 | + key, | ||
9 | + chartKey, | ||
10 | + conKey, | ||
11 | + title: '自定义树形控件', | ||
12 | + category: ChatCategoryEnum.INPUTS, | ||
13 | + categoryName: ChatCategoryEnumName.INPUTS, | ||
14 | + package: PackagesCategoryEnum.INFORMATIONS, | ||
15 | + chartFrame: ChartFrameEnum.COMMON, | ||
16 | + image: 'tree.png' | ||
17 | +} |
1 | +<template> | ||
2 | + <div> | ||
3 | + <n-tree | ||
4 | + :accordion="treeConfig.accordion" | ||
5 | + :checkable="treeConfig.checkable" | ||
6 | + :default-expand-all="treeConfig.defaultExpandAll" | ||
7 | + block-line | ||
8 | + block-node | ||
9 | + :data="dataset" | ||
10 | + key-field="id" | ||
11 | + label-field="name" | ||
12 | + children-field="children" | ||
13 | + @update:selected-keys="onClick" | ||
14 | + /> | ||
15 | + </div> | ||
16 | +</template> | ||
17 | + | ||
18 | +<script setup lang="ts"> | ||
19 | +import { PropType, toRefs } from 'vue' | ||
20 | +import { CreateComponentType } from '@/packages/index.d' | ||
21 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
22 | +import { useChartInteract } from '@/hooks/external/useChartSelectInteract.hook' | ||
23 | +import { InteractEventOn } from '@/enums/eventEnum' | ||
24 | +import { ComponentInteractParamsEnum } from './interact' | ||
25 | + | ||
26 | +const props = defineProps({ | ||
27 | + chartConfig: { | ||
28 | + type: Object as PropType<CreateComponentType>, | ||
29 | + required: true | ||
30 | + } | ||
31 | +}) | ||
32 | + | ||
33 | +const { dataset, treeConfig } = toRefs(props.chartConfig.option) | ||
34 | + | ||
35 | +const onClick = (v: string[]) => { | ||
36 | + useChartInteract( | ||
37 | + props.chartConfig, | ||
38 | + useChartEditStore, | ||
39 | + { [ComponentInteractParamsEnum.DATA]: v[0] }, | ||
40 | + InteractEventOn.CHANGE | ||
41 | + ) | ||
42 | +} | ||
43 | +</script> | ||
44 | + | ||
45 | +<style lang="scss" scoped></style> |
1 | +import { InteractEventOn, InteractActionsType } from '@/enums/eventEnum' | ||
2 | + | ||
3 | +// 时间组件类型 | ||
4 | +export enum ComponentInteractEventEnum { | ||
5 | + DATA = 'data' | ||
6 | +} | ||
7 | + | ||
8 | +// 联动参数 | ||
9 | +export enum ComponentInteractParamsEnum { | ||
10 | + DATA = 'data' | ||
11 | +} | ||
12 | + | ||
13 | +// 定义组件触发回调事件 | ||
14 | +export const interactActions: InteractActionsType[] = [ | ||
15 | + { | ||
16 | + interactType: InteractEventOn.CHANGE, | ||
17 | + interactName: '选择完成', | ||
18 | + componentEmitEvents: { | ||
19 | + [ComponentInteractEventEnum.DATA]: [ | ||
20 | + { | ||
21 | + value: ComponentInteractParamsEnum.DATA, | ||
22 | + label: '选择项' | ||
23 | + } | ||
24 | + ] | ||
25 | + } | ||
26 | + } | ||
27 | +] |
@@ -70,7 +70,17 @@ const transitionDuration = computed(() => { | @@ -70,7 +70,17 @@ const transitionDuration = computed(() => { | ||
70 | 70 | ||
71 | // 预览更新 | 71 | // 预览更新 |
72 | useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => { | 72 | useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => { |
73 | - option.dataset = newData | 73 | + const chartEditStore = useChartEditStore() |
74 | + //判断只要是分组并且分组绑定了ws | ||
75 | + let hasGroupWs = false | ||
76 | + chartEditStore.componentList.some((item: CreateComponentType) => { | ||
77 | + if (item.request.requestUrl?.includes('ws')) { | ||
78 | + hasGroupWs = true | ||
79 | + } | ||
80 | + }) | ||
81 | + if (!hasGroupWs) { | ||
82 | + option.dataset = newData | ||
83 | + } | ||
74 | }) | 84 | }) |
75 | </script> | 85 | </script> |
76 | 86 |
@@ -57,7 +57,17 @@ watch( | @@ -57,7 +57,17 @@ watch( | ||
57 | 57 | ||
58 | // 预览更新 | 58 | // 预览更新 |
59 | useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => { | 59 | useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => { |
60 | - option.dataset = newData | 60 | + const chartEditStore = useChartEditStore() |
61 | + //判断只要是分组并且分组绑定了ws | ||
62 | + let hasGroupWs = false | ||
63 | + chartEditStore.componentList.some((item: CreateComponentType) => { | ||
64 | + if (item.request.requestUrl?.includes('ws')) { | ||
65 | + hasGroupWs = true | ||
66 | + } | ||
67 | + }) | ||
68 | + if (!hasGroupWs) { | ||
69 | + option.dataset = newData | ||
70 | + } | ||
61 | }) | 71 | }) |
62 | 72 | ||
63 | //打开链接 | 73 | //打开链接 |
@@ -38,7 +38,17 @@ watch( | @@ -38,7 +38,17 @@ watch( | ||
38 | ) | 38 | ) |
39 | 39 | ||
40 | useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { | 40 | useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { |
41 | - option.dataset = newData | 41 | + const chartEditStore = useChartEditStore() |
42 | + //判断只要是分组并且分组绑定了ws | ||
43 | + let hasGroupWs = false | ||
44 | + chartEditStore.componentList.some((item: CreateComponentType) => { | ||
45 | + if (item.request.requestUrl?.includes('ws')) { | ||
46 | + hasGroupWs = true | ||
47 | + } | ||
48 | + }) | ||
49 | + if (!hasGroupWs) { | ||
50 | + option.dataset = newData | ||
51 | + } | ||
42 | }) | 52 | }) |
43 | </script> | 53 | </script> |
44 | 54 |
@@ -11,6 +11,7 @@ import { OverrideInputsDateConfig } from '@/packages/components/external/Informa | @@ -11,6 +11,7 @@ import { OverrideInputsDateConfig } from '@/packages/components/external/Informa | ||
11 | import { OverrideInputsTabConfig } from '@/packages/components/external/Informations/Inputs/OverrideInputsTab' | 11 | import { OverrideInputsTabConfig } from '@/packages/components/external/Informations/Inputs/OverrideInputsTab' |
12 | import { OverrideIframeConfig } from '@/packages/components/external/Informations/Mores/OverrideIframe' | 12 | import { OverrideIframeConfig } from '@/packages/components/external/Informations/Mores/OverrideIframe' |
13 | import { ButtonConfig } from '@/packages/components/external/Informations/Inputs/Button' | 13 | import { ButtonConfig } from '@/packages/components/external/Informations/Inputs/Button' |
14 | +import { TreeConfig } from '@/packages/components/external/Informations/Inputs/Tree' | ||
14 | import { OverrideTextCommonConfig } from '@/packages/components/external/Informations/Texts/OverrideTextCommon' | 15 | import { OverrideTextCommonConfig } from '@/packages/components/external/Informations/Texts/OverrideTextCommon' |
15 | import { OverrideTextBarrageConfig } from '@/packages/components/external/Informations/Texts/OverrideTextBarrage' | 16 | import { OverrideTextBarrageConfig } from '@/packages/components/external/Informations/Texts/OverrideTextBarrage' |
16 | import { OverrideTextGradientConfig } from '@/packages/components/external/Informations/Texts/OverrideTextGradient' | 17 | import { OverrideTextGradientConfig } from '@/packages/components/external/Informations/Texts/OverrideTextGradient' |
@@ -22,6 +23,7 @@ import { OverridePieCircleConfig } from '@/packages/components/external/Charts/P | @@ -22,6 +23,7 @@ import { OverridePieCircleConfig } from '@/packages/components/external/Charts/P | ||
22 | import { OverrideMapBaseConfig } from '@/packages/components/external/Charts/Maps/OverrideMapBase' | 23 | import { OverrideMapBaseConfig } from '@/packages/components/external/Charts/Maps/OverrideMapBase' |
23 | import { OverrideVideoConfig } from '@/packages/components/external/Informations/Mores/OverrideVideo' | 24 | import { OverrideVideoConfig } from '@/packages/components/external/Informations/Mores/OverrideVideo' |
24 | import { OverrideWaterPoloConfig } from '@/packages/components/external/Charts/Mores/OverrideWaterPolo' | 25 | import { OverrideWaterPoloConfig } from '@/packages/components/external/Charts/Mores/OverrideWaterPolo' |
26 | +import { OverrideDialConfig } from '@/packages/components/external/Charts/Mores/OverrideDial' | ||
25 | import { OverrideLineRealTimeConfig } from '@/packages/components/external/Charts/Lines/OverrideLineRealTime' | 27 | import { OverrideLineRealTimeConfig } from '@/packages/components/external/Charts/Lines/OverrideLineRealTime' |
26 | import { ThreeDimensionalConfig } from '@/packages/components/external/Decorates/Three/ThreeDimensional' | 28 | import { ThreeDimensionalConfig } from '@/packages/components/external/Decorates/Three/ThreeDimensional' |
27 | import { Headline1Config } from '@/packages/components/external/Decorates/Headline/Headline1' | 29 | import { Headline1Config } from '@/packages/components/external/Decorates/Headline/Headline1' |
@@ -80,6 +82,7 @@ export function useInjectLib(packagesList: EPackagesType) { | @@ -80,6 +82,7 @@ export function useInjectLib(packagesList: EPackagesType) { | ||
80 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideCarouselConfig)//重写信息下的轮播图 | 82 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideCarouselConfig)//重写信息下的轮播图 |
81 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideSelectConfig)//重写信息下的select | 83 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideSelectConfig)//重写信息下的select |
82 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, ButtonConfig)//新增信息下的按钮 | 84 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, ButtonConfig)//新增信息下的按钮 |
85 | + addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, TreeConfig)//新增信息下的树形控件 | ||
83 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideIframeConfig)//重写信息下的远程加载网页 | 86 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideIframeConfig)//重写信息下的远程加载网页 |
84 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsDateConfig)//重写信息下的日期 | 87 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsDateConfig)//重写信息下的日期 |
85 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsTabConfig)//重写信息下的tab | 88 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsTabConfig)//重写信息下的tab |
@@ -102,6 +105,7 @@ export function useInjectLib(packagesList: EPackagesType) { | @@ -102,6 +105,7 @@ export function useInjectLib(packagesList: EPackagesType) { | ||
102 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverridePieCircleConfig)//重写图表下的饼图 | 105 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverridePieCircleConfig)//重写图表下的饼图 |
103 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideMapBaseConfig)//重写图表下的地图 | 106 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideMapBaseConfig)//重写图表下的地图 |
104 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideWaterPoloConfig)//重写图表下的水球图 | 107 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideWaterPoloConfig)//重写图表下的水球图 |
108 | + addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideDialConfig)//重写图表下的表盘 | ||
105 | // | 109 | // |
106 | } | 110 | } |
107 | 111 |
@@ -160,6 +160,7 @@ export interface CreateComponentType extends PublicConfigType, requestConfig { | @@ -160,6 +160,7 @@ export interface CreateComponentType extends PublicConfigType, requestConfig { | ||
160 | chartConfig: ConfigType | 160 | chartConfig: ConfigType |
161 | option: GlobalThemeJsonType | 161 | option: GlobalThemeJsonType |
162 | groupList?: Array<CreateComponentType> | 162 | groupList?: Array<CreateComponentType> |
163 | + saveHistoryInput?:string // THINGS_KIT 新增一个接口字段 saveHistoryInput,用于记录当前组件id和输入框的内容,这里不能重写,有很多地方引用到的,这里升级版本有冲突 | ||
163 | } | 164 | } |
164 | 165 | ||
165 | // 组件成组实例类 | 166 | // 组件成组实例类 |
@@ -262,7 +262,32 @@ export const useSocketStore = defineStore({ | @@ -262,7 +262,32 @@ export const useSocketStore = defineStore({ | ||
262 | */ | 262 | */ |
263 | chartEditStore.getComponentList.forEach(targetItem => { | 263 | chartEditStore.getComponentList.forEach(targetItem => { |
264 | if (targetItem.isGroup) { | 264 | if (targetItem.isGroup) { |
265 | - //分组 | 265 | + /** |
266 | + * 如果是分组,并且request里是ws,则分组组件这个整体是接受ws绑定的,之前分组是不能绑定ws的 | ||
267 | + */ | ||
268 | + if(targetItem.request.requestUrl?.includes('ws')){ | ||
269 | + const _value = this.getComponentValueByKeys(targetItem, value) | ||
270 | + const { filter } = targetItem | ||
271 | + const { value: filterValue, reason, flag } = useFilterFn(filter, _value) | ||
272 | + targetItem.option.dataset = flag ? filterValue : reason | ||
273 | + try{ | ||
274 | + const dumpSaveHistoryInput = JSON.parse((!targetItem.saveHistoryInput ? null: targetItem.saveHistoryInput) as string) ||JSON.parse(window.localStorage.getItem('CACHE_HISTORY_INPUT_VALUE') as string) | ||
275 | + if(!dumpSaveHistoryInput) return | ||
276 | + if(!Array.isArray(dumpSaveHistoryInput)) return | ||
277 | + targetItem.groupList?.forEach((item:CreateComponentType)=>{ | ||
278 | + dumpSaveHistoryInput?.forEach((inputItem:{id:string,inputValue:string})=>{ | ||
279 | + if(item.id === inputItem.id){ | ||
280 | + item.option.dataset= Function('res', `return ${inputItem?.inputValue}`)(targetItem.option?.dataset) | ||
281 | + } | ||
282 | + }) | ||
283 | + }) | ||
284 | + }catch(e){ | ||
285 | + console.log(e) | ||
286 | + } | ||
287 | + } | ||
288 | + /** | ||
289 | + * 这也是分组,但这个是分组这个整体不绑定ws,而是下面的子组件都绑定了ws | ||
290 | + */ | ||
266 | targetItem.groupList?.forEach(groupItem => { | 291 | targetItem.groupList?.forEach(groupItem => { |
267 | if (groupItem.id === id) { | 292 | if (groupItem.id === id) { |
268 | const _value = this.getComponentValueByKeys(groupItem, value) | 293 | const _value = this.getComponentValueByKeys(groupItem, value) |
@@ -24,7 +24,8 @@ export const hideAsideComponentsObj = { | @@ -24,7 +24,8 @@ export const hideAsideComponentsObj = { | ||
24 | 'VImageCarousel', //轮播图 | 24 | 'VImageCarousel', //轮播图 |
25 | 'VVideo', //视频 | 25 | 'VVideo', //视频 |
26 | 'VIframe', //远程网页 | 26 | 'VIframe', //远程网页 |
27 | - 'VWaterPolo' //水球图 | 27 | + 'VWaterPolo', //水球图 |
28 | + 'VDial', //表盘 | ||
28 | ], | 29 | ], |
29 | Texts: [ | 30 | Texts: [ |
30 | 'VTextGradient', //渐变文字 | 31 | 'VTextGradient', //渐变文字 |
@@ -52,6 +53,7 @@ export const hideAsideComponentsObj = { | @@ -52,6 +53,7 @@ export const hideAsideComponentsObj = { | ||
52 | 'VIframe', //远程网页 | 53 | 'VIframe', //远程网页 |
53 | 'VImageCarousel', //轮播图 | 54 | 'VImageCarousel', //轮播图 |
54 | 'VWaterPolo', //水球图 | 55 | 'VWaterPolo', //水球图 |
56 | + 'VDial', //表盘 | ||
55 | 'VInputsTab', //标签选择器 | 57 | 'VInputsTab', //标签选择器 |
56 | 'VInputsSelect', //下拉选择器 | 58 | 'VInputsSelect', //下拉选择器 |
57 | 'VInputsDate' //日期选择器 | 59 | 'VInputsDate' //日期选择器 |
1 | +type Params = { | ||
2 | + [key: string]: string | ||
3 | +} | ||
4 | + | ||
5 | +type ArrayParams = Params[] | ||
6 | + | ||
7 | +export type historyInputValue = { id: string; inputValue: string } | ||
8 | + | ||
9 | +//dataset数据源数据类型不确定,String Array Object Number | ||
10 | +export type datasetType = string | number | Params | ArrayParams | ||
11 | + | ||
12 | +export type saveHistoryInputValueListType = historyInputValue[] |
1 | +<template> | ||
2 | + <div class="go-chart-configurations-data" v-if="targetData"> | ||
3 | + <n-space vertical> | ||
4 | + <n-tag type="success"> 分组返回的数据源 </n-tag> | ||
5 | + <n-card size="small"> | ||
6 | + <n-code word-wrap :code="toString(targetData.option.dataset)" language="json"></n-code> | ||
7 | + </n-card> | ||
8 | + <n-tag type="info"> 使用res点语法或者res中括号语法 </n-tag> | ||
9 | + <n-tag type="warning">示例:res.xxxx</n-tag> | ||
10 | + <span>测试一下</span> | ||
11 | + <n-input type="textarea" @input="handleTestInput($event, option)" size="small" placeholder="请输入"></n-input> | ||
12 | + <n-code word-wrap :code="toString(testInputValue)" language="json"></n-code> | ||
13 | + <n-divider /> | ||
14 | + <div v-for="(item, index) in groupList" :key="item.key + index"> | ||
15 | + <n-space justify="space-between"> | ||
16 | + <n-ellipsis> 组件id </n-ellipsis> | ||
17 | + <n-input size="small" v-model:value="item.id" :disabled="true"></n-input> | ||
18 | + </n-space> | ||
19 | + <n-space justify="space-between"> | ||
20 | + <n-ellipsis> 组件名称 </n-ellipsis> | ||
21 | + <n-input size="small" v-model:value="item.chartConfig.title" :disabled="true"></n-input> | ||
22 | + </n-space> | ||
23 | + <n-space vertical justify="space-between"> | ||
24 | + <n-ellipsis> 设置数据 </n-ellipsis> | ||
25 | + <n-input | ||
26 | + type="textarea" | ||
27 | + @update:value="handleInput(groupList!, item.id, $event)" | ||
28 | + size="small" | ||
29 | + :placeholder="String(item.option.dataset)" | ||
30 | + ></n-input> | ||
31 | + </n-space> | ||
32 | + <n-divider /> | ||
33 | + </div> | ||
34 | + </n-space> | ||
35 | + </div> | ||
36 | +</template> | ||
37 | + | ||
38 | +<script setup lang="ts"> | ||
39 | +import { toRefs, ref, watch } from 'vue' | ||
40 | +import { useTargetData } from '../../hooks/useTargetData.hook' | ||
41 | +import { toString } from '@/utils' | ||
42 | +import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' | ||
43 | +import { datasetType, saveHistoryInputValueListType, historyInputValue } from './index.d' | ||
44 | +import { GlobalThemeJsonType } from '@/settings/chartThemes/index' | ||
45 | +import { uniqBy } from 'lodash' | ||
46 | + | ||
47 | +const { targetData } = useTargetData() | ||
48 | + | ||
49 | +const { groupList, option } = toRefs(targetData.value) | ||
50 | + | ||
51 | +const testInputValue = ref('') | ||
52 | + | ||
53 | +const saveHistoryInputValueList = ref<saveHistoryInputValueListType>([]) | ||
54 | + | ||
55 | +const handleInput = (groupList: CreateComponentType[], id: string, inputValue: string) => { | ||
56 | + saveHistoryInputValueList.value.unshift({ | ||
57 | + id, | ||
58 | + inputValue | ||
59 | + }) | ||
60 | + handleGroupListById(groupList, id, inputValue, option.value.dataset) | ||
61 | +} | ||
62 | + | ||
63 | +const executeFn = (inputValue: string, dataset: datasetType) => { | ||
64 | + try { | ||
65 | + return Function('res', `return ${inputValue}`)(dataset) | ||
66 | + } catch (e) { | ||
67 | + return inputValue | ||
68 | + } | ||
69 | +} | ||
70 | + | ||
71 | +const setTargetDataset = (inputValue: string, dataset: datasetType) => { | ||
72 | + //不能用!,会排除0,0也是需要显示的 | ||
73 | + return executeFn(inputValue, dataset) === undefined ? '' : executeFn(inputValue, dataset) | ||
74 | +} | ||
75 | + | ||
76 | +const handleGroupListById = ( | ||
77 | + groupList: CreateComponentType[], | ||
78 | + id: string, | ||
79 | + inputValue: string, | ||
80 | + dataset: datasetType | ||
81 | +) => { | ||
82 | + //原生for循环优化性能 | ||
83 | + for (let index = 0, total = groupList.length; index < total; index++) { | ||
84 | + const targetItem = groupList[index] | ||
85 | + if (id === targetItem.id) targetItem.option.dataset = setTargetDataset(inputValue, dataset) | ||
86 | + } | ||
87 | +} | ||
88 | + | ||
89 | +//测试返回 | ||
90 | +const handleTestInput = (inputValue: string, { dataset }: GlobalThemeJsonType) => { | ||
91 | + testInputValue.value = setTargetDataset(inputValue, dataset) | ||
92 | +} | ||
93 | + | ||
94 | +watch( | ||
95 | + () => targetData.value, | ||
96 | + (newValue: CreateComponentType | CreateComponentGroupType) => { | ||
97 | + try { | ||
98 | + const uniqHistoryInputValueList = uniqBy(saveHistoryInputValueList.value, 'id') | ||
99 | + if (uniqHistoryInputValueList) { | ||
100 | + newValue.saveHistoryInput = JSON.stringify(uniqHistoryInputValueList) | ||
101 | + window.localStorage.setItem('CACHE_HISTORY_INPUT_VALUE', JSON.stringify(uniqHistoryInputValueList)) | ||
102 | + } | ||
103 | + newValue?.groupList?.forEach((item: CreateComponentType) => { | ||
104 | + uniqHistoryInputValueList.forEach((uniqueItem: historyInputValue) => { | ||
105 | + if (uniqueItem.id === item.id) { | ||
106 | + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
107 | + handleGroupListById(newValue.groupList!, uniqueItem.id, uniqueItem.inputValue, newValue.option.dataset) | ||
108 | + } | ||
109 | + }) | ||
110 | + }) | ||
111 | + } catch (e) { | ||
112 | + console.log(e) | ||
113 | + } | ||
114 | + }, | ||
115 | + { | ||
116 | + deep: true | ||
117 | + } | ||
118 | +) | ||
119 | +</script> |
1 | +<template> | ||
2 | + <n-layout has-sider sider-placement="right"> | ||
3 | + <n-layout-content> | ||
4 | + <!-- 图表拖拽区域 --> | ||
5 | + <content-edit></content-edit> | ||
6 | + </n-layout-content> | ||
7 | + <n-layout-sider | ||
8 | + collapse-mode="transform" | ||
9 | + :collapsed-width="0" | ||
10 | + :width="350" | ||
11 | + :collapsed="collapsed" | ||
12 | + :native-scrollbar="false" | ||
13 | + show-trigger="bar" | ||
14 | + @collapse="collapsedHandle" | ||
15 | + @expand="expandHandle" | ||
16 | + > | ||
17 | + <content-box class="go-content-configurations go-boderbox" :show-top="false" :depth="2"> | ||
18 | + <!-- 页面配置 --> | ||
19 | + <n-tabs v-if="!selectTarget" class="tabs-box" size="small" type="segment"> | ||
20 | + <n-tab-pane | ||
21 | + v-for="item in globalTabList" | ||
22 | + :key="item.key" | ||
23 | + :name="item.key" | ||
24 | + size="small" | ||
25 | + display-directive="show:lazy" | ||
26 | + > | ||
27 | + <template #tab> | ||
28 | + <n-space> | ||
29 | + <span>{{ item.title }}</span> | ||
30 | + <n-icon size="16" class="icon-position"> | ||
31 | + <component :is="item.icon"></component> | ||
32 | + </n-icon> | ||
33 | + </n-space> | ||
34 | + </template> | ||
35 | + <component :is="item.render"></component> | ||
36 | + </n-tab-pane> | ||
37 | + </n-tabs> | ||
38 | + | ||
39 | + <!-- 编辑 --> | ||
40 | + <n-tabs v-if="selectTarget" v-model:value="tabsSelect" class="tabs-box" size="small" type="segment"> | ||
41 | + <n-tab-pane | ||
42 | + v-for="item in selectTarget.isGroup ? chartsDefaultTabList : chartsTabList" | ||
43 | + :key="item.key" | ||
44 | + :name="item.key" | ||
45 | + size="small" | ||
46 | + display-directive="show:lazy" | ||
47 | + > | ||
48 | + <template #tab> | ||
49 | + <n-space> | ||
50 | + <span>{{ item.title }}</span> | ||
51 | + <n-icon size="16" class="icon-position"> | ||
52 | + <component :is="item.icon"></component> | ||
53 | + </n-icon> | ||
54 | + </n-space> | ||
55 | + </template> | ||
56 | + <component :is="item.render"></component> | ||
57 | + </n-tab-pane> | ||
58 | + </n-tabs> | ||
59 | + </content-box> | ||
60 | + </n-layout-sider> | ||
61 | + </n-layout> | ||
62 | +</template> | ||
63 | + | ||
64 | +<script setup lang="ts"> | ||
65 | +import { ref, toRefs, watch, computed } from 'vue' | ||
66 | +import { icon } from '@/plugins' | ||
67 | +import { loadAsyncComponent } from '@/utils' | ||
68 | +import { ContentBox } from '../../ContentBox/index' | ||
69 | +import { TabsEnum } from './index.d' | ||
70 | +import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore' | ||
71 | +import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' | ||
72 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
73 | + | ||
74 | +const { getDetails } = toRefs(useChartLayoutStore()) | ||
75 | +const { setItem } = useChartLayoutStore() | ||
76 | +const chartEditStore = useChartEditStore() | ||
77 | + | ||
78 | +const { ConstructIcon, FlashIcon, DesktopOutlineIcon, LeafIcon, RocketIcon, AlbumsIcon } = icon.ionicons5 | ||
79 | + | ||
80 | +const ContentEdit = loadAsyncComponent(() => import('../../ContentEdit/index.vue')) | ||
81 | +const CanvasPage = loadAsyncComponent(() => import('../components/CanvasPage/index.vue')) | ||
82 | +const ChartSetting = loadAsyncComponent(() => import('../components/ChartSetting/index.vue')) | ||
83 | +const ChartData = loadAsyncComponent(() => import('../components/ChartData/index.vue')) | ||
84 | +const ThingsKitChartData = loadAsyncComponent(() => import('../components/external/ThingsKitChartData/index.vue')) //新增ThingsKit自定义分组数据页面 | ||
85 | +const ChartEvent = loadAsyncComponent(() => import('../components/ChartEvent/index.vue')) | ||
86 | +const ChartAnimation = loadAsyncComponent(() => import('../components/ChartAnimation/index.vue')) | ||
87 | + | ||
88 | +const collapsed = ref<boolean>(getDetails.value) | ||
89 | +const tabsSelect = ref<TabsEnum>(TabsEnum.CHART_SETTING) | ||
90 | + | ||
91 | +const collapsedHandle = () => { | ||
92 | + collapsed.value = true | ||
93 | + setItem(ChartLayoutStoreEnum.DETAILS, true) | ||
94 | +} | ||
95 | + | ||
96 | +const expandHandle = () => { | ||
97 | + collapsed.value = false | ||
98 | + setItem(ChartLayoutStoreEnum.DETAILS, false) | ||
99 | +} | ||
100 | + | ||
101 | +const selectTarget = computed(() => { | ||
102 | + const selectId = chartEditStore.getTargetChart.selectId | ||
103 | + // 排除多个 | ||
104 | + if (selectId.length !== 1) return undefined | ||
105 | + const target = chartEditStore.componentList[chartEditStore.fetchTargetIndex()] | ||
106 | + if (target?.isGroup) { | ||
107 | + // eslint-disable-next-line vue/no-side-effects-in-computed-properties | ||
108 | + tabsSelect.value = TabsEnum.CHART_SETTING | ||
109 | + } | ||
110 | + return target | ||
111 | +}) | ||
112 | + | ||
113 | +watch(getDetails, newData => { | ||
114 | + if (newData) { | ||
115 | + collapsedHandle() | ||
116 | + } else { | ||
117 | + expandHandle() | ||
118 | + } | ||
119 | +}) | ||
120 | + | ||
121 | +// 页面设置 | ||
122 | +const globalTabList = [ | ||
123 | + { | ||
124 | + key: TabsEnum.PAGE_SETTING, | ||
125 | + title: '页面配置', | ||
126 | + icon: DesktopOutlineIcon, | ||
127 | + render: CanvasPage | ||
128 | + } | ||
129 | +] | ||
130 | + | ||
131 | +//THINGS_KIT 新增分组支持数据绑定 | ||
132 | +const chartsDefaultTabList = [ | ||
133 | + { | ||
134 | + key: TabsEnum.CHART_SETTING, | ||
135 | + title: '定制', | ||
136 | + icon: ConstructIcon, | ||
137 | + render: ChartSetting | ||
138 | + }, | ||
139 | + { | ||
140 | + key: TabsEnum.CHART_ANIMATION, | ||
141 | + title: '动画', | ||
142 | + icon: LeafIcon, | ||
143 | + render: ChartAnimation | ||
144 | + }, | ||
145 | + { | ||
146 | + key: TabsEnum.CHART_DATA, | ||
147 | + title: '数据', | ||
148 | + icon: FlashIcon, | ||
149 | + render: ChartData | ||
150 | + }, | ||
151 | + { | ||
152 | + key: TabsEnum.THINGS_KIT_CHART_DATA, | ||
153 | + title: '分组', | ||
154 | + icon: AlbumsIcon, | ||
155 | + render: ThingsKitChartData | ||
156 | + } | ||
157 | +] | ||
158 | + | ||
159 | +const chartsTabList = [ | ||
160 | + ...chartsDefaultTabList.slice(0,2), | ||
161 | + { | ||
162 | + key: TabsEnum.CHART_DATA, | ||
163 | + title: '数据', | ||
164 | + icon: FlashIcon, | ||
165 | + render: ChartData | ||
166 | + }, | ||
167 | + { | ||
168 | + key: TabsEnum.CHART_EVENT, | ||
169 | + title: '事件', | ||
170 | + icon: RocketIcon, | ||
171 | + render: ChartEvent | ||
172 | + } | ||
173 | +] | ||
174 | +</script> | ||
175 | + | ||
176 | +<style lang="scss" scoped> | ||
177 | +@include go(content-configurations) { | ||
178 | + overflow: hidden; | ||
179 | + .tabs-box { | ||
180 | + padding: 10px; | ||
181 | + .icon-position { | ||
182 | + padding-top: 2px; | ||
183 | + } | ||
184 | + } | ||
185 | +} | ||
186 | +</style> |
@@ -51,16 +51,18 @@ const chartEditStore = useChartEditStore() | @@ -51,16 +51,18 @@ const chartEditStore = useChartEditStore() | ||
51 | // 记录初始化 | 51 | // 记录初始化 |
52 | chartHistoryStoreStore.canvasInit(chartEditStore.getEditCanvas) | 52 | chartHistoryStoreStore.canvasInit(chartEditStore.getEditCanvas) |
53 | /** | 53 | /** |
54 | - * THINGS_KIT 升级版本这里有冲突 | 54 | + * THINGS_KIT 修改了部分重写引入,升级版本这里有冲突 |
55 | * 源文件 './ContentHeader/headerRightBtn/index.vue' ./ContentHeader/headerLeftBtn/index.vue' | 55 | * 源文件 './ContentHeader/headerRightBtn/index.vue' ./ContentHeader/headerLeftBtn/index.vue' |
56 | * 修改后 './ContentHeader/headerRightBtn/external/index.vue' ./ContentHeader/headerLeftBtn/external/index.vue' | 56 | * 修改后 './ContentHeader/headerRightBtn/external/index.vue' ./ContentHeader/headerLeftBtn/external/index.vue' |
57 | + * 源文件 './ContentConfigurations/index.vue' | ||
58 | + * 修改后 './ContentConfigurations/external/index.vue' | ||
57 | */ | 59 | */ |
58 | -const HeaderLeftBtn = loadAsyncComponent(() => import('./ContentHeader/headerLeftBtn/external/index.vue')) | ||
59 | -const HeaderRightBtn = loadAsyncComponent(() => import('./ContentHeader/headerRightBtn/external/index.vue')) | 60 | +const HeaderLeftBtn = loadAsyncComponent(() => import('./ContentHeader/headerLeftBtn/external/index.vue'))//修改引入路径!!! |
61 | +const HeaderRightBtn = loadAsyncComponent(() => import('./ContentHeader/headerRightBtn/external/index.vue'))//修改引入路径!!! | ||
60 | const HeaderTitle = loadAsyncComponent(() => import('./ContentHeader/headerTitle/index.vue')) | 62 | const HeaderTitle = loadAsyncComponent(() => import('./ContentHeader/headerTitle/index.vue')) |
61 | const ContentLayers = loadAsyncComponent(() => import('./ContentLayers/index.vue')) | 63 | const ContentLayers = loadAsyncComponent(() => import('./ContentLayers/index.vue')) |
62 | const ContentCharts = loadAsyncComponent(() => import('./ContentCharts/index.vue')) | 64 | const ContentCharts = loadAsyncComponent(() => import('./ContentCharts/index.vue')) |
63 | -const ContentConfigurations = loadAsyncComponent(() => import('./ContentConfigurations/index.vue')) | 65 | +const ContentConfigurations = loadAsyncComponent(() => import('./ContentConfigurations/external/index.vue'))//修改引入路径!!! |
64 | const ContentLoad = loadAsyncComponent(() => import('./ContentLoad/index.vue')) | 66 | const ContentLoad = loadAsyncComponent(() => import('./ContentLoad/index.vue')) |
65 | 67 | ||
66 | // 右键 | 68 | // 右键 |