forked from github/dataease
Merge pull request #6792 from dataease/pr@dev@refactor_panel-tab-change
fix: 修复Tab页中的不同画布之间的过滤组件可能相互影响问题
This commit is contained in:
commit
d06d2210b4
@ -70,6 +70,23 @@ export const buildViewKeyMap = panelItems => {
|
||||
return result
|
||||
}
|
||||
|
||||
export const buildCanvasIdMap = panelItems => {
|
||||
const result = {}
|
||||
panelItems.forEach(element => {
|
||||
if (element.type === 'view') {
|
||||
result[element.propValue.viewId] = element.canvasId
|
||||
}
|
||||
if (element.type === 'de-tabs') {
|
||||
element.options.tabList && element.options.tabList.forEach(tab => {
|
||||
if (tab.content && tab.content.propValue && tab.content.propValue.viewId) {
|
||||
result[tab.content.propValue.viewId] = element.id + '-' + tab.name
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
const cacheCondition = (cb, obj) => {
|
||||
obj.cb = cb
|
||||
}
|
||||
@ -78,6 +95,7 @@ export const buildViewKeyFilters = (panelItems, result) => {
|
||||
return result
|
||||
}
|
||||
const buildItems = panelItems[0].canvasId === 'canvas-main' ? panelItems : store.state.componentData
|
||||
const canvasIdMap = buildCanvasIdMap(buildItems)
|
||||
buildItems.forEach((element, index) => {
|
||||
if (element.type !== 'custom') {
|
||||
return true
|
||||
@ -91,28 +109,31 @@ export const buildViewKeyFilters = (panelItems, result) => {
|
||||
const vValid = valueValid(condition)
|
||||
const filterComponentId = condition.componentId
|
||||
Object.keys(result).forEach(viewId => {
|
||||
const vidMatch = viewIdMatch(condition.viewIds, viewId)
|
||||
if (vidMatch && selectFirst) {
|
||||
const obj = {}
|
||||
const promise = new Promise(resolve => {
|
||||
cacheCondition(cbParam => {
|
||||
const newCondition = getCondition(element, cbParam)
|
||||
resolve(newCondition)
|
||||
}, obj)
|
||||
})
|
||||
promise.componentId = filterComponentId
|
||||
promise.cacheObj = obj
|
||||
result[viewId].push(promise)
|
||||
} else {
|
||||
const viewFilters = result[viewId]
|
||||
let j = viewFilters.length
|
||||
while (j--) {
|
||||
const filter = viewFilters[j]
|
||||
if (filter.componentId === filterComponentId) {
|
||||
viewFilters.splice(j, 1)
|
||||
// 进行过滤时 如果过滤组件在主画布 则条件适用于所有画布视图 否则需要过滤组件和视图在相同画布
|
||||
if (element.canvasId === 'canvas-main' || element.canvasId === canvasIdMap[viewId]) {
|
||||
const vidMatch = viewIdMatch(condition.viewIds, viewId)
|
||||
if (vidMatch && selectFirst) {
|
||||
const obj = {}
|
||||
const promise = new Promise(resolve => {
|
||||
cacheCondition(cbParam => {
|
||||
const newCondition = getCondition(element, cbParam)
|
||||
resolve(newCondition)
|
||||
}, obj)
|
||||
})
|
||||
promise.componentId = filterComponentId
|
||||
promise.cacheObj = obj
|
||||
result[viewId].push(promise)
|
||||
} else {
|
||||
const viewFilters = result[viewId]
|
||||
let j = viewFilters.length
|
||||
while (j--) {
|
||||
const filter = viewFilters[j]
|
||||
if (filter.componentId === filterComponentId) {
|
||||
viewFilters.splice(j, 1)
|
||||
}
|
||||
}
|
||||
vidMatch && vValid && viewFilters.push(condition)
|
||||
}
|
||||
vidMatch && vValid && viewFilters.push(condition)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user