@@ -1145,6 +1145,20 @@ export class Dataset {
11451145 indicatorPosition ?: { position : 'col' | 'row' ; index ?: number }
11461146 ) : IAggregator {
11471147 const indicatorIndex = this . indicatorKeys . indexOf ( indicator ) ;
1148+ //#region 获取行和列的维度key,考虑到tree模式被折叠的情况 rowKey colKey会小于rows和columns的长度
1149+ let rowDimensionKey ;
1150+ if ( indicatorPosition ?. position === 'row' ) {
1151+ rowDimensionKey = rowKey . length >= 2 ? this . rows [ rowKey . length - 2 ] : undefined ;
1152+ } else {
1153+ rowDimensionKey = this . rows [ rowKey . length - 1 ] ;
1154+ }
1155+ let colDimensionKey ;
1156+ if ( indicatorPosition ?. position === 'col' ) {
1157+ colDimensionKey = colKey . length >= 2 ? this . columns [ colKey . length - 2 ] : undefined ;
1158+ } else {
1159+ colDimensionKey = this . columns [ colKey . length - 1 ] ;
1160+ }
1161+ //#endregion
11481162 // let agg;
11491163 let flatRowKey ;
11501164 let flatColKey ;
@@ -1165,7 +1179,8 @@ export class Dataset {
11651179 } else if (
11661180 this . totals ?. row ?. subTotalsDimensions &&
11671181 this . totals ?. row ?. subTotalsDimensions ?. length >= 1 &&
1168- rowKey [ rowKey . length - 1 ] !== this . rowSubTotalLabel
1182+ rowKey [ rowKey . length - 1 ] !== this . rowSubTotalLabel &&
1183+ this . totals . row . subTotalsDimensions . find ( dimension => dimension === rowDimensionKey ) //如果维度key在subTotalsDimensions中 则需要补充小计标签名到rowKey中
11691184 ) {
11701185 rowKey . push ( this . rowSubTotalLabel ) ;
11711186 }
@@ -1190,7 +1205,8 @@ export class Dataset {
11901205 } else if (
11911206 this . totals ?. column ?. subTotalsDimensions &&
11921207 this . totals ?. column ?. subTotalsDimensions ?. length >= 1 &&
1193- colKey [ colKey . length - 1 ] !== this . colSubTotalLabel
1208+ colKey [ colKey . length - 1 ] !== this . colSubTotalLabel &&
1209+ this . totals . column . subTotalsDimensions . find ( dimension => dimension === colDimensionKey ) //如果维度key在subTotalsDimensions中 则需要补充小计标签名到colKey中
11941210 ) {
11951211 colKey . push ( this . colSubTotalLabel ) ;
11961212 }
0 commit comments