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
|
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) => {
|
const cacheCondition = (cb, obj) => {
|
||||||
obj.cb = cb
|
obj.cb = cb
|
||||||
}
|
}
|
||||||
@ -78,6 +95,7 @@ export const buildViewKeyFilters = (panelItems, result) => {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
const buildItems = panelItems[0].canvasId === 'canvas-main' ? panelItems : store.state.componentData
|
const buildItems = panelItems[0].canvasId === 'canvas-main' ? panelItems : store.state.componentData
|
||||||
|
const canvasIdMap = buildCanvasIdMap(buildItems)
|
||||||
buildItems.forEach((element, index) => {
|
buildItems.forEach((element, index) => {
|
||||||
if (element.type !== 'custom') {
|
if (element.type !== 'custom') {
|
||||||
return true
|
return true
|
||||||
@ -91,28 +109,31 @@ export const buildViewKeyFilters = (panelItems, result) => {
|
|||||||
const vValid = valueValid(condition)
|
const vValid = valueValid(condition)
|
||||||
const filterComponentId = condition.componentId
|
const filterComponentId = condition.componentId
|
||||||
Object.keys(result).forEach(viewId => {
|
Object.keys(result).forEach(viewId => {
|
||||||
const vidMatch = viewIdMatch(condition.viewIds, viewId)
|
// 进行过滤时 如果过滤组件在主画布 则条件适用于所有画布视图 否则需要过滤组件和视图在相同画布
|
||||||
if (vidMatch && selectFirst) {
|
if (element.canvasId === 'canvas-main' || element.canvasId === canvasIdMap[viewId]) {
|
||||||
const obj = {}
|
const vidMatch = viewIdMatch(condition.viewIds, viewId)
|
||||||
const promise = new Promise(resolve => {
|
if (vidMatch && selectFirst) {
|
||||||
cacheCondition(cbParam => {
|
const obj = {}
|
||||||
const newCondition = getCondition(element, cbParam)
|
const promise = new Promise(resolve => {
|
||||||
resolve(newCondition)
|
cacheCondition(cbParam => {
|
||||||
}, obj)
|
const newCondition = getCondition(element, cbParam)
|
||||||
})
|
resolve(newCondition)
|
||||||
promise.componentId = filterComponentId
|
}, obj)
|
||||||
promise.cacheObj = obj
|
})
|
||||||
result[viewId].push(promise)
|
promise.componentId = filterComponentId
|
||||||
} else {
|
promise.cacheObj = obj
|
||||||
const viewFilters = result[viewId]
|
result[viewId].push(promise)
|
||||||
let j = viewFilters.length
|
} else {
|
||||||
while (j--) {
|
const viewFilters = result[viewId]
|
||||||
const filter = viewFilters[j]
|
let j = viewFilters.length
|
||||||
if (filter.componentId === filterComponentId) {
|
while (j--) {
|
||||||
viewFilters.splice(j, 1)
|
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