fix: 工程组态置于背景前插入

This commit is contained in:
huanghao1412 2024-03-20 14:34:14 +08:00
parent f194dc3995
commit 702cc105a3
6 changed files with 29 additions and 6 deletions

View File

@ -22,6 +22,8 @@ export default class Config extends PublicConfigClass implements CreateComponent
h: 1080,
x: 0,
y: 0,
// 置于工程组态前插入
isBeforeEngineerging: true
}
}
public key = BackgroundsConfig.key

View File

@ -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)

View File

@ -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
}
// 组件实例类

View File

@ -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

View File

@ -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()

View File

@ -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) {