From 479229102527bf1bd20b624f5241a9ece456aa81 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 17 Jul 2024 16:14:58 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=AF=BC=E5=87=BA;=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E6=B1=87=E6=80=BB=E8=A1=8C=E7=A9=BA;=20=E8=A1=A8?= =?UTF-8?q?=E5=A4=B4=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Data.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Data.jsx b/src/components/Data.jsx index e467f00..d067a63 100644 --- a/src/components/Data.jsx +++ b/src/components/Data.jsx @@ -44,7 +44,7 @@ export const TableExportBtn = (props) => { }), {}) : {}) }), {}); const flatCols = props.columns.flatMap((v, k) => - v.children ? v.children.map((vc, ci) => ({ ...vc, title: `${v?.titleX || v.title}` + (vc?.titleX ? `,${vc.titleX}` : (ci || '')) })) : v + v.children ? v.children.map((vc, ci) => ({ ...vc, title: `${v?.titleX || v.title}` + (vc?.titleX ? `,${vc.titleX}` : (ci || '')) })) : {...v, title: `${v?.titleX || v.title}`} ); // .filter((c) => c.dataIndex) // !['string', 'number'].includes(typeof vc.title) ? `${v?.titleX || v.title}` : `${v?.titleX || v.title}-${vc.title || ''}` @@ -74,7 +74,7 @@ export const TableExportBtn = (props) => { }, {}); return itemMapped; }); - const ws = utils.json_to_sheet([summaryRow, ...data], { header: columnsMap.filter((r) => r.dataIndex).map((r) => r.title) }); + const ws = utils.json_to_sheet([].concat(isEmpty(summaryRow) ? [] : [summaryRow], data), { header: columnsMap.filter((r) => r.dataIndex).map((r) => r.title) }); const wb = utils.book_new(); utils.book_append_sheet(wb, ws, 'sheet'); writeFile(wb, `${output_name}.xlsx`);