From f0e860f30610a7012eda3d7955b77e2fd9ffb8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Tue, 30 Aug 2022 17:28:21 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=8D=95=E8=AF=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/public/publicConfig.ts | 2 +- src/settings/designSetting.ts | 5 ++++- .../modules/chartEditStore/chartEditStore.ts | 20 +++++++++---------- .../chart/ContentEdit/hooks/useDrag.hook.ts | 6 +++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/packages/public/publicConfig.ts b/src/packages/public/publicConfig.ts index a285cf13..ddccc09d 100644 --- a/src/packages/public/publicConfig.ts +++ b/src/packages/public/publicConfig.ts @@ -104,5 +104,5 @@ export class PublicGroupConfigClass extends publicConfig implements CreateCompon // 标识 public id = getUUID() // 基本信息 - public attr = { w: 0, h: 0, x: 0, y: 0, zIndex: -1 } + public attr = { w: 0, h: 0, x: 0, y: 0, offsetX: 0, offsetY: 0, zIndex: -1 } } diff --git a/src/settings/designSetting.ts b/src/settings/designSetting.ts index 713b88bd..42fa7ad5 100644 --- a/src/settings/designSetting.ts +++ b/src/settings/designSetting.ts @@ -25,7 +25,10 @@ export const chartInitConfig = { x: 50, y: 50, w: 500, - h: 300 + h: 300, + // 不建议动 offset + offsetX: 0, + offsetY: 0, } // dialog 图标的大小 diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index 4a50a7eb..6f48c788 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -314,16 +314,16 @@ export const useChartEditStore = defineStore({ } }, // * 重置组件位置 - resetComponentPostion(item: CreateComponentType | CreateComponentGroupType, isForward: boolean):void{ + resetComponentPosition(item: CreateComponentType | CreateComponentGroupType, isForward: boolean): void { const index = this.fetchTargetIndex(item.id) - if(index > -1){ + if (index > -1) { const componentInstance = this.getComponentList[index] - if(isForward){ + if (isForward) { componentInstance.attr = Object.assign(componentInstance.attr, { x: item.attr.x + item.attr.offsetX, y: item.attr.y + item.attr.offsetY }) - }else{ + } else { componentInstance.attr = Object.assign(componentInstance.attr, { x: item.attr.x, y: item.attr.y @@ -332,7 +332,7 @@ export const useChartEditStore = defineStore({ } }, // * 移动组件 - moveComponentList(item: CreateComponentType | CreateComponentGroupType){ + moveComponentList(item: CreateComponentType | CreateComponentGroupType) { chartHistoryStore.createMoveHistory([item]) }, // * 更新组件列表某一项的值 @@ -554,9 +554,9 @@ export const useChartEditStore = defineStore({ // 处理移动 const isMove = HistoryItem.actionType === HistoryActionTypeEnum.MOVE - if(isMove){ + if (isMove) { historyData.forEach(item => { - this.resetComponentPostion(item, isForward) + this.resetComponentPosition(item, isForward) }) return } @@ -593,12 +593,12 @@ export const useChartEditStore = defineStore({ if (isGroup || isUnGroup) { if ((isGroup && isForward) || (isUnGroup && !isForward)) { const ids: string[] = [] - if(historyData.length > 1) { + if (historyData.length > 1) { historyData.forEach(item => { ids.push(item.id) }) } else { - (historyData[0] as CreateComponentGroupType).groupList.forEach(item => { + ;(historyData[0] as CreateComponentGroupType).groupList.forEach(item => { ids.push(item.id) }) } @@ -606,7 +606,7 @@ export const useChartEditStore = defineStore({ return } // 都需使用子组件的id去解组 - if(historyData.length > 1) { + if (historyData.length > 1) { this.setUnGroup([(historyData[0] as CreateComponentType).id], undefined, false) } else { this.setUnGroup([(historyData[0] as CreateComponentGroupType).groupList[0].id], undefined, false) diff --git a/src/views/chart/ContentEdit/hooks/useDrag.hook.ts b/src/views/chart/ContentEdit/hooks/useDrag.hook.ts index b6b1b61d..f481192d 100644 --- a/src/views/chart/ContentEdit/hooks/useDrag.hook.ts +++ b/src/views/chart/ContentEdit/hooks/useDrag.hook.ts @@ -111,7 +111,7 @@ export const mousedownBoxSelect = (e: MouseEvent, item?: CreateComponentType | C selectAttr.x1 = Math.round(startOffsetX - (startScreenX - moveEvent.screenX) / scale) selectAttr.y1 = startOffsetY selectAttr.x2 = startOffsetX - selectAttr.y2 = Math.round(startOffsetY + (moveEvent.screenY - startScreenY ) / scale) + selectAttr.y2 = Math.round(startOffsetY + (moveEvent.screenY - startScreenY) / scale) // 左下方向 } else { // 左上方向 @@ -223,7 +223,7 @@ export const useMouseHandle = () => { const startY = e.screenY // 记录历史位置 - let prevComponentInstance:CreateComponentType | CreateComponentGroupType + let prevComponentInstance: CreateComponentType | CreateComponentGroupType chartEditStore.getTargetChart.selectId.forEach(id => { if (!targetMap.has(id)) return @@ -278,7 +278,7 @@ export const useMouseHandle = () => { chartEditStore.setMousePosition(0, 0, 0, 0) chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_DRAG, false) // 加入历史栈 - if(prevComponentInstance){ + if (prevComponentInstance) { chartEditStore.getTargetChart.selectId.forEach(id => { if (!targetMap.has(id)) return const index = chartEditStore.fetchTargetIndex(id)