fix: 优化组态 创建时固定位置

This commit is contained in:
huanghao1412 2024-03-07 15:22:53 +08:00
parent 0a343ad794
commit 23bf1d2af4
5 changed files with 21 additions and 10 deletions

View File

@ -16,7 +16,7 @@ export const option = {
// 展示标题
isThereATitleComponet: false,
// 控制内层 使外层选中失效
enableInner: false
enableInner: true
}
export default class Config extends PublicConfigClass implements CreateComponentType
@ -27,6 +27,8 @@ 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.isFixedInit = true
}
public key = EngineeringConfig.key
public chartConfig = cloneDeep(EngineeringConfig)

View File

@ -1,9 +1,11 @@
<template>
<CollapseItem name="组态" :expanded="true">
<SettingItemBox name="移动组态" :alone="true">
<n-space justify="start">
<n-switch v-model:value="optionData.enableInner" size="small"></n-switch>
</n-space>
<SettingItem name="开启后能移动组态,但无法选中组件,可以在左侧图层栏选中">
<n-space justify="start">
<n-switch v-model:value="optionData.enableInner" size="small"></n-switch>
</n-space>
</SettingItem>
</SettingItemBox>
<SettingItemBox name="标题">
<SettingItem name="如果有标题将展示">

View File

@ -118,7 +118,9 @@ export const BlendModeEnumList = [
export interface PublicConfigType {
id: string
isGroup: boolean
attr: { x: number; y: number; w: number; h: number; zIndex: number; offsetX: number; offsetY: number }
// isHeadInsert 组件置底
// isFixedInit 组件初始时位置以x,y为准 不以鼠标位置为准
attr: { x: number; y: number; w: number; h: number; zIndex: number; offsetX: number; offsetY: number, isHeadInsert?: boolean, isFixedInit?: boolean }
styles: {
[FilterEnum.FILTERS_SHOW]: boolean
[FilterEnum.OPACITY]: number

View File

@ -129,9 +129,7 @@ const dblclickHandle = async (item: ConfigType) => {
newComponent.chartConfig.chartFrame = item.chartFrame
}
//
let isHead = false
let isHeadList = ['EngineeringConfig']
if(isHeadList.includes(newComponent.chartConfig.key)) isHead = true
let isHead = !!newComponent.chartConfig.isHeadInsert
//
chartEditStore.addComponentList(newComponent, isHead, true)
//

View File

@ -40,8 +40,15 @@ export const dragHandle = async (e: DragEvent) => {
newComponent.chartConfig.chartFrame = dropData.chartFrame
}
setComponentPosition(newComponent, e.offsetX - newComponent.attr.w / 2, e.offsetY - newComponent.attr.h / 2)
chartEditStore.addComponentList(newComponent, false, true)
if(newComponent.attr.isFixedInit) {
setComponentPosition(newComponent, newComponent.attr.x, newComponent.attr.y)
}
else {
setComponentPosition(newComponent, e.offsetX - newComponent.attr.w / 2, e.offsetY - newComponent.attr.h / 2)
}
let isHead = !!newComponent.attr.isHeadInsert
chartEditStore.addComponentList(newComponent, isHead, true)
chartEditStore.setTargetSelectChart(newComponent.id)
loadingFinish()
} catch (error) {