From 702cc105a3ff6d5f948f4ec108b8d04fcbd61175 Mon Sep 17 00:00:00 2001 From: huanghao1412 Date: Wed, 20 Mar 2024 14:34:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E7=A8=8B=E7=BB=84=E6=80=81?= =?UTF-8?q?=E7=BD=AE=E4=BA=8E=E8=83=8C=E6=99=AF=E5=89=8D=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Backgrounds/Backgrounds/config.ts | 2 ++ .../CustomComponents/EngineeringConfig/config.ts | 6 +++++- src/packages/index.d.ts | 3 ++- .../modules/chartEditStore/chartEditStore.ts | 16 ++++++++++++++++ .../components/ChartsItemBox/index.vue | 4 ++-- .../chart/ContentEdit/hooks/useDrag.hook.ts | 4 ++-- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/packages/components/CustomComponents/Backgrounds/Backgrounds/config.ts b/src/packages/components/CustomComponents/Backgrounds/Backgrounds/config.ts index 3013f0ac..31b44e2f 100644 --- a/src/packages/components/CustomComponents/Backgrounds/Backgrounds/config.ts +++ b/src/packages/components/CustomComponents/Backgrounds/Backgrounds/config.ts @@ -22,6 +22,8 @@ export default class Config extends PublicConfigClass implements CreateComponent h: 1080, x: 0, y: 0, + // 置于工程组态前插入 + isBeforeEngineerging: true } } public key = BackgroundsConfig.key diff --git a/src/packages/components/CustomComponents/CustomComponents/EngineeringConfig/config.ts b/src/packages/components/CustomComponents/CustomComponents/EngineeringConfig/config.ts index 0d8441bc..f0728a1a 100644 --- a/src/packages/components/CustomComponents/CustomComponents/EngineeringConfig/config.ts +++ b/src/packages/components/CustomComponents/CustomComponents/EngineeringConfig/config.ts @@ -27,8 +27,12 @@ export default class Config extends PublicConfigClass implements CreateComponent this.attr.h = 1080 this.attr.x = 0 this.attr.y = 0 - this.attr.isHeadInsert = true + // 置底插入 + // this.attr.isHeadInsert = true + // 初始时固定 拖拽组件会在鼠标处生成组件 此处为true就是固定位置以attr位置生成组件 this.attr.isFixedInit = true + // 在自定义组件背景 前插入 + this.attr.isAfterBGInsert = true } public key = EngineeringConfig.key public chartConfig = cloneDeep(EngineeringConfig) diff --git a/src/packages/index.d.ts b/src/packages/index.d.ts index eadfa948..95911e23 100644 --- a/src/packages/index.d.ts +++ b/src/packages/index.d.ts @@ -115,7 +115,8 @@ export const BlendModeEnumList = [ ] export interface PublicConfigAttrType { - x: number; y: number; w: number; h: number; zIndex: number; offsetX: number; offsetY: number, isHeadInsert?: boolean, isFixedInit?: boolean + x: number; y: number; w: number; h: number; zIndex: number; offsetX: number; offsetY: number, isHeadInsert?: boolean, isFixedInit?: boolean, + isAfterBGInsert?: boolean, isBeforeEngineerging?: boolean } // 组件实例类 diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index f63a9264..829d68e0 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -320,6 +320,22 @@ export const useChartEditStore = defineStore({ if (isHistory) { chartHistoryStore.createAddHistory([componentInstance]) } + let isAfterBGInsert = !!componentInstance.attr.isAfterBGInsert + if(isAfterBGInsert) { + let index = this.componentList.length + this.componentList.forEach((item, i) => { + if(item.chartConfig.key === 'Backgrounds') index = i + 1 + }) + this.componentList.splice(index, 0, componentInstance) + return + } + let isBeforeEngineerging = !!componentInstance.attr.isBeforeEngineerging + if(isBeforeEngineerging) { + let index = this.componentList.findIndex(_ => _.chartConfig.key === 'EngineeringConfig') + index = index > -1 ? index : 0 + this.componentList.splice(index, 0, componentInstance) + return + } if (isHead) { this.componentList.unshift(componentInstance) return diff --git a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue index 97899e6f..4af1689e 100644 --- a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue @@ -129,9 +129,9 @@ const dblclickHandle = async (item: ConfigType) => { newComponent.chartConfig.chartFrame = item.chartFrame } // 组件置底插入 - let isHead = !!newComponent.attr.isHeadInsert + // let isHead = !!newComponent.attr.isHeadInsert // 添加 - chartEditStore.addComponentList(newComponent, isHead, true) + chartEditStore.addComponentList(newComponent, false, true) // 选中 chartEditStore.setTargetSelectChart(newComponent.id) loadingFinish() diff --git a/src/views/chart/ContentEdit/hooks/useDrag.hook.ts b/src/views/chart/ContentEdit/hooks/useDrag.hook.ts index 0b32c105..f0b90c3e 100644 --- a/src/views/chart/ContentEdit/hooks/useDrag.hook.ts +++ b/src/views/chart/ContentEdit/hooks/useDrag.hook.ts @@ -47,8 +47,8 @@ export const dragHandle = async (e: DragEvent) => { setComponentPosition(newComponent, e.offsetX - newComponent.attr.w / 2, e.offsetY - newComponent.attr.h / 2) } - let isHead = !!newComponent.attr.isHeadInsert - chartEditStore.addComponentList(newComponent, isHead, true) + // let isHead = !!newComponent.attr.isHeadInsert + chartEditStore.addComponentList(newComponent, false, true) chartEditStore.setTargetSelectChart(newComponent.id) loadingFinish() } catch (error) {