Skip to content

Commit

Permalink
fix: pr problem
Browse files Browse the repository at this point in the history
  • Loading branch information
YardWill committed Dec 3, 2021
1 parent 6d06e90 commit 8defa4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/s2-core/src/common/interface/node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 角头 node 类型
export enum CornerNodeType {
ROW = 'row',
Row = 'row',
Col = 'col',
}
14 changes: 9 additions & 5 deletions packages/s2-core/src/utils/export/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { last, isEmpty, clone, trim, max, isObject, forEach } from 'lodash';
import { getCsvString } from './export-worker';
import { SpreadSheet } from '@/sheet-type';
import { ViewMeta } from '@/common/interface';
import { CornerNodeType, ViewMeta } from '@/common/interface';
import {
ID_SEPARATOR,
EMPTY_PLACEHOLDER,
Expand Down Expand Up @@ -201,20 +201,24 @@ export const copyData = (
headers = colHeader.map((item, index) => {
if (sheetInstance.isPivotMode()) {
const { columns, rows, data } = sheetInstance.facet.cornerHeader.cfg;
const colNode = data.filter((e) => e.cornerType === 'col');
const rowNode = data.filter((e) => e.cornerType === 'row');
const colNodes = data.filter(
({ cornerType }) => cornerType === CornerNodeType.Col,
);
const rowNodes = data.filter(
({ cornerType }) => cornerType === CornerNodeType.Row,
);

if (index < colHeader.length - 1) {
return [
...Array(rowLength - 1).fill(''),
colNode.find((v) => v.field === columns[index])?.label || '',
colNodes.find(({ field }) => field === columns[index])?.label || '',
...item,
];
}
if (index < colHeader.length) {
return [
...rows.map(
(row) => rowNode.find((v) => v.field === row)?.label || '',
(row) => rowNodes.find(({ field }) => field === row)?.label || '',
),
...item,
];
Expand Down

0 comments on commit 8defa4a

Please sign in to comment.