perf: 优化依赖与首屏加载
This commit is contained in:
@@ -18,7 +18,6 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useState, useMemo, useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import * as XLSX from 'xlsx';
|
||||
import {
|
||||
RefreshCw,
|
||||
Receipt,
|
||||
@@ -161,7 +160,7 @@ const EXPORT_FIELDS = [
|
||||
];
|
||||
|
||||
// 将选中字段组装成一个 worksheet(含表头、列宽)
|
||||
function buildWorksheet(rows, fields, header) {
|
||||
function buildWorksheet(XLSX, rows, fields, header) {
|
||||
const aoa = [header, ...rows.map((r) => fields.map((f) => f.value(r)))];
|
||||
const ws = XLSX.utils.aoa_to_sheet(aoa);
|
||||
ws['!cols'] = fields.map((f) => ({ wch: f.width || 14 }));
|
||||
@@ -455,6 +454,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
}
|
||||
|
||||
const header = fields.map((f) => t(f.label));
|
||||
const XLSX = await import('xlsx');
|
||||
const wb = XLSX.utils.book_new();
|
||||
|
||||
if (exportMode === 'perUser') {
|
||||
@@ -535,7 +535,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
);
|
||||
|
||||
for (const { name, rows } of groups.values()) {
|
||||
const ws = buildWorksheet(rows, fields, header);
|
||||
const ws = buildWorksheet(XLSX, rows, fields, header);
|
||||
XLSX.utils.book_append_sheet(
|
||||
wb,
|
||||
ws,
|
||||
@@ -544,7 +544,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
}
|
||||
} else {
|
||||
// 汇总:所有记录放在一个 sheet 页
|
||||
const ws = buildWorksheet(allLogs, fields, header);
|
||||
const ws = buildWorksheet(XLSX, allLogs, fields, header);
|
||||
XLSX.utils.book_append_sheet(
|
||||
wb,
|
||||
ws,
|
||||
|
||||
Reference in New Issue
Block a user