From 0b58dd4d1733538e8b1cbec8ed1f364e5c9c6969 Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Wed, 16 Feb 2022 19:18:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E9=87=8D=E5=8F=A0?= =?UTF-8?q?=E6=8B=96=E6=8B=BD=E6=94=BE=E7=BD=AE=E4=BD=8D=E7=BD=AE=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LoadingComponent/index.vue | 2 ++ .../chartEditStore/chartEditStore.d.ts | 3 ++ .../modules/chartEditStore/chartEditStore.ts | 6 ++-- .../components/ChartTheme/index.vue | 2 +- .../components/CanvasPage/index.vue | 12 ++++---- .../components/EditBottom/index.vue | 2 +- .../components/EditRange/index.vue | 28 +++++++++++++++---- .../{useDrop.hook.ts => useDrag.hook.ts} | 21 +++++++++----- .../chart/ContentEdit/hooks/useLayout.hook.ts | 4 +-- .../chart/ContentEdit/hooks/useStyle.hook.ts | 8 ++---- src/views/chart/ContentEdit/index.vue | 6 ++-- 11 files changed, 60 insertions(+), 34 deletions(-) rename src/views/chart/ContentEdit/hooks/{useDrop.hook.ts => useDrag.hook.ts} (91%) diff --git a/src/components/LoadingComponent/index.vue b/src/components/LoadingComponent/index.vue index 09306e7f..34ff91fd 100644 --- a/src/components/LoadingComponent/index.vue +++ b/src/components/LoadingComponent/index.vue @@ -7,6 +7,8 @@ diff --git a/src/views/chart/ContentEdit/hooks/useDrop.hook.ts b/src/views/chart/ContentEdit/hooks/useDrag.hook.ts similarity index 91% rename from src/views/chart/ContentEdit/hooks/useDrop.hook.ts rename to src/views/chart/ContentEdit/hooks/useDrag.hook.ts index d21a575d..09233341 100644 --- a/src/views/chart/ContentEdit/hooks/useDrop.hook.ts +++ b/src/views/chart/ContentEdit/hooks/useDrag.hook.ts @@ -1,20 +1,21 @@ import { toRefs } from 'vue' -import { getChartEditStore } from './useStore.hook' import { DragKeyEnum } from '@/enums/editPageEnum' import { createComponent } from '@/packages' import { ConfigType } from '@/packages/index.d' -import { loadingStart, loadingFinish, loadingError } from '@/utils' import { CreateComponentType } from '@/packages/index.d' -import throttle from 'lodash/throttle' import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook' +import { getChartEditStore, getChartEditStoreEnum } from './useStore.hook' +import { loadingStart, loadingFinish, loadingError } from '@/utils' +import throttle from 'lodash/throttle' const { onClickoutside } = useContextMenu() const chartEditStore = getChartEditStore() +const chartEditStoreEnum = getChartEditStoreEnum() const { scale } = toRefs(chartEditStore.getEditCanvas) -// * 拖拽中 -export const handleDrop = async (e: DragEvent) => { +// * 拖拽到编辑区域里 +export const handleDrag = async (e: DragEvent) => { e.preventDefault() try { @@ -24,7 +25,10 @@ export const handleDrop = async (e: DragEvent) => { if (!drayDataString) { loadingFinish() return - } + } + + // 设置拖拽状态 + chartEditStore.setEditCanvas(chartEditStoreEnum.Is_Drag, false) const dropData: Exclude = JSON.parse( drayDataString @@ -42,10 +46,13 @@ export const handleDrop = async (e: DragEvent) => { } } -// * 拖拽结束 +// * 拖拽中 export const handleDragOver = (e: DragEvent) => { e.preventDefault() e.stopPropagation() + + // 设置拖拽状态 + chartEditStore.setEditCanvas(chartEditStoreEnum.Is_Drag, true) if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy' } diff --git a/src/views/chart/ContentEdit/hooks/useLayout.hook.ts b/src/views/chart/ContentEdit/hooks/useLayout.hook.ts index 4da36cf4..71fb3639 100644 --- a/src/views/chart/ContentEdit/hooks/useLayout.hook.ts +++ b/src/views/chart/ContentEdit/hooks/useLayout.hook.ts @@ -8,11 +8,11 @@ const chartEditStore = getChartEditStore() export const useLayout = () => { onMounted(() => { // 设置 Dom 值(ref 不生效先用 document) - chartEditStore.setEditCanvasItem( + chartEditStore.setEditCanvas( EditCanvasTypeEnum.EDIT_LAYOUT_DOM, document.getElementById('go-chart-edit-layout') ) - chartEditStore.setEditCanvasItem( + chartEditStore.setEditCanvas( EditCanvasTypeEnum.EDIT_CONTENT_DOM, document.getElementById('go-chart-edit-content') ) diff --git a/src/views/chart/ContentEdit/hooks/useStyle.hook.ts b/src/views/chart/ContentEdit/hooks/useStyle.hook.ts index fc9b60a3..481c168b 100644 --- a/src/views/chart/ContentEdit/hooks/useStyle.hook.ts +++ b/src/views/chart/ContentEdit/hooks/useStyle.hook.ts @@ -1,9 +1,5 @@ -interface AttrType { - x: number - y: number - w: number - h: number -} +import { PublicConfigType } from '@/packages/index.d' +type AttrType = Pick['attr'] export const useComponentStyle = (attr: AttrType, index: number) => { const componentStyle = { diff --git a/src/views/chart/ContentEdit/index.vue b/src/views/chart/ContentEdit/index.vue index 8d7f5e31..ee703fc7 100644 --- a/src/views/chart/ContentEdit/index.vue +++ b/src/views/chart/ContentEdit/index.vue @@ -7,7 +7,7 @@ :showBottom="true" :depth="1" :xScroll="true" - @drop="handleDrop" + @drop="handleDrag" @dragover="handleDragOver" >
@@ -52,7 +52,7 @@ import { EditShapeBox } from './components/EditShapeBox/index' import { useLayout } from './hooks/useLayout.hook' import { useAddKeyboard } from '../hooks/useKeyboard.hook' -import { handleDrop, handleDragOver, useMouseHandle } from './hooks/useDrop.hook' +import { handleDrag, handleDragOver, useMouseHandle } from './hooks/useDrag.hook' import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook' import { getChartEditStore } from './hooks/useStore.hook' import { useComponentStyle, useSizeStyle } from './hooks/useStyle.hook' @@ -93,7 +93,7 @@ onMounted(() => { @extend .go-point-bg; @include goId(chart-edit-content) { margin: 20px; - overflow: hidden; + /* overflow: hidden; */ transform-origin: left top; border: 1px solid rgba(0, 0, 0, 0); @extend .go-transition;