fix(仪表板): 修复选择首选项的过滤组件在tab中可能会出现位置偏移问题

This commit is contained in:
wangjiahao 2024-03-06 17:49:33 +08:00
parent 99449cb56a
commit bca491cd98

View File

@ -794,6 +794,7 @@ export default {
restore() {
const canvasHeight = document.getElementById(this.previewDomId).offsetHeight
const canvasWidth = document.getElementById(this.previewDomId).offsetWidth
console.log('===canvasHeight=' + canvasHeight + ';canvasWidth=' + canvasWidth)
this.scaleWidth = (canvasWidth) * 100 / this.canvasStyleData.width //
// 使
if (this.backScreenShot) {
@ -828,25 +829,30 @@ export default {
if (this.componentData) {
const componentData = deepCopy(this.componentData)
componentData.forEach(component => {
Object.keys(component.style).forEach(key => {
if (this.needToChangeHeight.includes(key)) {
component.style[key] = this.format(component.style[key], this.scaleHeight)
}
if (this.needToChangeWidth.includes(key)) {
component.style[key] = this.format(component.style[key], this.scaleWidth)
}
if (this.needToChangeInnerWidth.includes(key)) {
if ((key === 'fontSize' || key === 'activeFontSize') && (this.terminal === 'mobile' || ['custom'].includes(component.type))) {
// do nothing ( v-text )
} else {
if (key === 'fontSize' && component.component !== 'de-tabs') {
component.style[key] = this.formatPoint(component.style[key], this.previewCanvasScale.scalePointWidth * 1.4)
if (!this.isMainCanvas() && component.type === 'custom' && component.options?.attrs?.selectFirst && this.format(component.style.width, this.scaleWidth) < 80) {
// do continue
} else {
Object.keys(component.style).forEach(key => {
if (this.needToChangeHeight.includes(key)) {
component.style[key] = this.format(component.style[key], this.scaleHeight)
}
if (this.needToChangeWidth.includes(key)) {
component.style[key] = this.format(component.style[key], this.scaleWidth)
}
if (this.needToChangeInnerWidth.includes(key)) {
if ((key === 'fontSize' || key === 'activeFontSize') && (this.terminal === 'mobile' || ['custom'].includes(component.type))) {
// do nothing ( v-text )
} else {
component.style[key] = this.formatPoint(component.style[key], this.previewCanvasScale.scalePointWidth)
if (key === 'fontSize' && component.component !== 'de-tabs') {
component.style[key] = this.formatPoint(component.style[key], this.previewCanvasScale.scalePointWidth * 1.4)
} else {
component.style[key] = this.formatPoint(component.style[key], this.previewCanvasScale.scalePointWidth)
}
}
}
}
})
})
}
const maxWidth = this.canvasStyleData.width * this.scaleWidth / 100
if (component.style['width'] > maxWidth) {
component.style['width'] = maxWidth