refactor(仪表板): 优化自定义颜色数据加载时机,改为需要配置时加载,防止初始化即加载导致请求时间过长 #6638

This commit is contained in:
wangjiahao 2023-11-14 16:30:26 +08:00
parent 5c24fee5e2
commit f04671ee7a
2 changed files with 63 additions and 55 deletions

View File

@ -1354,27 +1354,20 @@ export default {
},
getDataOnly(sourceResponseData, dataBroadcast) {
if (this.isEdit) {
if ((this.filter.filter && this.filter.filter.length) || (this.filter.linkageFilters && this.filter.linkageFilters.length)) {
const requestInfo = {
filter: [],
drill: [],
queryFrom: 'panel'
}
// table-info
if (this.view && this.view.customAttr) {
const attrSize = JSON.parse(this.view.customAttr).size
if (this.chart.type === 'table-info' && this.view.datasetMode === 0 && (!attrSize.tablePageMode || attrSize.tablePageMode === 'page')) {
requestInfo.goPage = this.currentPage.page
requestInfo.pageSize = this.currentPage.pageSize
}
}
viewData(this.chart.id, this.panelInfo.id, requestInfo).then(response => {
this.componentViewsData[this.chart.id] = response.data
this.view = response.data
if (((this.filter.filter && this.filter.filter.length) || (this.filter.linkageFilters && this.filter.linkageFilters.length)) &&
this.chart.render &&
this.chart.render === 'antv' &&
(this.chart.type.includes('bar') ||
this.chart.type.includes('line') ||
this.chart.type.includes('area') ||
this.chart.type.includes('pie') ||
this.chart.type === 'funnel' ||
this.chart.type === 'radar' ||
this.chart.type === 'scatter')) {
delete this.componentViewsData[this.chart.id]
if (dataBroadcast) {
bus.$emit('prop-change-data')
}
})
} else {
this.componentViewsData[this.chart.id] = sourceResponseData
if (dataBroadcast) {

View File

@ -349,6 +349,7 @@ import { mapState } from 'vuex'
import GradientColorSelector from '@/components/gradientColorSelector'
import bus from '@/utils/bus'
import { equalsAny } from '@/utils/StringUtils'
import { viewData } from '@/api/panel/panel'
export default {
name: 'ColorSelector',
@ -479,6 +480,9 @@ export default {
}
},
computed: {
panelInfo() {
return this.$store.state.panel.panelInfo
},
checkMapLineGradient() {
const chart = this.chart
if (chart.type === 'flow-map') {
@ -614,6 +618,17 @@ export default {
if (this.componentViewsData[this.chart.id]) {
const chart = JSON.parse(JSON.stringify(this.componentViewsData[this.chart.id]))
this.colorForm.seriesColors = getColors(chart, this.colorForm.colors, reset)
} else {
const requestInfo = {
filter: [],
drill: [],
queryFrom: 'panel'
}
viewData(this.chart.id, this.panelInfo.id, requestInfo).then(response => {
this.componentViewsData[this.chart.id] = response.data
const chart = JSON.parse(JSON.stringify(this.componentViewsData[this.chart.id]))
this.colorForm.seriesColors = getColors(chart, this.colorForm.colors, reset)
})
}
}
}