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: { showPosition: {
type: String, type: String,
required: false, required: false,
default: 'NotProvided' default: 'preview'
}, },
panelInfo: { panelInfo: {
type: Object, type: Object,
@ -828,26 +828,21 @@ export default {
if (this.componentData) { if (this.componentData) {
const componentData = deepCopy(this.componentData) const componentData = deepCopy(this.componentData)
componentData.forEach(component => { componentData.forEach(component => {
if (!this.isMainCanvas() && component.type === 'custom' && component.options?.attrs?.selectFirst && this.format(component.style.width, this.scaleWidth) < 80) { Object.keys(component.style).forEach(key => {
// do continue if (this.needToChangeHeight.includes(key)) {
} else { component.style[key] = this.format(component.style[key], this.scaleHeight)
Object.keys(component.style).forEach(key => { }
if (this.needToChangeHeight.includes(key)) { if (this.needToChangeWidth.includes(key)) {
component.style[key] = this.format(component.style[key], this.scaleHeight) 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 (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)
}
}
})
}
const maxWidth = this.canvasStyleData.width * this.scaleWidth / 100 const maxWidth = this.canvasStyleData.width * this.scaleWidth / 100
if (component.style['width'] > maxWidth) { if (component.style['width'] > maxWidth) {
component.style['width'] = maxWidth component.style['width'] = maxWidth

View File

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

View File

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