fix(视图-透视表): 透视表汇总排序错误

This commit is contained in:
wisonic-s 2024-01-25 19:29:46 +08:00
parent 9bb04e99ba
commit 21ed2c84d1
2 changed files with 8 additions and 10 deletions

View File

@ -502,9 +502,7 @@ onMounted(() => {
</el-radio-group>
</el-form-item>
<el-form-item
v-show="
false && chart.type === 'table-pivot' && state.tableTotalForm.col?.totalSort !== 'none'
"
v-show="chart.type === 'table-pivot' && state.tableTotalForm.col?.totalSort !== 'none'"
:label="t('chart.total_sort_field')"
class="form-item"
>

View File

@ -307,30 +307,30 @@ function customCalcFunc(query, data, totalCfgMap) {
switch (aggregation) {
case 'SUM': {
return data.reduce((p, n) => {
return p + n[n[EXTRA_FIELD]]
return p + n[query[EXTRA_FIELD]]
}, 0)
}
case 'AVG': {
const sum = data.reduce((p, n) => {
return p + n[n[EXTRA_FIELD]]
return p + n[query[EXTRA_FIELD]]
}, 0)
return sum / data.length
}
case 'MIN': {
const result = minBy(data, n => {
return n[n[EXTRA_FIELD]]
return n[query[EXTRA_FIELD]]
})
return result[result[EXTRA_FIELD]]
return result[query[EXTRA_FIELD]]
}
case 'MAX': {
const result = maxBy(data, n => {
return n[n[EXTRA_FIELD]]
return n[query[EXTRA_FIELD]]
})
return result[result[EXTRA_FIELD]]
return result[query[EXTRA_FIELD]]
}
default: {
return data.reduce((p, n) => {
return p + n[n[EXTRA_FIELD]]
return p + n[query[EXTRA_FIELD]]
}, 0)
}
}