Skip to content

Commit f649e2a

Browse files
committed
refactor: getCellAdressByHeaderPath api
1 parent bdc8eb9 commit f649e2a

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

packages/vtable/src/layout/pivot-header-layout.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,14 +3347,17 @@ export class PivotHeaderLayoutMap implements LayoutMapAPI {
33473347
if (this.rowHierarchyType === 'grid') {
33483348
// defaultCol = (this.rowHeaderTitle ? afterSpanLevel + 1 : afterSpanLevel) + this.leftRowSeriesNumberColumnCount;
33493349
// 传入rowHeaderPaths是合并单元格如行总计的path数据的情况,上面defaultCol总是返回0 所以需要修改如下:
3350-
const col = rowHeaderPaths.reduce((acc, path) => {
3351-
const index = this.rowDimensionKeys.indexOf(path.dimensionKey);
3352-
if (index >= 0) {
3353-
acc += 1;
3354-
}
3355-
return acc;
3356-
}, -1);
3357-
defaultCol = (this.rowHeaderTitle ? col + 1 : col) + this.leftRowSeriesNumberColumnCount;
3350+
//检查rowHeaderPaths 和this.rowDimensionKeys数组中的维度key是否匹配
3351+
const isMatch = rowHeaderPaths.every((path: IDimensionInfo, index: number) => {
3352+
return this.rowDimensionKeys[index] === path.dimensionKey;
3353+
});
3354+
if (isMatch) {
3355+
const col = rowHeaderPaths.length - 1;
3356+
defaultCol = (this.rowHeaderTitle ? col + 1 : col) + this.leftRowSeriesNumberColumnCount;
3357+
} else {
3358+
defaultCol =
3359+
(this.rowHeaderTitle ? afterSpanLevel + 1 : afterSpanLevel) + this.leftRowSeriesNumberColumnCount;
3360+
}
33583361
} else {
33593362
defaultCol = 0;
33603363
} //树形展示的情况下 肯定是在第0列

0 commit comments

Comments
 (0)