Showing
9 changed files
with
203 additions
and
3 deletions
| 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.STATIC, | |
| 16 | + image: 'button.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 | 70 | |
| 71 | 71 | // 预览更新 |
| 72 | 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 | 85 | </script> |
| 76 | 86 | ... | ... |
| ... | ... | @@ -57,7 +57,17 @@ watch( |
| 57 | 57 | |
| 58 | 58 | // 预览更新 |
| 59 | 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 | 38 | ) |
| 39 | 39 | |
| 40 | 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 | 53 | </script> |
| 44 | 54 | ... | ... |
| ... | ... | @@ -11,6 +11,7 @@ import { OverrideInputsDateConfig } from '@/packages/components/external/Informa |
| 11 | 11 | import { OverrideInputsTabConfig } from '@/packages/components/external/Informations/Inputs/OverrideInputsTab' |
| 12 | 12 | import { OverrideIframeConfig } from '@/packages/components/external/Informations/Mores/OverrideIframe' |
| 13 | 13 | import { ButtonConfig } from '@/packages/components/external/Informations/Inputs/Button' |
| 14 | +import { TreeConfig } from '@/packages/components/external/Informations/Inputs/Tree' | |
| 14 | 15 | import { OverrideTextCommonConfig } from '@/packages/components/external/Informations/Texts/OverrideTextCommon' |
| 15 | 16 | import { OverrideTextBarrageConfig } from '@/packages/components/external/Informations/Texts/OverrideTextBarrage' |
| 16 | 17 | import { OverrideTextGradientConfig } from '@/packages/components/external/Informations/Texts/OverrideTextGradient' |
| ... | ... | @@ -80,6 +81,7 @@ export function useInjectLib(packagesList: EPackagesType) { |
| 80 | 81 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideCarouselConfig)//重写信息下的轮播图 |
| 81 | 82 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideSelectConfig)//重写信息下的select |
| 82 | 83 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, ButtonConfig)//新增信息下的按钮 |
| 84 | + addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, TreeConfig)//新增信息下的树形控件 | |
| 83 | 85 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideIframeConfig)//重写信息下的远程加载网页 |
| 84 | 86 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsDateConfig)//重写信息下的日期 |
| 85 | 87 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsTabConfig)//重写信息下的tab | ... | ... |