Merge pull request #9459 from dataease/pr@dev@fix_sub_dim_drill

fix(视图): 修复子维度作为下钻入口无法下钻
This commit is contained in:
wisonic-s 2024-04-29 18:05:32 +08:00 committed by GitHub
commit c5f9861d74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -273,7 +273,7 @@ import Vue from 'vue'
import { formatterItem, valueFormatter } from '@/views/chart/chart/formatter' import { formatterItem, valueFormatter } from '@/views/chart/chart/formatter'
import UserViewDialog from '@/components/canvas/customComponent/UserViewDialog' import UserViewDialog from '@/components/canvas/customComponent/UserViewDialog'
import UserViewMobileDialog from '@/components/canvas/customComponent/UserViewMobileDialog' import UserViewMobileDialog from '@/components/canvas/customComponent/UserViewMobileDialog'
import { equalsAny } from '@/utils/StringUtils' import { equalsAny, includesAny } from '@/utils/StringUtils'
export default { export default {
name: 'UserView', name: 'UserView',
@ -530,7 +530,7 @@ export default {
let linkageCount = 0 let linkageCount = 0
let jumpCount = 0 let jumpCount = 0
if (this.drillFilters.length && !this.chart.type.includes('table')) { if (this.drillFilters.length && !this.chart.type.includes('table')) {
const checkItem = this.drillFields[this.drillFilters.length] const checkItem = this.getDrillField()
const sourceInfo = this.chart.id + '#' + checkItem.id const sourceInfo = this.chart.id + '#' + checkItem.id
if (this.nowPanelTrackInfo[sourceInfo]) { if (this.nowPanelTrackInfo[sourceInfo]) {
linkageCount++ linkageCount++
@ -1587,6 +1587,49 @@ export default {
pageClick(page) { pageClick(page) {
this.currentPage = page this.currentPage = page
this.getData(this.element.propValue.viewId, false) this.getData(this.element.propValue.viewId, false)
},
getDrillField() {
const { type, xaxis, xaxisExt, extStack } = this.chart
const drillItem = this.drillFields[this.drillFilters.length]
if (!includesAny(type, 'group', 'stack')) {
return drillItem
}
const drillHead = this.drillFields[0]
const xAxis = JSON.parse(xaxis)
// group
if (type.includes('group') && !type.includes('stack')) {
const xAxisExt = JSON.parse(xaxisExt)
if (drillHead.id === xAxisExt?.[0]?.id) {
return this.drillFields[this.drillFilters.length - xAxis.length]
}
}
// stack
if (!type.includes('group') && type.includes('stack')) {
const stack = JSON.parse(extStack)
if (drillHead.id === stack?.[0]?.id) {
return this.drillFields[this.drillFilters.length - xAxis.length]
}
}
// group-stack
if (type.includes('group') && type.includes('stack')) {
const xAxisExt = JSON.parse(xaxisExt)
const stack = JSON.parse(extStack)
if (drillHead.id === xAxisExt?.[0]?.id) {
if (stack?.length) {
return this.drillFields[this.drillFilters.length - xAxis.length - stack.length]
} else {
return this.drillFields[this.drillFilters.length - xAxis.length ]
}
}
if (drillHead.id === stack?.[0].id) {
if (xAxisExt?.length) {
return this.drillFields[this.drillFilters.length - xAxis.length - xAxisExt.length]
} else {
return this.drillFields[this.drillFilters.length - xAxis.length]
}
}
}
return drillItem
} }
} }
} }