diff --git a/frontend/src/views/chart/chart/table/table-info.js b/frontend/src/views/chart/chart/table/table-info.js index 3d12c5cc62..63f044588f 100644 --- a/frontend/src/views/chart/chart/table/table-info.js +++ b/frontend/src/views/chart/chart/table/table-info.js @@ -424,7 +424,7 @@ export function baseTablePivot(s2, container, chart, action, tableData) { // 解析合计、小计排序 const sortParams = [] - if (totalCfg.row.totalSort && totalCfg.row.totalSort !== 'none' && c.length > 0 && totalCfg.row.showGrandTotals) { + if (totalCfg.row.totalSort && totalCfg.row.totalSort !== 'none' && c.length > 0 && totalCfg.row.showGrandTotals && v.indexOf(totalCfg.row.totalSortField) > -1) { const sort = { sortFieldId: c[0], sortMethod: totalCfg.row.totalSort.toUpperCase(), @@ -436,7 +436,7 @@ export function baseTablePivot(s2, container, chart, action, tableData) { sortParams.push(sort) } totalCfg.col.totalSort = false - if (totalCfg.col.totalSort && totalCfg.col.totalSort !== 'none' && r.length > 0 && totalCfg.col.showGrandTotals) { + if (totalCfg.col.totalSort && totalCfg.col.totalSort !== 'none' && r.length > 0 && totalCfg.col.showGrandTotals && v.indexOf(totalCfg.col.totalSortField) > -1) { const sort = { sortFieldId: r[0], sortMethod: totalCfg.col.totalSort.toUpperCase(), diff --git a/frontend/src/views/chart/components/shapeAttr/TotalCfg.vue b/frontend/src/views/chart/components/shapeAttr/TotalCfg.vue index 49ef97efe2..d7160abd24 100644 --- a/frontend/src/views/chart/components/shapeAttr/TotalCfg.vue +++ b/frontend/src/views/chart/components/shapeAttr/TotalCfg.vue @@ -422,12 +422,15 @@ export default { this.totalSortFields = JSON.parse(chart.yaxis) } if (this.totalSortFields.length > 0) { - if (this.totalForm.row.totalSortField === '') { + if (this.resetTotalSort(this.totalForm.row.totalSortField)) { this.totalForm.row.totalSortField = this.totalSortFields[0].dataeaseName } - if (this.totalForm.col.totalSortField === '') { + if (this.resetTotalSort(this.totalForm.col.totalSortField)) { this.totalForm.col.totalSortField = this.totalSortFields[0].dataeaseName } + } else { + this.totalForm.row.totalSortField = '' + this.totalForm.col.totalSortField = '' } } }, @@ -437,6 +440,16 @@ export default { }, showProperty(property) { return this.propertyInner.includes(property) + }, + resetTotalSort(field) { + if (field === '') { + return true + } + const sortFieldList = [] + this.totalSortFields.forEach(ele => { + sortFieldList.push(ele.dataeaseName) + }) + return sortFieldList.indexOf(field) === -1 } } }