diff --git a/core/core-frontend/src/store/modules/data-visualization/copy.ts b/core/core-frontend/src/store/modules/data-visualization/copy.ts index 18e5224515..071335bde0 100644 --- a/core/core-frontend/src/store/modules/data-visualization/copy.ts +++ b/core/core-frontend/src/store/modules/data-visualization/copy.ts @@ -8,6 +8,7 @@ import eventBus from '@/utils/eventBus' import { adaptCurThemeCommonStyle } from '@/utils/canvasStyle' import { composeStoreWithOut } from '@/store/modules/data-visualization/compose' import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot' +import { maxYComponentCount } from '@/utils/canvasUtils' const dvMainStore = dvMainStoreWithOut() const composeStore = composeStoreWithOut() @@ -62,7 +63,7 @@ export const copyStore = defineStore('copy', { } // dataV 数据大屏 newComponent.x = newComponent.sizeX * xPositionOffset + 1 - newComponent.y = 200 + newComponent.y = maxYComponentCount() + 10 // dataV 数据大屏 newComponent.style.left = 0 newComponent.style.top = 0 diff --git a/core/core-frontend/src/utils/canvasUtils.ts b/core/core-frontend/src/utils/canvasUtils.ts index 3049a5017e..bdc0352fcb 100644 --- a/core/core-frontend/src/utils/canvasUtils.ts +++ b/core/core-frontend/src/utils/canvasUtils.ts @@ -731,3 +731,14 @@ export function componentPreSort(componentData) { }) } } + +export function maxYComponentCount() { + if (componentData.value.length === 0) { + return 1 + } else { + return componentData.value + .filter(item => item.y) + .map(item => item.y + item.sizeY) // 计算每个元素的 y + sizeY + .reduce((max, current) => Math.max(max, current), 0) + } +}