diff --git a/core/core-frontend/src/utils/canvasUtils.ts b/core/core-frontend/src/utils/canvasUtils.ts index fc0e74841d..60c06f4382 100644 --- a/core/core-frontend/src/utils/canvasUtils.ts +++ b/core/core-frontend/src/utils/canvasUtils.ts @@ -120,6 +120,68 @@ function matrixAdaptor(componentItem) { } } +export function historyItemAdaptor( + componentItem, + reportFilterInfo, + attachInfo, + canvasVersion, + canvasInfo +) { + componentItem['canvasActive'] = false + // 定时报告过滤组件适配 如果当前是定时报告默认切有设置对应的过滤组件默认值,则替换过滤组件 + if ( + componentItem.component === 'VQuery' && + attachInfo.source === 'report' && + !!reportFilterInfo + ) { + componentItem.propValue.forEach((filterItem, index) => { + if (reportFilterInfo[filterItem.id]) { + componentItem.propValue[index] = JSON.parse(reportFilterInfo[filterItem.id].filterInfo) + } + }) + } + if (componentItem.component === 'Group') { + componentItem.expand = componentItem.expand || false + } + + if (componentItem.component === 'Picture') { + componentItem.style['adaptation'] = componentItem.style['adaptation'] || 'adaptation' + } + // public + componentItem['maintainRadio'] = componentItem['maintainRadio'] || false + componentItem['multiDimensional'] = + componentItem['multiDimensional'] || deepCopy(MULTI_DIMENSIONAL) + componentItem['carousel'] = componentItem['carousel'] || deepCopy(BASE_CAROUSEL) + componentItem['aspectRatio'] = componentItem['aspectRatio'] || 1 + if (componentItem.component === 'UserView') { + componentItem.actionSelection = componentItem.actionSelection || deepCopy(ACTION_SELECTION) + } + // 2 为基础版本 此处需要增加仪表板矩阵密度 + if ((!canvasVersion || canvasVersion === 2) && canvasInfo.type === 'dashboard') { + matrixAdaptor(componentItem) + } + // 组件事件适配 + componentItem.events = + componentItem.events && + componentItem.events.checked !== undefined && + componentItem.events.type !== 'displayChange' + ? componentItem.events + : deepCopy(BASE_EVENTS) + componentItem['category'] = componentItem['category'] || 'base' + + if (componentItem.component === 'DeTabs') { + componentItem.propValue.forEach(tabItem => { + tabItem.componentData.forEach(tabComponent => { + historyItemAdaptor(tabComponent, reportFilterInfo, attachInfo, canvasVersion, canvasInfo) + }) + }) + } else if (componentItem.component === 'Group') { + componentItem.propValue.forEach(groupItem => { + historyItemAdaptor(groupItem, reportFilterInfo, attachInfo, canvasVersion, canvasInfo) + }) + } +} + export function historyAdaptor( canvasStyleResult, canvasDataResult, @@ -138,47 +200,7 @@ export function historyAdaptor( canvasStyleResult['popupAvailable'] === undefined ? true : canvasStyleResult['popupAvailable'] //兼容弹框区域开关 const reportFilterInfo = canvasInfo.reportFilterInfo canvasDataResult.forEach(componentItem => { - componentItem['canvasActive'] = false - // 定时报告过滤组件适配 如果当前是定时报告默认切有设置对应的过滤组件默认值,则替换过滤组件 - if ( - componentItem.component === 'VQuery' && - attachInfo.source === 'report' && - !!reportFilterInfo - ) { - componentItem.propValue.forEach((filterItem, index) => { - if (reportFilterInfo[filterItem.id]) { - componentItem.propValue[index] = JSON.parse(reportFilterInfo[filterItem.id].filterInfo) - } - }) - } - if (componentItem.component === 'Group') { - componentItem.expand = componentItem.expand || false - } - - if (componentItem.component === 'Picture') { - componentItem.style['adaptation'] = componentItem.style['adaptation'] || 'adaptation' - } - // public - componentItem['maintainRadio'] = componentItem['maintainRadio'] || false - componentItem['multiDimensional'] = - componentItem['multiDimensional'] || deepCopy(MULTI_DIMENSIONAL) - componentItem['carousel'] = componentItem['carousel'] || deepCopy(BASE_CAROUSEL) - componentItem['aspectRatio'] = componentItem['aspectRatio'] || 1 - if (componentItem.component === 'UserView') { - componentItem.actionSelection = componentItem.actionSelection || deepCopy(ACTION_SELECTION) - } - // 2 为基础版本 此处需要增加仪表板矩阵密度 - if ((!canvasVersion || canvasVersion === 2) && canvasInfo.type === 'dashboard') { - matrixAdaptor(componentItem) - } - // 组件事件适配 - componentItem.events = - componentItem.events && - componentItem.events.checked !== undefined && - componentItem.events.type !== 'displayChange' - ? componentItem.events - : deepCopy(BASE_EVENTS) - componentItem['category'] = componentItem['category'] || 'base' + historyItemAdaptor(componentItem, reportFilterInfo, attachInfo, canvasVersion, canvasInfo) }) }