Merge pull request #8903 from dataease/pr@dev@fix_selectfirst

fix(仪表板): 修复含有首选项的组件在tab页面中容易显示错位问题#8569
This commit is contained in:
王嘉豪 2024-04-02 21:31:53 +08:00 committed by GitHub
commit 7f2a66c5ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 22 deletions

View File

@ -260,7 +260,7 @@ export default {
showPosition: {
type: String,
required: false,
default: 'NotProvided'
default: 'preview'
},
panelInfo: {
type: Object,
@ -828,9 +828,6 @@ export default {
if (this.componentData) {
const componentData = deepCopy(this.componentData)
componentData.forEach(component => {
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)
@ -846,8 +843,6 @@ export default {
}
}
})
}
const maxWidth = this.canvasStyleData.width * this.scaleWidth / 100
if (component.style['width'] > maxWidth) {
component.style['width'] = maxWidth

View File

@ -179,10 +179,12 @@ export function panelDataPrepare(componentData, componentStyle, callback) {
})
// 初始化密度为最高密度
componentStyle.aidedDesign.matrixBase = 4
callback({
const result = {
'componentData': resetID(componentData),
'componentStyle': componentStyle
})
}
store.state.sourceComponentData = deepCopy(result.componentData)
callback(result)
}
export function resetID(data) {
@ -307,6 +309,9 @@ export function imgUrlTrans(url) {
export function getNowCanvasComponentData(canvasId, showPosition) {
if (showPosition && (showPosition.includes('email-task') || showPosition.includes('multiplexing'))) {
return store.state.previewComponentData.filter(item => item.canvasId === canvasId)
} else if (showPosition === 'preview') {
console.log('test===' + JSON.stringify(deepCopy(store.state.sourceComponentData.filter(item => item.canvasId === canvasId))))
return deepCopy(store.state.sourceComponentData.filter(item => item.canvasId === canvasId))
} else {
return store.state.componentData.filter(item => item.canvasId === canvasId)
}

View File

@ -154,6 +154,7 @@ const data = {
},
previewVisible: false,
previewComponentData: [],
sourceComponentData: [],
currentCanvasNewId: [],
lastViewRequestInfo: {},
multiplexingStyleAdapt: true, // 复用样式跟随主题
@ -261,6 +262,9 @@ const data = {
setPreviewComponentData(state, previewComponentData = []) {
Vue.set(state, 'previewComponentData', previewComponentData)
},
setSourceComponentData(state, sourceComponentData = []) {
Vue.set(state, 'sourceComponentData', sourceComponentData)
},
setComponentViewsData(state, componentViewsData = {}) {
Vue.set(state, 'componentViewsData', componentViewsData)
},