Skip to content

Commit

Permalink
chore: getMultiData 使用传参格式改回
Browse files Browse the repository at this point in the history
  • Loading branch information
JuZe committed Oct 17, 2023
1 parent 033441d commit fa51116
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 33 deletions.
16 changes: 8 additions & 8 deletions packages/s2-core/src/data-set/base-data-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ export abstract class BaseDataSet {
* To get a row or column cells data;
* if query is empty, return all data
* @param query
* @param option
* - withMissedField 用于标记是否需要汇总数据混入其中,在排序功能中使用
* @param isTotals
* @param isRow
* @param drillDownFields
* @param withMissedField 用于标记是否需要汇总数据混入其中,在排序功能中使用
*/
public abstract getMultiData(
query: DataType,
option?: {
isTotals?: boolean;
isRow?: boolean;
drillDownFields?: string[];
withMissedField?: boolean;
},
isTotals?: boolean,
isRow?: boolean,
drillDownFields?: string[],
withMissedField?: boolean,
): DataType[];

public moreThanOneValue() {
Expand Down
11 changes: 4 additions & 7 deletions packages/s2-core/src/data-set/pivot-data-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,11 @@ export class PivotDataSet extends BaseDataSet {

public getMultiData(
query: DataType,
option: {
isTotals?: boolean;
isRow?: boolean;
drillDownFields?: string[];
withMissedField?: boolean;
} = {},
isTotals?: boolean,
isRow?: boolean,
drillDownFields?: string[],
withMissedField?: boolean,
): DataType[] {
const { isTotals, isRow, drillDownFields, withMissedField } = option;
if (isEmpty(query)) {
return compact(customFlattenDeep(this.indexesData));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/src/data-set/table-data-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class TableDataSet extends BaseDataSet {
return rowData[query.col];
}

public getMultiData(query: DataType): DataType[] {
public getMultiData(query: DataType, isTotals?: boolean): DataType[] {
return this.displayData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ export class RowTextClick extends BaseEvent implements BaseEventImplement {
private getRowData = (cellData: Node): Data => {
const leafNode = cellData.getHeadLeafChild();

const data = this.spreadsheet.dataSet.getMultiData(leafNode?.query, {
isTotals: leafNode?.isTotals,
isRow: true,
})[0];
const data = this.spreadsheet.dataSet.getMultiData(
leafNode?.query,
leafNode?.isTotals,
true,
)[0];

return {
...data,
Expand Down
10 changes: 7 additions & 3 deletions packages/s2-core/src/utils/sort-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,13 @@ export const getSortByMeasureValues = (
const { dataSet, sortParam, originValues } = params;
const { fields } = dataSet;
const { sortByMeasure, query, sortFieldId } = sortParam;
const dataList = dataSet.getMultiData(query, {
withMissedField: true,
}); // 按 query 查出所有数据
const dataList = dataSet.getMultiData(
query,
undefined,
undefined,
undefined,
true,
); // 按 query 查出所有数据
const columns = getLeafColumnsWithKey(fields.columns);
/**
* 按明细数据
Expand Down
6 changes: 1 addition & 5 deletions packages/s2-react/playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ const partDrillDown: PartDrillDown = {
const dataSet = meta.spreadsheet.dataSet;
const field = drillFields[0];
const rowDatas = dataSet
.getMultiData(meta.query, {
isTotals: true,
isRow: true,
drillDownFields: [preDrillDownfield],
})
.getMultiData(meta.query, true, true, [preDrillDownfield])
.filter(
(item) => item.sub_type && item.type && item[preDrillDownfield],
);
Expand Down
6 changes: 1 addition & 5 deletions packages/s2-vue/playground/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,7 @@ const partDrillDown: PartDrillDown = {
const dataSet = meta.spreadsheet.dataSet;
const field = drillFields[0];
const rowData = dataSet
.getMultiData(meta?.query as DataType, {
isTotals: true,
isRow: true,
drillDownFields: [preDrillDownfield],
})
.getMultiData(meta?.query as DataType, true, true, [preDrillDownfield])
.filter(
(item) => item.sub_type && item.type && item[preDrillDownfield],
);
Expand Down

0 comments on commit fa51116

Please sign in to comment.