forked from github/dataease
refactor: 图层样式优化
This commit is contained in:
parent
ac7046ed27
commit
5e2f2b183e
@ -365,7 +365,7 @@ const handleContextMenu = e => {
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
min-width: 65px;
|
min-width: 43px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
@ -1203,6 +1203,14 @@ const linkageSetOpen = item => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contextMenuShow = computed(() => {
|
||||||
|
if (curComponent.value) {
|
||||||
|
return curComponent.value.canvasId === canvasId.value
|
||||||
|
} else {
|
||||||
|
return isMainCanvas(canvasId.value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const markLineShow = computed(() => isMainCanvas(canvasId.value))
|
const markLineShow = computed(() => isMainCanvas(canvasId.value))
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -1333,7 +1341,7 @@ defineExpose({
|
|||||||
/>
|
/>
|
||||||
</Shape>
|
</Shape>
|
||||||
<!-- 右击菜单 -->
|
<!-- 右击菜单 -->
|
||||||
<ContextMenu show-position="canvasCore" />
|
<ContextMenu v-if="contextMenuShow" show-position="canvasCore" />
|
||||||
<!-- 标线 -->
|
<!-- 标线 -->
|
||||||
<MarkLine v-if="markLineShow" />
|
<MarkLine v-if="markLineShow" />
|
||||||
<!-- 选中区域 -->
|
<!-- 选中区域 -->
|
||||||
|
@ -454,6 +454,17 @@ const handleMouseDownOnShape = e => {
|
|||||||
) {
|
) {
|
||||||
emit('onDragging', e)
|
emit('onDragging', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//如果当前组件是Group分组 则要进行内部组件深度计算
|
||||||
|
element.value.component === 'Group' && groupSizeStyleAdaptor(element.value)
|
||||||
|
//如果当前画布是Group内部画布 则对应组件定位在resize时要还原到groupStyle中
|
||||||
|
if (isGroupCanvas(canvasId.value)) {
|
||||||
|
groupStyleRevert(element.value, {
|
||||||
|
width: parentNode.value.offsetWidth,
|
||||||
|
height: parentNode.value.offsetHeight
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 防止首次组件在tab旁边无法触发矩阵移动
|
// 防止首次组件在tab旁边无法触发矩阵移动
|
||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
isFirst = false
|
isFirst = false
|
||||||
|
@ -84,8 +84,12 @@ export const composeStore = defineStore('compose', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const newId = generateID()
|
||||||
|
components.forEach(component => {
|
||||||
|
component.canvasId = 'Group-' + newId
|
||||||
|
})
|
||||||
const groupComponent = {
|
const groupComponent = {
|
||||||
id: generateID(),
|
id: newId,
|
||||||
component: 'Group',
|
component: 'Group',
|
||||||
name: '组合',
|
name: '组合',
|
||||||
label: '组合',
|
label: '组合',
|
||||||
|
@ -2,6 +2,7 @@ import { deepCopy } from './utils'
|
|||||||
import { divide, multiply } from 'mathjs'
|
import { divide, multiply } from 'mathjs'
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
|
import { groupSizeStyleAdaptor } from '@/utils/style'
|
||||||
|
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const { componentData, curComponentIndex, canvasStyleData } = storeToRefs(dvMainStore)
|
const { componentData, curComponentIndex, canvasStyleData } = storeToRefs(dvMainStore)
|
||||||
@ -28,14 +29,7 @@ export function changeComponentsSizeWithScale(scale) {
|
|||||||
// 计算逻辑 Group 中样式 * groupComponent.groupStyle[sonKey].
|
// 计算逻辑 Group 中样式 * groupComponent.groupStyle[sonKey].
|
||||||
if (component.component === 'Group') {
|
if (component.component === 'Group') {
|
||||||
try {
|
try {
|
||||||
component.propValue.forEach(groupComponent => {
|
groupSizeStyleAdaptor(component)
|
||||||
Object.keys(groupComponent.style).forEach(sonKey => {
|
|
||||||
if (groupComponent.groupStyle[sonKey]) {
|
|
||||||
groupComponent.style[sonKey] =
|
|
||||||
component.style[sonKey] * groupComponent.groupStyle[sonKey]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 旧Group适配
|
// 旧Group适配
|
||||||
console.error('group adaptor error:' + e)
|
console.error('group adaptor error:' + e)
|
||||||
|
@ -4,4 +4,5 @@ export default function decomposeComponent(component, editorRect, parentStyle) {
|
|||||||
component.style.left = component.style.left + parentStyle.left
|
component.style.left = component.style.left + parentStyle.left
|
||||||
component.style.top = component.style.top + parentStyle.top
|
component.style.top = component.style.top + parentStyle.top
|
||||||
component.groupStyle = {}
|
component.groupStyle = {}
|
||||||
|
component.canvasId = 'canvas-main'
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ export function groupSizeStyleAdaptor(groupComponent) {
|
|||||||
groupComponent.propValue.forEach(component => {
|
groupComponent.propValue.forEach(component => {
|
||||||
// 分组还原逻辑
|
// 分组还原逻辑
|
||||||
// 当发上分组缩放是,要将内部组件按照比例转换
|
// 当发上分组缩放是,要将内部组件按照比例转换
|
||||||
const styleScale = { ...component.groupStyle }
|
const styleScale = component.groupStyle
|
||||||
component.style.left = parentStyle.width * styleScale.left
|
component.style.left = parentStyle.width * styleScale.left
|
||||||
component.style.top = parentStyle.height * styleScale.top
|
component.style.top = parentStyle.height * styleScale.top
|
||||||
component.style.width = parentStyle.width * styleScale.width
|
component.style.width = parentStyle.width * styleScale.width
|
||||||
|
Loading…
Reference in New Issue
Block a user