From d4ba828d088c5fd4aa1585ee2254327c39162885 Mon Sep 17 00:00:00 2001 From: tnt group Date: Fri, 16 Sep 2022 10:30:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=84=E4=BB=B6ChartsItemBox?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8F=8C=E5=87=BB=E6=B7=BB=E5=8A=A0=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ChartsItemBox/index.vue | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue index 696fd6e3..2a27725c 100644 --- a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue @@ -8,6 +8,7 @@ draggable @dragstart="dragStartHandle($event, item)" @dragend="dragendHandle" + @dblclick="dblclickHandle(item)" >
@@ -25,9 +26,10 @@ import { PropType } from 'vue' import { MacOsControlBtn } from '@/components/Tips/MacOsControlBtn/index' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' -import { componentInstall } from '@/utils' +import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils' import { DragKeyEnum } from '@/enums/editPageEnum' -import { ConfigType } from '@/packages/index.d' +import { createComponent } from '@/packages' +import { ConfigType, CreateComponentType } from '@/packages/index.d' import { fetchConfigComponent, fetchChartComponent } from '@/packages/index' import omit from 'lodash/omit' const chartEditStore = useChartEditStore() @@ -54,6 +56,26 @@ const dragStartHandle = (e: DragEvent, item: ConfigType) => { const dragendHandle = () => { chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_CREATE, false) } + +// 双击添加 +const dblclickHandle = async (item: ConfigType) => { + try { + loadingStart() + // 动态注册图表组件 + componentInstall(item.chartKey, fetchChartComponent(item)) + componentInstall(item.conKey, fetchConfigComponent(item)) + // 创建新图表组件 + let newComponent: CreateComponentType = await createComponent(item) + // 添加 + chartEditStore.addComponentList(newComponent, false, true) + // 选中 + chartEditStore.setTargetSelectChart(newComponent.id) + loadingFinish() + } catch (error) { + loadingError() + window['$message'].warning(`图表正在研发中, 敬请期待...`) + } +}