forked from github/dataease
Merge pull request #12573 from dataease/pr@dev-v2@refactor_copy
refactor(仪表板): 优化复用仪表板组件最终放置位置,防止复用仪表板较长时,复用的视图在仪表板中部
This commit is contained in:
commit
972edd920b
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user