Merge pull request #3831 from dataease/pr@dev@feat_table_pivot

feat(视图): 透视表行汇总支持按合计排序
This commit is contained in:
xuwei-fit2cloud 2022-11-23 09:10:51 +08:00 committed by GitHub
commit 5462f5ec21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -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(),

View File

@ -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
}
}
}