refactor: 组合组件预览优化

This commit is contained in:
wangjiahao 2023-12-29 19:11:05 +08:00
parent 908a596641
commit d0e91241a5
2 changed files with 11 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import { toRefs } from 'vue'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { storeToRefs } from 'pinia'
import ComponentWrapper from '@/components/data-visualization/canvas/ComponentWrapper.vue'
import { toPercent } from '@/utils/translate'
const dvMainStore = dvMainStoreWithOut()
const { canvasViewInfo } = storeToRefs(dvMainStore)
@ -37,6 +38,15 @@ const props = defineProps({
})
const { propValue, dvInfo, searchCount } = toRefs(props)
const customGroupStyle = item => {
return {
width: toPercent(item.groupStyle.width),
height: toPercent(item.groupStyle.height),
top: toPercent(item.groupStyle.top),
left: toPercent(item.groupStyle.left)
}
}
</script>
<template>
@ -50,7 +60,7 @@ const { propValue, dvInfo, searchCount } = toRefs(props)
:config="item"
:index="index"
:dv-info="dvInfo"
:style="item.groupStyle"
:style="customGroupStyle(item)"
:show-position="showPosition"
:search-count="searchCount"
/>

View File

@ -142,14 +142,8 @@ export function canvasSave(callBack) {
if (item.component === 'UserView') {
item.linkageFilters = []
} else if (item.component === 'Group') {
const groupStyle = item.style
item.propValue.forEach(groupItem => {
groupItem.linkageFilters = []
// 计算groupStyle
groupItem.groupStyle.left = toPercent(groupItem.style.left / groupStyle.width)
groupItem.groupStyle.top = toPercent(groupItem.style.top / groupStyle.height)
groupItem.groupStyle.width = toPercent(groupItem.style.width / groupStyle.width)
groupItem.groupStyle.height = toPercent(groupItem.style.height / groupStyle.height)
})
} else if (item.component === 'DeTabs') {
item.propValue.forEach(tabItem => {