zmdms-webui 2.6.3 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/canvastable/canvasTable.js +33 -27
- package/dist/es/table/excel.js +61 -8
- package/dist/es/table/table.js +17 -15
- package/package.json +3 -2
|
@@ -40,7 +40,8 @@ import { getTableColumns } from '../table/utils.js';
|
|
|
40
40
|
import DynamicSetting from '../dynamicsetting/dynamicSetting.js';
|
|
41
41
|
|
|
42
42
|
function CanvasTable(props) {
|
|
43
|
-
var _a
|
|
43
|
+
var _a;
|
|
44
|
+
var _b = props.dataSource, dataSource = _b === void 0 ? [] : _b, _c = props.columns, columns = _c === void 0 ? [] : _c, _d = props.rowKey, rowKey = _d === void 0 ? "id" : _d, _e = props.height, height = _e === void 0 ? 600 : _e, width = props.width, _f = props.rowHeight, rowHeight = _f === void 0 ? 36 : _f, _g = props.headerHeight, headerHeight = _g === void 0 ? 36 : _g, rowSelection = props.rowSelection, onSortChange = props.onSortChange, onFilterChange = props.onFilterChange, onScroll = props.onScroll, onRowClick = props.onRowClick, onColumnResize = props.onColumnResize, _h = props.bordered, bordered = _h === void 0 ? true : _h, _j = props.striped, striped = _j === void 0 ? false : _j, _k = props.emptyText, emptyText = _k === void 0 ? "暂无数据" : _k, style = props.style, className = props.className, _l = props.loading, loading = _l === void 0 ? false : _l, _m = props.isContextMenu, isContextMenu = _m === void 0 ? true : _m, isFullscreenHandle = props.isFullscreenHandle, mode = props.mode, dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, customDynamicListHandle = props.customDynamicListHandle, isDimensionDynamic = props.isDimensionDynamic, dimensionCustomSumKeys = props.dimensionCustomSumKeys, isAutoMerge = props.isAutoMerge, _o = props.isIndexMerge, isIndexMerge = _o === void 0 ? true : _o, _p = props.isSelectionMerge, isSelectionMerge = _p === void 0 ? false : _p, _q = props.renderMode, renderMode = _q === void 0 ? "object" : _q, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, _r = props.summaryFixed, summaryFixed = _r === void 0 ? false : _r, _s = props.isAutoScrollY, isAutoScrollY = _s === void 0 ? false : _s, _t = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _t === void 0 ? 65 : _t, canvasTableId = props.canvasTableId, headerWrap = props.headerWrap, _u = props.headerAlign, headerAlign = _u === void 0 ? "center" : _u, tableRefHandle = props.tableRefHandle, exportExcelConfig = props.exportExcelConfig, _v = props.maxHeight, maxHeight = _v === void 0 ? 3000 : _v, expandable = props.expandable;
|
|
44
45
|
var actualMode = "mode" in props ? mode : "index";
|
|
45
46
|
var canvasRef = useRef(null);
|
|
46
47
|
var containerRef = useRef(null);
|
|
@@ -63,17 +64,17 @@ function CanvasTable(props) {
|
|
|
63
64
|
return String((_a = record[rowKey]) !== null && _a !== void 0 ? _a : index);
|
|
64
65
|
}, [rowKey]);
|
|
65
66
|
// 动态列配置
|
|
66
|
-
var
|
|
67
|
+
var _w = useDynamicListByColumns(columns, {
|
|
67
68
|
dynamicKey: dynamicKey,
|
|
68
69
|
dynamicVersion: dynamicVersion,
|
|
69
70
|
customDynamicListHandle: customDynamicListHandle,
|
|
70
|
-
}), defaultDynamicList =
|
|
71
|
+
}), defaultDynamicList = _w.defaultDynamicList, currentDynamicList = _w.currentDynamicList, onCurrentListChange = _w.onCurrentListChange, dynamicSettingRef = _w.dynamicSettingRef;
|
|
71
72
|
// 根据动态列配置处理columns
|
|
72
73
|
var dynamicColumns = useMemo(function () { return getTableColumns(columns, currentDynamicList); }, [columns, currentDynamicList]).columns;
|
|
73
74
|
// 内部列宽状态(未开启动态配置时使用)
|
|
74
|
-
var
|
|
75
|
+
var _x = useState({}), internalColumnWidths = _x[0], setInternalColumnWidths = _x[1];
|
|
75
76
|
// 跟踪用户手动调整过宽度的列(用于排除自动宽度分配)
|
|
76
|
-
var
|
|
77
|
+
var _y = useState(new Set()), manuallyResizedColumnKeys = _y[0], setManuallyResizedColumnKeys = _y[1];
|
|
77
78
|
// 处理选中框列、序号列等
|
|
78
79
|
var processedColumnsOld = useProcessedColumns({
|
|
79
80
|
columns: columns,
|
|
@@ -88,30 +89,30 @@ function CanvasTable(props) {
|
|
|
88
89
|
headerAlign: headerAlign,
|
|
89
90
|
});
|
|
90
91
|
// 表格状态管理
|
|
91
|
-
var
|
|
92
|
+
var _z = useTableState({
|
|
92
93
|
dataSource: dataSource,
|
|
93
94
|
columns: processedColumnsOld,
|
|
94
95
|
rowSelection: rowSelection,
|
|
95
96
|
onFilterChange: onFilterChange,
|
|
96
97
|
isAutoMerge: isAutoMerge,
|
|
97
|
-
}), state =
|
|
98
|
+
}), state = _z.state, setState = _z.setState, processedDataSource = _z.processedDataSource, handleFilterChange = _z.handleFilterChange, closeFilterPopover = _z.closeFilterPopover, autoGeneratedFilters = _z.autoGeneratedFilters;
|
|
98
99
|
// 树形展开管理
|
|
99
|
-
var
|
|
100
|
+
var _0 = useExpandable({
|
|
100
101
|
dataSource: dataSource,
|
|
101
102
|
expandable: expandable,
|
|
102
103
|
rowKey: rowKey,
|
|
103
|
-
}), expandedKeys =
|
|
104
|
+
}), expandedKeys = _0.expandedKeys, flattenedData = _0.flattenedData, toggleExpand = _0.toggleExpand, expandRow = _0.expandRow, collapseRow = _0.collapseRow, setExpandedRowKeys = _0.setExpandedRowKeys, hasExpandable = _0.hasExpandable;
|
|
104
105
|
var order = useMemo(function () {
|
|
105
106
|
return state.sortOrder && state.sortField
|
|
106
107
|
? { field: state.sortField, order: state.sortOrder }
|
|
107
108
|
: undefined;
|
|
108
109
|
}, [state.sortOrder, state.sortField]);
|
|
109
|
-
var
|
|
110
|
+
var _1 = useAutoMerge(processedDataSource, processedColumnsOld, {
|
|
110
111
|
isAutoMerge: isAutoMerge,
|
|
111
112
|
isDimensionDynamic: isDimensionDynamic,
|
|
112
113
|
order: order,
|
|
113
114
|
dimensionCustomSumKeys: dimensionCustomSumKeys,
|
|
114
|
-
}), newDataSource =
|
|
115
|
+
}), newDataSource = _1[0], processedColumns = _1[1];
|
|
115
116
|
// 如果开启了树形展开,使用扁平化后的数据源
|
|
116
117
|
var expandedDataSource = useMemo(function () {
|
|
117
118
|
if (hasExpandable) {
|
|
@@ -120,14 +121,14 @@ function CanvasTable(props) {
|
|
|
120
121
|
return newDataSource;
|
|
121
122
|
}, [hasExpandable, flattenedData, newDataSource]);
|
|
122
123
|
// 生成合计行和最终数据源
|
|
123
|
-
var
|
|
124
|
+
var _2 = useSummaryRow({
|
|
124
125
|
columns: processedColumns,
|
|
125
126
|
dataSource: expandedDataSource,
|
|
126
|
-
}), finalDataSource =
|
|
127
|
+
}), finalDataSource = _2.finalDataSource, hasSummaryRow = _2.hasSummaryRow;
|
|
127
128
|
// 用于存储计算后的表头高度(用于自动高度的精确计算)
|
|
128
|
-
var
|
|
129
|
+
var _3 = useState(undefined), preciseHeaderHeight = _3[0], setPreciseHeaderHeight = _3[1];
|
|
129
130
|
// 用于存储是否需要横向滚动条(用于自动高度的精确计算)
|
|
130
|
-
var
|
|
131
|
+
var _4 = useState(false), needHorizontalScrollbar = _4[0], setNeedHorizontalScrollbar = _4[1];
|
|
131
132
|
// 自动高度计算(需要在容器尺寸计算之前)
|
|
132
133
|
var autoHeight = useCanvasTableAutoHeight(isAutoScrollY, autoScrollYMarginBottom, canvasTableId, finalDataSource.length, // 数据行数(用于 content 模式)
|
|
133
134
|
headerHeight, // 表头基础高度(用于 content 模式的初始计算)
|
|
@@ -194,7 +195,7 @@ function CanvasTable(props) {
|
|
|
194
195
|
return calculateTotalHeight(calculatedHeaderHeight, finalDataSource.length, rowHeight);
|
|
195
196
|
}, [calculatedHeaderHeight, finalDataSource.length, rowHeight]);
|
|
196
197
|
// 计算滚动条指标
|
|
197
|
-
var
|
|
198
|
+
var _5 = useScrollbarMetrics({
|
|
198
199
|
containerWidth: containerWidth,
|
|
199
200
|
containerHeight: containerHeight,
|
|
200
201
|
totalWidth: totalWidth,
|
|
@@ -202,14 +203,14 @@ function CanvasTable(props) {
|
|
|
202
203
|
headerHeight: calculatedHeaderHeight,
|
|
203
204
|
scrollTop: 0,
|
|
204
205
|
scrollLeft: 0,
|
|
205
|
-
}), maxScrollTop =
|
|
206
|
+
}), maxScrollTop = _5.maxScrollTop, maxScrollLeft = _5.maxScrollLeft;
|
|
206
207
|
// 滚动管理(使用预先计算的maxScrollTop和maxScrollLeft)
|
|
207
|
-
var
|
|
208
|
+
var _6 = useTableScroll({
|
|
208
209
|
containerRef: containerRef,
|
|
209
210
|
maxScrollTop: maxScrollTop,
|
|
210
211
|
maxScrollLeft: maxScrollLeft,
|
|
211
212
|
onScroll: onScroll,
|
|
212
|
-
}), scrollState =
|
|
213
|
+
}), scrollState = _6.scrollState, setScrollState = _6.setScrollState;
|
|
213
214
|
// 使用 ref 保存最新的滚动位置,确保在组件卸载过程中仍能访问
|
|
214
215
|
var scrollPositionRef = useRef({ x: 0, y: 0 });
|
|
215
216
|
useEffect(function () {
|
|
@@ -227,6 +228,10 @@ function CanvasTable(props) {
|
|
|
227
228
|
sortOrder: state.sortOrder,
|
|
228
229
|
setScrollState: setScrollState,
|
|
229
230
|
});
|
|
231
|
+
// 容器尺寸变化时重置滚动位置
|
|
232
|
+
useEffect(function () {
|
|
233
|
+
setScrollState(function (prev) { return (__assign(__assign({}, prev), { scrollLeft: 0, scrollTop: 0 })); });
|
|
234
|
+
}, [containerWidth, containerHeight, setScrollState]);
|
|
230
235
|
// 使用实际滚动位置重新计算滚动条的显示位置
|
|
231
236
|
var scrollbarMetrics = useScrollbarMetrics({
|
|
232
237
|
containerWidth: containerWidth,
|
|
@@ -249,12 +254,12 @@ function CanvasTable(props) {
|
|
|
249
254
|
needHorizontalScrollbar,
|
|
250
255
|
]);
|
|
251
256
|
// 单元格框选
|
|
252
|
-
var
|
|
257
|
+
var _7 = useTableSelection({
|
|
253
258
|
state: state,
|
|
254
259
|
setState: setState,
|
|
255
260
|
}),
|
|
256
261
|
// selectionStartRef,
|
|
257
|
-
startSelection =
|
|
262
|
+
startSelection = _7.startSelection, updateSelection = _7.updateSelection, extendSelection = _7.extendSelection;
|
|
258
263
|
// 处理列宽调整
|
|
259
264
|
var handleColumnResize = useCallback(function (columnKey, newWidth) {
|
|
260
265
|
var _a;
|
|
@@ -309,20 +314,20 @@ function CanvasTable(props) {
|
|
|
309
314
|
onCurrentListChange,
|
|
310
315
|
]);
|
|
311
316
|
// 列宽调整
|
|
312
|
-
var
|
|
317
|
+
var _8 = useColumnResize({
|
|
313
318
|
columnRenderInfos: columnRenderInfos,
|
|
314
319
|
containerWidth: containerWidth,
|
|
315
320
|
headerHeight: calculatedHeaderHeight,
|
|
316
321
|
scrollLeft: scrollState.scrollLeft,
|
|
317
322
|
onColumnResize: handleColumnResize,
|
|
318
|
-
}), resizeState =
|
|
323
|
+
}), resizeState = _8.resizeState, checkResizeHandle = _8.checkResizeHandle, startResize = _8.startResize, updateResize = _8.updateResize, endResize = _8.endResize, setHoverResizeColumn = _8.setHoverResizeColumn, getColumnWidth = _8.getColumnWidth, RESIZE_HANDLE_WIDTH = _8.RESIZE_HANDLE_WIDTH;
|
|
319
324
|
// 复制到剪贴板
|
|
320
|
-
var
|
|
325
|
+
var _9 = useCopyToClipboard({
|
|
321
326
|
cellSelection: state.cellSelection,
|
|
322
327
|
processedDataSource: finalDataSource,
|
|
323
328
|
columns: processedColumns,
|
|
324
329
|
containerRef: containerRef,
|
|
325
|
-
}), getSelectedCellsText =
|
|
330
|
+
}), getSelectedCellsText = _9.getSelectedCellsText, copyToClipboard = _9.copyToClipboard;
|
|
326
331
|
// 处理右键菜单的复制操作
|
|
327
332
|
var handleCopy = useCallback(function () {
|
|
328
333
|
var text = getSelectedCellsText();
|
|
@@ -339,9 +344,10 @@ function CanvasTable(props) {
|
|
|
339
344
|
columns: exportColumns,
|
|
340
345
|
isAutoMerge: isAutoMerge,
|
|
341
346
|
summaryConfig: (exportExcelConfig === null || exportExcelConfig === void 0 ? void 0 : exportExcelConfig.isExportNoSummary) ? undefined : [],
|
|
347
|
+
childrenColumnName: (_a = props.expandable) === null || _a === void 0 ? void 0 : _a.childrenColumnName,
|
|
342
348
|
});
|
|
343
349
|
// 交互事件处理(使用baseScrollbarMetrics的maxScrollTop/maxScrollLeft以保持稳定)
|
|
344
|
-
var
|
|
350
|
+
var _10 = useTableInteraction({
|
|
345
351
|
state: state,
|
|
346
352
|
setState: setState,
|
|
347
353
|
scrollState: scrollState,
|
|
@@ -391,7 +397,7 @@ function CanvasTable(props) {
|
|
|
391
397
|
fixedRowsCount: fixedRowsCount,
|
|
392
398
|
fixedRowsConfig: fixedRowsConfig,
|
|
393
399
|
summaryFixed: summaryFixed,
|
|
394
|
-
}), handleCanvasMouseDown =
|
|
400
|
+
}), handleCanvasMouseDown = _10.handleCanvasMouseDown, handleCanvasMouseMove = _10.handleCanvasMouseMove, handleCanvasMouseUp = _10.handleCanvasMouseUp, handleCanvasMouseLeave = _10.handleCanvasMouseLeave, handleCanvasContextMenu = _10.handleCanvasContextMenu;
|
|
395
401
|
// 渲染表格
|
|
396
402
|
useTableRender(__assign(__assign({ canvasRef: canvasRef, processedDataSource: finalDataSource, columnRenderInfos: columnRenderInfos, columns: processedColumns, // 传递原始columns用于渲染多级表头
|
|
397
403
|
state: state, scrollState: scrollState, rowSelection: rowSelection, containerWidth: containerWidth, containerHeight: containerHeight, headerHeight: calculatedHeaderHeight, baseHeaderHeight: headerHeight, // 传入原始基础高度用于计算每层高度
|
package/dist/es/table/excel.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __spreadArray, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
1
|
+
import { __spreadArray, __assign, __awaiter, __generator, __rest } from '../_virtual/_tslib.js';
|
|
2
2
|
import ExcelJS from '../node_modules/exceljs/dist/exceljs.min.js';
|
|
3
3
|
import { useMergeKeys, useNumKeys, useDateKeys } from './hooks.js';
|
|
4
4
|
import { useMemoizedFn } from 'ahooks';
|
|
@@ -6,19 +6,61 @@ import { IS_SUMMARY, MERGE_ROW_SPANS } from './constant.js';
|
|
|
6
6
|
import { exactRound } from 'zmdms-utils';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
8
|
|
|
9
|
+
// 内部常量,用于标记父数据
|
|
10
|
+
var IS_PARENT = "__is_parent__";
|
|
11
|
+
var PARENT_LEVEL = "__parent_level__";
|
|
12
|
+
/**
|
|
13
|
+
* 扁平化树形数据
|
|
14
|
+
* @param records 原始数据数组
|
|
15
|
+
* @param childrenColumnName 子节点字段名,默认为 'children'
|
|
16
|
+
* @returns 扁平化后的数据数组
|
|
17
|
+
*/
|
|
18
|
+
function flattenTreeData(records, childrenColumnName) {
|
|
19
|
+
if (childrenColumnName === void 0) { childrenColumnName = "children"; }
|
|
20
|
+
if (!Array.isArray(records) || records.length === 0) {
|
|
21
|
+
return records;
|
|
22
|
+
}
|
|
23
|
+
var result = [];
|
|
24
|
+
var flatten = function (items, level) {
|
|
25
|
+
if (level === void 0) { level = 0; }
|
|
26
|
+
items.forEach(function (item) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
var hasChildren = item[childrenColumnName] &&
|
|
29
|
+
Array.isArray(item[childrenColumnName]) &&
|
|
30
|
+
item[childrenColumnName].length > 0;
|
|
31
|
+
// 创建当前项的副本(不包含 children)
|
|
32
|
+
var _c = item, _d = childrenColumnName, children = _c[_d], itemWithoutChildren = __rest(_c, [typeof _d === "symbol" ? _d : _d + ""]);
|
|
33
|
+
if (hasChildren) {
|
|
34
|
+
// 这是父数据,添加标记
|
|
35
|
+
result.push(__assign(__assign({}, itemWithoutChildren), (_a = {}, _a[IS_PARENT] = true, _a[PARENT_LEVEL] = level, _a)));
|
|
36
|
+
// 递归处理子数据
|
|
37
|
+
flatten(children, level + 1);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// 这是叶子节点或没有子节点的数据
|
|
41
|
+
result.push(__assign(__assign({}, itemWithoutChildren), (_b = {}, _b[IS_PARENT] = false, _b[PARENT_LEVEL] = level, _b)));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
flatten(records, 0);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
9
48
|
/**
|
|
10
49
|
* 使用 ExcelJS + 后处理添加批注
|
|
11
50
|
* 导出Excel,支持维度合并和小计,以及批注功能
|
|
12
51
|
*/
|
|
13
|
-
function exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys, dateKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight) {
|
|
52
|
+
function exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys, dateKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight, childrenColumnName) {
|
|
14
53
|
var _a;
|
|
15
54
|
var _this = this;
|
|
16
55
|
if (fileName === void 0) { fileName = "export.xlsx"; }
|
|
17
56
|
if (sheetName === void 0) { sheetName = "Sheet1"; }
|
|
57
|
+
if (childrenColumnName === void 0) { childrenColumnName = "children"; }
|
|
18
58
|
if (!records || records.length === 0) {
|
|
19
59
|
throw new Error("没有数据可导出");
|
|
20
60
|
}
|
|
21
|
-
|
|
61
|
+
// 扁平化树形数据
|
|
62
|
+
var flattenedRecords = flattenTreeData(records, childrenColumnName);
|
|
63
|
+
var processedData = applyPrecisionToRecords(flattenedRecords, columns);
|
|
22
64
|
// 准备Excel数据
|
|
23
65
|
var excelData = prepareExcelData(processedData, columns, columnHeaders, topDescription);
|
|
24
66
|
// 创建工作簿
|
|
@@ -361,6 +403,9 @@ function createWorksheetWithMerge(workbook, excelData, mergeKeys, sheetName) {
|
|
|
361
403
|
return "continue";
|
|
362
404
|
for (var rowIndex = 0; rowIndex < data.length; rowIndex++) {
|
|
363
405
|
var rowData = data[rowIndex];
|
|
406
|
+
// 跳过父数据的合并,父数据不参与列合并
|
|
407
|
+
if (rowData[IS_PARENT])
|
|
408
|
+
continue;
|
|
364
409
|
var spanCount = (_a = rowData[MERGE_ROW_SPANS]) === null || _a === void 0 ? void 0 : _a[mergeKey];
|
|
365
410
|
if (spanCount && spanCount > 1) {
|
|
366
411
|
var startRow = headerRowCount + rowIndex + 1;
|
|
@@ -500,9 +545,15 @@ function applyExcelStyles(worksheet, data, numKeys, dateKeys, columns, headerRow
|
|
|
500
545
|
for (var rowIndex = 0; rowIndex < data.length; rowIndex++) {
|
|
501
546
|
var rowData = data[rowIndex];
|
|
502
547
|
var isSubtotal = rowData.__is_summary__;
|
|
548
|
+
var isParent = rowData[IS_PARENT];
|
|
503
549
|
for (var c = 1; c <= totalCols; c++) {
|
|
504
550
|
var cell = worksheet.getCell(headerRowCount + rowIndex + 1, c);
|
|
505
|
-
|
|
551
|
+
// 优先级:小计行 > 父数据 > 普通数据
|
|
552
|
+
var base = isSubtotal
|
|
553
|
+
? summaryStyle
|
|
554
|
+
: isParent
|
|
555
|
+
? summaryStyle
|
|
556
|
+
: normalStyle;
|
|
506
557
|
var columnAlign = columns && Array.isArray(columns)
|
|
507
558
|
? (_c = columns[c - 1]) === null || _c === void 0 ? void 0 : _c.align
|
|
508
559
|
: undefined;
|
|
@@ -570,22 +621,23 @@ function applyExcelStyles(worksheet, data, numKeys, dateKeys, columns, headerRow
|
|
|
570
621
|
/**
|
|
571
622
|
* 主要的导出函数,使用改进的批注功能
|
|
572
623
|
*/
|
|
573
|
-
function exportToExcelWithMerge(records, columns, mergeKeys, numKeys, dateKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight) {
|
|
624
|
+
function exportToExcelWithMerge(records, columns, mergeKeys, numKeys, dateKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight, childrenColumnName) {
|
|
574
625
|
if (fileName === void 0) { fileName = "export.xlsx"; }
|
|
575
626
|
if (sheetName === void 0) { sheetName = "Sheet1"; }
|
|
576
|
-
|
|
627
|
+
if (childrenColumnName === void 0) { childrenColumnName = "children"; }
|
|
628
|
+
return exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys, dateKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight, childrenColumnName);
|
|
577
629
|
}
|
|
578
630
|
/**
|
|
579
631
|
* 简化版本的导出函数
|
|
580
632
|
*/
|
|
581
633
|
function exportToExcelSimple(records, config) {
|
|
582
|
-
return exportToExcelWithMerge(records, config.columns || [], config.mergeKeys, config.numKeys || [], config.dateKeys, config.fileName || "export.xlsx", config.sheetName || "Sheet1", config.columnHeaders, config.summaryConfig, config.topDescription, config.topDescriptionRowHeight);
|
|
634
|
+
return exportToExcelWithMerge(records, config.columns || [], config.mergeKeys, config.numKeys || [], config.dateKeys, config.fileName || "export.xlsx", config.sheetName || "Sheet1", config.columnHeaders, config.summaryConfig, config.topDescription, config.topDescriptionRowHeight, config.childrenColumnName || "children");
|
|
583
635
|
}
|
|
584
636
|
/**
|
|
585
637
|
* Hook 版本,支持选择导出方式
|
|
586
638
|
*/
|
|
587
639
|
function useExcelExport(records, config) {
|
|
588
|
-
var columns = config.columns, isAutoMerge = config.isAutoMerge, columnHeaders = config.columnHeaders, summaryConfig = config.summaryConfig;
|
|
640
|
+
var columns = config.columns, isAutoMerge = config.isAutoMerge, columnHeaders = config.columnHeaders, summaryConfig = config.summaryConfig, childrenColumnName = config.childrenColumnName;
|
|
589
641
|
var mergeKeys = useMergeKeys(columns, isAutoMerge);
|
|
590
642
|
var numKeys = useNumKeys(columns);
|
|
591
643
|
var dateKeys = useDateKeys(columns);
|
|
@@ -607,6 +659,7 @@ function useExcelExport(records, config) {
|
|
|
607
659
|
summaryConfig: summaryConfig,
|
|
608
660
|
topDescription: topDescription,
|
|
609
661
|
topDescriptionRowHeight: topDescriptionRowHeight,
|
|
662
|
+
childrenColumnName: childrenColumnName,
|
|
610
663
|
});
|
|
611
664
|
});
|
|
612
665
|
return exportFunction;
|
package/dist/es/table/table.js
CHANGED
|
@@ -40,8 +40,9 @@ import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js'
|
|
|
40
40
|
// completed: 过滤功能
|
|
41
41
|
// completed: 实现从execl复制到表格中的功能
|
|
42
42
|
var Table = function (props) {
|
|
43
|
+
var _a;
|
|
43
44
|
// console.log("表格渲染");
|
|
44
|
-
var className = props.className,
|
|
45
|
+
var className = props.className, _b = props.bordered, bordered = _b === void 0 ? true : _b, _c = props.pagination, pagination = _c === void 0 ? false : _c, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, customDynamicListHandle = props.customDynamicListHandle, isRemeberFilter = props.isRemeberFilter, _d = props.isOrderUpdateData, isOrderUpdateData = _d === void 0 ? true : _d, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle, _e = props.isTheadTitleAdd, isTheadTitleAdd = _e === void 0 ? true : _e, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, delPopTitle = props.delPopTitle, hiddenDelBtnHandle = props.hiddenDelBtnHandle, _f = props.isDelAll, isDelAll = _f === void 0 ? true : _f, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _g = props.summaryFixed, summaryFixed = _g === void 0 ? true : _g, isInnerPagination = props.isInnerPagination, _h = props.innerPaginationPageSize, innerPaginationPageSize = _h === void 0 ? 30 : _h, _j = props.innerPaginationPosition, innerPaginationPosition = _j === void 0 ? INNER_TABLE_PAGINATION_POSITION : _j, _k = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _k === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _k, innerPaginationConfig = props.innerPaginationConfig, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _l = props.isResizableColumn, isResizableColumn = _l === void 0 ? true : _l, _m = props.isResizableTitleEllipsis, isResizableTitleEllipsis = _m === void 0 ? true : _m, _o = props.isRealTimeValidate, isRealTimeValidate = _o === void 0 ? true : _o, isMarginTop = props.isMarginTop, isMarginBottom = props.isMarginBottom, scroll = props.scroll, addAndDelProps = props.addAndDelProps, _p = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _p === void 0 ? 65 : _p, _q = props.isAutoScrollY, isAutoScrollY = _q === void 0 ? false : _q, tableId = props.tableId, extraOnRow = props.onRow, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, headerAlign = props.headerAlign, isDimensionDynamic = props.isDimensionDynamic, dimensionCustomSumKeys = props.dimensionCustomSumKeys, isAutoMerge = props.isAutoMerge, mode = props.mode, rowSelection = props.rowSelection, isContextMenu = props.isContextMenu, isFullscreenHandle = props.isFullscreenHandle, _r = props.isExportSummary, isExportSummary = _r === void 0 ? true : _r, isAutoMergeAddAndDel = props.isAutoMergeAddAndDel, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "customDynamicListHandle", "isRemeberFilter", "isOrderUpdateData", "hiddenDynamicIcon", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "hiddenAddBtnHandle", "isTheadTitleAdd", "addMode", "addCallback", "isDel", "delPopTitle", "hiddenDelBtnHandle", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "innerPaginationConfig", "tableRefHandle", "tableName", "serviceOrder", "differences", "virtualKey", "isResizableColumn", "isResizableTitleEllipsis", "isRealTimeValidate", "isMarginTop", "isMarginBottom", "scroll", "addAndDelProps", "autoScrollYMarginBottom", "isAutoScrollY", "tableId", "onRow", "fixedRowsCount", "fixedRowsConfig", "headerAlign", "isDimensionDynamic", "dimensionCustomSumKeys", "isAutoMerge", "mode", "rowSelection", "isContextMenu", "isFullscreenHandle", "isExportSummary", "isAutoMergeAddAndDel"]);
|
|
45
46
|
var classes = classNames("ztxk-table", className, {
|
|
46
47
|
"ztxk-table--flex": isFlex,
|
|
47
48
|
});
|
|
@@ -53,25 +54,25 @@ var Table = function (props) {
|
|
|
53
54
|
id: menuId,
|
|
54
55
|
}).show;
|
|
55
56
|
// 针对SCU和增减行 做特殊处理
|
|
56
|
-
var
|
|
57
|
+
var _s = useScuRfresh(), refreshScuCell = _s.refreshScuCell, getRefreshScuCell = _s.getRefreshScuCell;
|
|
57
58
|
// 做一些前置处理
|
|
58
59
|
// 比如过滤某些列 不做展示
|
|
59
60
|
var columns = useParseColumns(_columns);
|
|
60
61
|
// 得到动态列配置信息
|
|
61
|
-
var
|
|
62
|
+
var _t = useDynamicListByColumns(columns, {
|
|
62
63
|
dynamicKey: dynamicKey,
|
|
63
64
|
dynamicVersion: dynamicVersion,
|
|
64
65
|
customDynamicListHandle: customDynamicListHandle,
|
|
65
|
-
}), defaultDynamicList =
|
|
66
|
+
}), defaultDynamicList = _t.defaultDynamicList, onCurrentListChange = _t.onCurrentListChange, currentDynamicList = _t.currentDynamicList, dynamicSettingRef = _t.dynamicSettingRef;
|
|
66
67
|
// 因为内部分页需要知晓当前页面的数据展示,要不然数据排序就跟内部分页没关系了
|
|
67
68
|
// 自定义排序方法
|
|
68
|
-
var
|
|
69
|
+
var _u = useCustomSort(dataSource, onTableChange, {
|
|
69
70
|
refreshScuCell: refreshScuCell,
|
|
70
71
|
rowKey: props === null || props === void 0 ? void 0 : props.rowKey,
|
|
71
72
|
serviceOrder: serviceOrder,
|
|
72
73
|
isOrderUpdateData: isOrderUpdateData,
|
|
73
74
|
isAutoMerge: isAutoMerge,
|
|
74
|
-
}), order =
|
|
75
|
+
}), order = _u.order, setOrder = _u.setOrder, customSortHandle = _u.customSortHandle, sortDataSource = _u.sortDataSource;
|
|
75
76
|
// 当前表格展示的数据
|
|
76
77
|
// 如果开启了前端排序的话,排序后的数据,可能会影响到很多地方。
|
|
77
78
|
// 所以后续操作的数据 应该用
|
|
@@ -98,12 +99,12 @@ var Table = function (props) {
|
|
|
98
99
|
return scroll || {};
|
|
99
100
|
}, [scroll, currentTableDataSource, virtualKey, scrolly, isAutoScrollY]);
|
|
100
101
|
// 内部分页相关配置
|
|
101
|
-
var
|
|
102
|
+
var _v = useInnerPagination(isInnerPagination, innerPaginationPageSize, {
|
|
102
103
|
innerPaginationPosition: innerPaginationPosition,
|
|
103
104
|
innerPaginationPageSizeOptions: innerPaginationPageSizeOptions,
|
|
104
105
|
innerPaginationConfig: innerPaginationConfig,
|
|
105
106
|
dataSource: currentTableDataSource,
|
|
106
|
-
}), paginationConfig =
|
|
107
|
+
}), paginationConfig = _v.paginationConfig, currentPage = _v.currentPage, setCurrent = _v.setCurrent, pageSize = _v.pageSize;
|
|
107
108
|
// 内部表格编辑事件
|
|
108
109
|
var onEditableSave = useEditChange(dataSourceRef, onTableChange);
|
|
109
110
|
// 记录表头过滤的一些配置(通过ref记录,key => filter) 复制整列、过滤后修改数据,需要先走过滤
|
|
@@ -131,9 +132,9 @@ var Table = function (props) {
|
|
|
131
132
|
filterConfigRef: filterConfigRef,
|
|
132
133
|
});
|
|
133
134
|
// 表格内部自定义处理过滤,不走antd内部
|
|
134
|
-
var
|
|
135
|
+
var _w = useCustomFilter(currentTableDataSource), filterDataSource = _w[0], handleFilterConfigChange = _w[1];
|
|
135
136
|
// 处理列配置信息 得到新的列配置信息
|
|
136
|
-
var
|
|
137
|
+
var _x = useColumns(columns, {
|
|
137
138
|
// 动态列配置相关信息
|
|
138
139
|
dynamicKey: dynamicKey,
|
|
139
140
|
isRemeberFilter: isRemeberFilter,
|
|
@@ -176,14 +177,14 @@ var Table = function (props) {
|
|
|
176
177
|
isAutoMerge: isAutoMerge,
|
|
177
178
|
handleFilterConfigChange: handleFilterConfigChange,
|
|
178
179
|
isAutoMergeAddAndDel: isAutoMergeAddAndDel,
|
|
179
|
-
}), _newColumns =
|
|
180
|
+
}), _newColumns = _x.newColumns, newRowSelection = _x.rowSelection;
|
|
180
181
|
// 处理表格合并和维度
|
|
181
|
-
var
|
|
182
|
+
var _y = useAutoMerge(filterDataSource, _newColumns, {
|
|
182
183
|
isAutoMerge: isAutoMerge,
|
|
183
184
|
isDimensionDynamic: isDimensionDynamic,
|
|
184
185
|
order: order,
|
|
185
186
|
dimensionCustomSumKeys: dimensionCustomSumKeys,
|
|
186
|
-
}), newDataSource =
|
|
187
|
+
}), newDataSource = _y[0], newColumns = _y[1];
|
|
187
188
|
// 内部表格总结栏
|
|
188
189
|
var getSummaryHandle = useSummary(summaryConfig, newColumns, {
|
|
189
190
|
summaryFixed: summaryFixed,
|
|
@@ -193,7 +194,7 @@ var Table = function (props) {
|
|
|
193
194
|
isDel: isDel,
|
|
194
195
|
});
|
|
195
196
|
// 表格验证
|
|
196
|
-
var
|
|
197
|
+
var _z = useTableValidate(), tableRef = _z.tableRef, getCurrentTable = _z.getCurrentTable, clearErrorClass = _z.clearErrorClass;
|
|
197
198
|
// 使用 ref 缓存最新的滚动位置,确保在组件卸载过程中仍能访问
|
|
198
199
|
var scrollPositionRef = useRef({ x: 0, y: 0 });
|
|
199
200
|
// 滚动条控制方法
|
|
@@ -326,6 +327,7 @@ var Table = function (props) {
|
|
|
326
327
|
columns: newColumns,
|
|
327
328
|
isAutoMerge: isAutoMerge,
|
|
328
329
|
summaryConfig: isExportSummary ? summaryConfig : undefined,
|
|
330
|
+
childrenColumnName: (_a = props.expandable) === null || _a === void 0 ? void 0 : _a.childrenColumnName,
|
|
329
331
|
});
|
|
330
332
|
// 暴露给外部一些方法
|
|
331
333
|
useImperativeHandle(tableRefHandle, function () {
|
|
@@ -398,7 +400,7 @@ var Table = function (props) {
|
|
|
398
400
|
};
|
|
399
401
|
});
|
|
400
402
|
// 全屏的一些方法
|
|
401
|
-
var
|
|
403
|
+
var _0 = useState(false), isFull = _0[0], setIsFull = _0[1];
|
|
402
404
|
var fullscreenHandle = useMemoizedFn(function (isFull) {
|
|
403
405
|
isFullscreenHandle === null || isFullscreenHandle === void 0 ? void 0 : isFullscreenHandle(isFull);
|
|
404
406
|
setIsFull(isFull);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zmdms-webui",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"test": "craco test",
|
|
42
42
|
"eject": "craco eject",
|
|
43
43
|
"storybook": "storybook dev -p 6006",
|
|
44
|
-
"build-storybook": "storybook build"
|
|
44
|
+
"build-storybook": "storybook build",
|
|
45
|
+
"publish:npm": "node publish.cjs"
|
|
45
46
|
},
|
|
46
47
|
"eslintConfig": {
|
|
47
48
|
"extends": [
|