zmdms-webui 2.5.6 → 2.5.7

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.
@@ -39,7 +39,7 @@ import { getTableColumns } from '../table/utils.js';
39
39
  import DynamicSetting from '../dynamicsetting/dynamicSetting.js';
40
40
 
41
41
  function CanvasTable(props) {
42
- var _a = props.dataSource, dataSource = _a === void 0 ? [] : _a, _b = props.columns, columns = _b === void 0 ? [] : _b, _c = props.rowKey, rowKey = _c === void 0 ? "id" : _c, _d = props.height, height = _d === void 0 ? 600 : _d, width = props.width, _e = props.rowHeight, rowHeight = _e === void 0 ? 36 : _e, _f = props.headerHeight, headerHeight = _f === void 0 ? 36 : _f, rowSelection = props.rowSelection, onSortChange = props.onSortChange, onFilterChange = props.onFilterChange, onScroll = props.onScroll, onRowClick = props.onRowClick, onColumnResize = props.onColumnResize, _g = props.bordered, bordered = _g === void 0 ? true : _g, _h = props.striped, striped = _h === void 0 ? false : _h, _j = props.emptyText, emptyText = _j === void 0 ? "暂无数据" : _j, style = props.style, className = props.className, _k = props.loading, loading = _k === void 0 ? false : _k, _l = props.isContextMenu, isContextMenu = _l === void 0 ? true : _l, isFullscreenHandle = props.isFullscreenHandle, mode = props.mode, dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, customDynamicListHandle = props.customDynamicListHandle, isDimensionDynamic = props.isDimensionDynamic, dimensionCustomSumKeys = props.dimensionCustomSumKeys, isAutoMerge = props.isAutoMerge, _m = props.isIndexMerge, isIndexMerge = _m === void 0 ? true : _m, _o = props.isSelectionMerge, isSelectionMerge = _o === void 0 ? false : _o, _p = props.renderMode, renderMode = _p === void 0 ? "object" : _p, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, _q = props.summaryFixed, summaryFixed = _q === void 0 ? false : _q, _r = props.isAutoScrollY, isAutoScrollY = _r === void 0 ? false : _r, _s = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _s === void 0 ? 65 : _s, canvasTableId = props.canvasTableId, headerWrap = props.headerWrap, _t = props.headerAlign, headerAlign = _t === void 0 ? "center" : _t, tableRefHandle = props.tableRefHandle, exportExcelConfig = props.exportExcelConfig;
42
+ var _a = props.dataSource, dataSource = _a === void 0 ? [] : _a, _b = props.columns, columns = _b === void 0 ? [] : _b, _c = props.rowKey, rowKey = _c === void 0 ? "id" : _c, _d = props.height, height = _d === void 0 ? 600 : _d, width = props.width, _e = props.rowHeight, rowHeight = _e === void 0 ? 36 : _e, _f = props.headerHeight, headerHeight = _f === void 0 ? 36 : _f, rowSelection = props.rowSelection, onSortChange = props.onSortChange, onFilterChange = props.onFilterChange, onScroll = props.onScroll, onRowClick = props.onRowClick, onColumnResize = props.onColumnResize, _g = props.bordered, bordered = _g === void 0 ? true : _g, _h = props.striped, striped = _h === void 0 ? false : _h, _j = props.emptyText, emptyText = _j === void 0 ? "暂无数据" : _j, style = props.style, className = props.className, _k = props.loading, loading = _k === void 0 ? false : _k, _l = props.isContextMenu, isContextMenu = _l === void 0 ? true : _l, isFullscreenHandle = props.isFullscreenHandle, mode = props.mode, dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, customDynamicListHandle = props.customDynamicListHandle, isDimensionDynamic = props.isDimensionDynamic, dimensionCustomSumKeys = props.dimensionCustomSumKeys, isAutoMerge = props.isAutoMerge, _m = props.isIndexMerge, isIndexMerge = _m === void 0 ? true : _m, _o = props.isSelectionMerge, isSelectionMerge = _o === void 0 ? false : _o, _p = props.renderMode, renderMode = _p === void 0 ? "object" : _p, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, _q = props.summaryFixed, summaryFixed = _q === void 0 ? false : _q, _r = props.isAutoScrollY, isAutoScrollY = _r === void 0 ? false : _r, _s = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _s === void 0 ? 65 : _s, canvasTableId = props.canvasTableId, headerWrap = props.headerWrap, _t = props.headerAlign, headerAlign = _t === void 0 ? "center" : _t, tableRefHandle = props.tableRefHandle, exportExcelConfig = props.exportExcelConfig, _u = props.maxHeight, maxHeight = _u === void 0 ? 3000 : _u;
43
43
  var actualMode = "mode" in props ? mode : "index";
44
44
  var canvasRef = useRef(null);
45
45
  var containerRef = useRef(null);
@@ -62,17 +62,17 @@ function CanvasTable(props) {
62
62
  return String((_a = record[rowKey]) !== null && _a !== void 0 ? _a : index);
63
63
  }, [rowKey]);
64
64
  // 动态列配置
65
- var _u = useDynamicListByColumns(columns, {
65
+ var _v = useDynamicListByColumns(columns, {
66
66
  dynamicKey: dynamicKey,
67
67
  dynamicVersion: dynamicVersion,
68
68
  customDynamicListHandle: customDynamicListHandle,
69
- }), defaultDynamicList = _u.defaultDynamicList, currentDynamicList = _u.currentDynamicList, onCurrentListChange = _u.onCurrentListChange, dynamicSettingRef = _u.dynamicSettingRef;
69
+ }), defaultDynamicList = _v.defaultDynamicList, currentDynamicList = _v.currentDynamicList, onCurrentListChange = _v.onCurrentListChange, dynamicSettingRef = _v.dynamicSettingRef;
70
70
  // 根据动态列配置处理columns
71
71
  var dynamicColumns = useMemo(function () { return getTableColumns(columns, currentDynamicList); }, [columns, currentDynamicList]).columns;
72
72
  // 内部列宽状态(未开启动态配置时使用)
73
- var _v = useState({}), internalColumnWidths = _v[0], setInternalColumnWidths = _v[1];
73
+ var _w = useState({}), internalColumnWidths = _w[0], setInternalColumnWidths = _w[1];
74
74
  // 跟踪用户手动调整过宽度的列(用于排除自动宽度分配)
75
- var _w = useState(new Set()), manuallyResizedColumnKeys = _w[0], setManuallyResizedColumnKeys = _w[1];
75
+ var _x = useState(new Set()), manuallyResizedColumnKeys = _x[0], setManuallyResizedColumnKeys = _x[1];
76
76
  // 处理选中框列、序号列等
77
77
  var processedColumnsOld = useProcessedColumns({
78
78
  columns: columns,
@@ -87,47 +87,46 @@ function CanvasTable(props) {
87
87
  headerAlign: headerAlign,
88
88
  });
89
89
  // 表格状态管理
90
- var _x = useTableState({
90
+ var _y = useTableState({
91
91
  dataSource: dataSource,
92
92
  columns: processedColumnsOld,
93
93
  rowSelection: rowSelection,
94
94
  onFilterChange: onFilterChange,
95
95
  isAutoMerge: isAutoMerge,
96
- }), state = _x.state, setState = _x.setState, processedDataSource = _x.processedDataSource, handleFilterChange = _x.handleFilterChange, closeFilterPopover = _x.closeFilterPopover, autoGeneratedFilters = _x.autoGeneratedFilters;
96
+ }), state = _y.state, setState = _y.setState, processedDataSource = _y.processedDataSource, handleFilterChange = _y.handleFilterChange, closeFilterPopover = _y.closeFilterPopover, autoGeneratedFilters = _y.autoGeneratedFilters;
97
97
  var order = useMemo(function () {
98
98
  return state.sortOrder && state.sortField
99
99
  ? { field: state.sortField, order: state.sortOrder }
100
100
  : undefined;
101
101
  }, [state.sortOrder, state.sortField]);
102
- var _y = useAutoMerge(processedDataSource, processedColumnsOld, {
102
+ var _z = useAutoMerge(processedDataSource, processedColumnsOld, {
103
103
  isAutoMerge: isAutoMerge,
104
104
  isDimensionDynamic: isDimensionDynamic,
105
105
  order: order,
106
106
  dimensionCustomSumKeys: dimensionCustomSumKeys,
107
- }), newDataSource = _y[0], processedColumns = _y[1];
107
+ }), newDataSource = _z[0], processedColumns = _z[1];
108
108
  // 生成合计行和最终数据源
109
- var _z = useSummaryRow({
109
+ var _0 = useSummaryRow({
110
110
  columns: processedColumns,
111
111
  dataSource: newDataSource,
112
- }), finalDataSource = _z.finalDataSource, hasSummaryRow = _z.hasSummaryRow;
112
+ }), finalDataSource = _0.finalDataSource, hasSummaryRow = _0.hasSummaryRow;
113
113
  // 用于存储计算后的表头高度(用于自动高度的精确计算)
114
- var _0 = useState(undefined), preciseHeaderHeight = _0[0], setPreciseHeaderHeight = _0[1];
114
+ var _1 = useState(undefined), preciseHeaderHeight = _1[0], setPreciseHeaderHeight = _1[1];
115
115
  // 用于存储是否需要横向滚动条(用于自动高度的精确计算)
116
- var _1 = useState(false), needHorizontalScrollbar = _1[0], setNeedHorizontalScrollbar = _1[1];
116
+ var _2 = useState(false), needHorizontalScrollbar = _2[0], setNeedHorizontalScrollbar = _2[1];
117
117
  // 自动高度计算(需要在容器尺寸计算之前)
118
118
  var autoHeight = useCanvasTableAutoHeight(isAutoScrollY, autoScrollYMarginBottom, canvasTableId, finalDataSource.length, // 数据行数(用于 content 模式)
119
119
  headerHeight, // 表头基础高度(用于 content 模式的初始计算)
120
120
  rowHeight, // 行高(用于 content 模式)
121
121
  preciseHeaderHeight, // 计算后的表头高度(用于 content 模式的精确计算)
122
- needHorizontalScrollbar // 是否需要横向滚动条(用于计算额外高度)
123
- );
122
+ needHorizontalScrollbar, // 是否需要横向滚动条(用于计算额外高度)
123
+ maxHeight);
124
124
  // 监听容器尺寸变化(提前计算,用于列宽自适应)
125
125
  var containerSize = useContainerSize({
126
126
  containerRef: containerRef,
127
127
  width: width,
128
128
  height: isAutoScrollY ? autoHeight || height : height,
129
129
  });
130
- console.log("containerSize", containerSize);
131
130
  var containerWidth = containerSize.width;
132
131
  var containerHeight = containerSize.height;
133
132
  // 计算列的渲染信息(使用容器宽度进行自适应填充)
@@ -181,7 +180,7 @@ function CanvasTable(props) {
181
180
  return calculateTotalHeight(calculatedHeaderHeight, finalDataSource.length, rowHeight);
182
181
  }, [calculatedHeaderHeight, finalDataSource.length, rowHeight]);
183
182
  // 计算滚动条指标
184
- var _2 = useScrollbarMetrics({
183
+ var _3 = useScrollbarMetrics({
185
184
  containerWidth: containerWidth,
186
185
  containerHeight: containerHeight,
187
186
  totalWidth: totalWidth,
@@ -189,14 +188,14 @@ function CanvasTable(props) {
189
188
  headerHeight: calculatedHeaderHeight,
190
189
  scrollTop: 0,
191
190
  scrollLeft: 0,
192
- }), maxScrollTop = _2.maxScrollTop, maxScrollLeft = _2.maxScrollLeft;
191
+ }), maxScrollTop = _3.maxScrollTop, maxScrollLeft = _3.maxScrollLeft;
193
192
  // 滚动管理(使用预先计算的maxScrollTop和maxScrollLeft)
194
- var _3 = useTableScroll({
193
+ var _4 = useTableScroll({
195
194
  containerRef: containerRef,
196
195
  maxScrollTop: maxScrollTop,
197
196
  maxScrollLeft: maxScrollLeft,
198
197
  onScroll: onScroll,
199
- }), scrollState = _3.scrollState, setScrollState = _3.setScrollState;
198
+ }), scrollState = _4.scrollState, setScrollState = _4.setScrollState;
200
199
  // 使用 ref 保存最新的滚动位置,确保在组件卸载过程中仍能访问
201
200
  var scrollPositionRef = useRef({ x: 0, y: 0 });
202
201
  useEffect(function () {
@@ -236,12 +235,12 @@ function CanvasTable(props) {
236
235
  needHorizontalScrollbar,
237
236
  ]);
238
237
  // 单元格框选
239
- var _4 = useTableSelection({
238
+ var _5 = useTableSelection({
240
239
  state: state,
241
240
  setState: setState,
242
241
  }),
243
242
  // selectionStartRef,
244
- startSelection = _4.startSelection, updateSelection = _4.updateSelection, extendSelection = _4.extendSelection;
243
+ startSelection = _5.startSelection, updateSelection = _5.updateSelection, extendSelection = _5.extendSelection;
245
244
  // 处理列宽调整
246
245
  var handleColumnResize = useCallback(function (columnKey, newWidth) {
247
246
  var _a;
@@ -296,20 +295,20 @@ function CanvasTable(props) {
296
295
  onCurrentListChange,
297
296
  ]);
298
297
  // 列宽调整
299
- var _5 = useColumnResize({
298
+ var _6 = useColumnResize({
300
299
  columnRenderInfos: columnRenderInfos,
301
300
  containerWidth: containerWidth,
302
301
  headerHeight: calculatedHeaderHeight,
303
302
  scrollLeft: scrollState.scrollLeft,
304
303
  onColumnResize: handleColumnResize,
305
- }), resizeState = _5.resizeState, checkResizeHandle = _5.checkResizeHandle, startResize = _5.startResize, updateResize = _5.updateResize, endResize = _5.endResize, setHoverResizeColumn = _5.setHoverResizeColumn, getColumnWidth = _5.getColumnWidth, RESIZE_HANDLE_WIDTH = _5.RESIZE_HANDLE_WIDTH;
304
+ }), resizeState = _6.resizeState, checkResizeHandle = _6.checkResizeHandle, startResize = _6.startResize, updateResize = _6.updateResize, endResize = _6.endResize, setHoverResizeColumn = _6.setHoverResizeColumn, getColumnWidth = _6.getColumnWidth, RESIZE_HANDLE_WIDTH = _6.RESIZE_HANDLE_WIDTH;
306
305
  // 复制到剪贴板
307
- var _6 = useCopyToClipboard({
306
+ var _7 = useCopyToClipboard({
308
307
  cellSelection: state.cellSelection,
309
308
  processedDataSource: finalDataSource,
310
309
  columns: processedColumns,
311
310
  containerRef: containerRef,
312
- }), getSelectedCellsText = _6.getSelectedCellsText, copyToClipboard = _6.copyToClipboard;
311
+ }), getSelectedCellsText = _7.getSelectedCellsText, copyToClipboard = _7.copyToClipboard;
313
312
  // 处理右键菜单的复制操作
314
313
  var handleCopy = useCallback(function () {
315
314
  var text = getSelectedCellsText();
@@ -328,7 +327,7 @@ function CanvasTable(props) {
328
327
  summaryConfig: (exportExcelConfig === null || exportExcelConfig === void 0 ? void 0 : exportExcelConfig.isExportNoSummary) ? undefined : [],
329
328
  });
330
329
  // 交互事件处理(使用baseScrollbarMetrics的maxScrollTop/maxScrollLeft以保持稳定)
331
- var _7 = useTableInteraction({
330
+ var _8 = useTableInteraction({
332
331
  state: state,
333
332
  setState: setState,
334
333
  scrollState: scrollState,
@@ -375,7 +374,7 @@ function CanvasTable(props) {
375
374
  fixedRowsCount: fixedRowsCount,
376
375
  fixedRowsConfig: fixedRowsConfig,
377
376
  summaryFixed: summaryFixed,
378
- }), handleCanvasMouseDown = _7.handleCanvasMouseDown, handleCanvasMouseMove = _7.handleCanvasMouseMove, handleCanvasMouseUp = _7.handleCanvasMouseUp, handleCanvasMouseLeave = _7.handleCanvasMouseLeave, handleCanvasContextMenu = _7.handleCanvasContextMenu;
377
+ }), handleCanvasMouseDown = _8.handleCanvasMouseDown, handleCanvasMouseMove = _8.handleCanvasMouseMove, handleCanvasMouseUp = _8.handleCanvasMouseUp, handleCanvasMouseLeave = _8.handleCanvasMouseLeave, handleCanvasContextMenu = _8.handleCanvasContextMenu;
379
378
  // 渲染表格
380
379
  useTableRender(__assign(__assign({ canvasRef: canvasRef, processedDataSource: finalDataSource, columnRenderInfos: columnRenderInfos, columns: processedColumns, // 传递原始columns用于渲染多级表头
381
380
  state: state, scrollState: scrollState, rowSelection: rowSelection, containerWidth: containerWidth, containerHeight: containerHeight, headerHeight: calculatedHeaderHeight, baseHeaderHeight: headerHeight, // 传入原始基础高度用于计算每层高度
@@ -17,9 +17,10 @@ var SCROLLBAR_SIZE = 12;
17
17
  * @param needHorizontalScrollbar 是否需要横向滚动条(用于计算额外高度)
18
18
  * @returns 计算出的表格高度
19
19
  */
20
- function useCanvasTableAutoHeight(isAutoScrollY, marginBottom, canvasTableId, dataLength, headerHeight, rowHeight, calculatedHeaderHeight, needHorizontalScrollbar) {
20
+ function useCanvasTableAutoHeight(isAutoScrollY, marginBottom, canvasTableId, dataLength, headerHeight, rowHeight, calculatedHeaderHeight, needHorizontalScrollbar, maxHeight) {
21
21
  if (marginBottom === void 0) { marginBottom = 65; }
22
22
  if (needHorizontalScrollbar === void 0) { needHorizontalScrollbar = false; }
23
+ if (maxHeight === void 0) { maxHeight = 3000; }
23
24
  var _a = useState(undefined), tableHeight = _a[0], setTableHeight = _a[1];
24
25
  useEffect(function () {
25
26
  // 归一化模式:true 转换为 'viewport'
@@ -41,7 +42,7 @@ function useCanvasTableAutoHeight(isAutoScrollY, marginBottom, canvasTableId, da
41
42
  // 设置最小高度和最大高度
42
43
  var minHeight = 200;
43
44
  // 如果没有数据,使用最小高度(包含表头和空状态提示)
44
- var finalHeight = dataLength === 0 ? minHeight : Math.max(calculatedHeight, minHeight);
45
+ var finalHeight = dataLength === 0 ? minHeight : Math.min(calculatedHeight, maxHeight);
45
46
  setTableHeight(finalHeight);
46
47
  }
47
48
  return;
@@ -245,6 +245,10 @@ interface ICanvasTableProps<RecordType = any> {
245
245
  * 表格高度
246
246
  */
247
247
  height?: number;
248
+ /**
249
+ * 表格最大高度
250
+ */
251
+ maxHeight?: number;
248
252
  /**
249
253
  * 表格宽度
250
254
  */
@@ -124,7 +124,34 @@ var DynamicDrawer = function (props, ref) {
124
124
  onSure && onSure(tempDynamicList);
125
125
  };
126
126
  var onCheckboxChange = function (checkedValues) {
127
- // 1. 构建互斥关系映射
127
+ // 1. 找出本次变化的项(新增或移除的)
128
+ var prevCheckedKeys = new Set(checkedValues.filter(function (key) {
129
+ var item = tempDynamicList.find(function (d) { return d.key === key; });
130
+ return item && item.checked;
131
+ }));
132
+ var currentCheckedKeys = new Set(checkedValues);
133
+ // 找出新增的和移除的 key
134
+ var changedKey = null;
135
+ var isChecked = false;
136
+ for (var _i = 0, checkedValues_1 = checkedValues; _i < checkedValues_1.length; _i++) {
137
+ var key = checkedValues_1[_i];
138
+ if (!prevCheckedKeys.has(key)) {
139
+ changedKey = key;
140
+ isChecked = true;
141
+ break;
142
+ }
143
+ }
144
+ if (!changedKey) {
145
+ for (var _a = 0, tempDynamicList_1 = tempDynamicList; _a < tempDynamicList_1.length; _a++) {
146
+ var item = tempDynamicList_1[_a];
147
+ if (item.checked && !currentCheckedKeys.has(item.key)) {
148
+ changedKey = item.key;
149
+ isChecked = false;
150
+ break;
151
+ }
152
+ }
153
+ }
154
+ // 2. 构建互斥关系映射
128
155
  var exclusiveMap = {};
129
156
  tempDynamicList.forEach(function (item) {
130
157
  var key = item.key;
@@ -134,7 +161,7 @@ var DynamicDrawer = function (props, ref) {
134
161
  .filter(Boolean);
135
162
  exclusiveMap[key] = new Set(__spreadArray([key], exclusiveKeys, true));
136
163
  });
137
- // 2. 检查本次勾选是否有互斥
164
+ // 3. 检查本次勾选是否有互斥
138
165
  var hasConflict = false;
139
166
  for (var i = 0; i < checkedValues.length; i++) {
140
167
  for (var j = i + 1; j < checkedValues.length; j++) {
@@ -152,8 +179,22 @@ var DynamicDrawer = function (props, ref) {
152
179
  myMessage.warning("所选项存在互斥关系,不能同时勾选!");
153
180
  return; // 拦截本次勾选
154
181
  }
155
- // 3. 正常更新
156
- var newDynamicList = tempDynamicList.map(function (item) { return (__assign(__assign({}, item), { checked: checkedValues.includes(item.key) })); });
182
+ // 3. 正常更新,包括联动子元素
183
+ var newDynamicList = tempDynamicList.map(function (item) {
184
+ var isItemChecked = checkedValues.includes(item.key);
185
+ var newItem = __assign(__assign({}, item), { checked: isItemChecked });
186
+ // 如果当前变化的是这个主元素,并且它有子元素,联动子元素
187
+ if (item.key === changedKey &&
188
+ item.children &&
189
+ item.children.length > 0) {
190
+ newItem.children = item.children.map(function (child) { return (__assign(__assign({}, child), { checked: isChecked })); });
191
+ }
192
+ else if (item.children && item.children.length > 0) {
193
+ // 保持原有的子元素状态
194
+ newItem.children = item.children.map(function (child) { return (__assign({}, child)); });
195
+ }
196
+ return newItem;
197
+ });
157
198
  setTempDynamicList(newDynamicList);
158
199
  };
159
200
  var onChildCheckboxChange = function (checkedValues, pIndex) {
@@ -163,6 +204,7 @@ var DynamicDrawer = function (props, ref) {
163
204
  var changeCList = ((_b = (_a = newDynamicList[pIndex].children) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, function (item) { return (__assign({}, item)); })) ||
164
205
  [] ||
165
206
  [];
207
+ // 更新子元素的选中状态
166
208
  changeCList.forEach(function (item) {
167
209
  if (!checkedValues.find(function (value) { return value === item.key; })) {
168
210
  item.checked = false;
@@ -172,6 +214,17 @@ var DynamicDrawer = function (props, ref) {
172
214
  }
173
215
  });
174
216
  newDynamicList[pIndex].children = changeCList;
217
+ // 联动父元素
218
+ var allChildrenChecked = changeCList.length > 0 && changeCList.every(function (child) { return child.checked; });
219
+ changeCList.some(function (child) { return child.checked; });
220
+ if (allChildrenChecked) {
221
+ // 所有子元素都选中,父元素也选中
222
+ newDynamicList[pIndex].checked = true;
223
+ }
224
+ else {
225
+ // 部分选中或全不选中,父元素取消选中(配合 indeterminate 显示半选状态)
226
+ newDynamicList[pIndex].checked = false;
227
+ }
175
228
  setTempDynamicList(sortDynamicListByType(newDynamicList));
176
229
  };
177
230
  // 后期可能需要拓展功能
@@ -197,14 +250,19 @@ var DynamicDrawer = function (props, ref) {
197
250
  return (jsxs("div", { children: [title && jsx("div", __assign({ className: "dynamic-drawer-section-title" }, { children: title })), list.map(function (item, index) {
198
251
  var key = item.key, disabled = item.disabled, label = item.label, fixed = item.fixed, children = item.children, isDimensionSum = item.isDimensionSum, isDimension = item.isDimension;
199
252
  var childrenCheckedValues = [];
200
- if (Array.isArray(children)) {
253
+ var isIndeterminate = false; // 半选状态
254
+ if (Array.isArray(children) && children.length > 0) {
201
255
  children.forEach(function (item) {
202
256
  if (item.checked) {
203
257
  childrenCheckedValues.push(item.key);
204
258
  }
205
259
  });
260
+ // 计算半选状态:有子元素选中,但不是全部选中
261
+ var hasChecked = childrenCheckedValues.length > 0;
262
+ var allChecked = childrenCheckedValues.length === children.length;
263
+ isIndeterminate = hasChecked && !allChecked;
206
264
  }
207
- return (jsxs(Sortable, __assign({ type: "search-drawer", index: indexOffset + index, onMoveItem: onMoveItem }, { children: [jsxs("div", __assign({ className: "zt-sortable--item dynamic-drawer-card" }, { children: [jsx(Checkbox, __assign({ value: key, disabled: disabled }, { children: label || key })), isMore && (!children || children.length === 0) && (jsx(MoreConfig, { fixed: fixed || "", isDimensionSum: isDimensionSum, onChange: function (result) {
265
+ return (jsxs(Sortable, __assign({ type: "search-drawer", index: indexOffset + index, onMoveItem: onMoveItem }, { children: [jsxs("div", __assign({ className: "zt-sortable--item dynamic-drawer-card" }, { children: [jsx(Checkbox, __assign({ value: key, disabled: disabled, indeterminate: isIndeterminate }, { children: label || key })), isMore && (!children || children.length === 0) && (jsx(MoreConfig, { fixed: fixed || "", isDimensionSum: isDimensionSum, onChange: function (result) {
208
266
  onMoreChange(key, result);
209
267
  }, isSum: isDimension, isFixed: isFixed }))] })), Array.isArray(children) && children.length > 0 ? (jsx("div", __assign({ className: "zt-sortable--children dynamic-drawer-children", style: { marginLeft: 32, marginBottom: 8 } }, { children: jsx(Checkbox.Group, __assign({ value: childrenCheckedValues, onChange: function (checkedValues) {
210
268
  onChildCheckboxChange(checkedValues, tempDynamicList.indexOf(item));
@@ -1,6 +1,6 @@
1
1
  import { __spreadArray, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
2
2
  import ExcelJS from '../node_modules/exceljs/dist/exceljs.min.js';
3
- import { useMergeKeys, useNumKeys } from './hooks.js';
3
+ import { useMergeKeys, useNumKeys, useDateKeys } from './hooks.js';
4
4
  import { useMemoizedFn } from 'ahooks';
5
5
  import { IS_SUMMARY, MERGE_ROW_SPANS } from './constant.js';
6
6
  import { exactRound } from 'zmdms-utils';
@@ -10,7 +10,7 @@ import dayjs from 'dayjs';
10
10
  * 使用 ExcelJS + 后处理添加批注
11
11
  * 导出Excel,支持维度合并和小计,以及批注功能
12
12
  */
13
- function exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight) {
13
+ function exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys, dateKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight) {
14
14
  var _a;
15
15
  var _this = this;
16
16
  if (fileName === void 0) { fileName = "export.xlsx"; }
@@ -62,8 +62,8 @@ function exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys,
62
62
  var worksheet = createWorksheetWithMerge(workbook, __assign(__assign({}, excelData), { summaryRow: summaryRow }), mergeKeys, sheetName);
63
63
  // 设置冻结窗格
64
64
  setWorksheetFreeze(worksheet, excelData.leafColumns, excelData.headerRowCount);
65
- // 添加样式
66
- applyExcelStyles(worksheet, dataForStyles, numKeys, excelData.leafColumns, excelData.headerRowCount, !!excelData.topDescription, topDescriptionRowHeight);
65
+ // 添加样式和格式
66
+ applyExcelStyles(worksheet, dataForStyles, numKeys, dateKeys, excelData.leafColumns, excelData.headerRowCount, !!excelData.topDescription, topDescriptionRowHeight);
67
67
  // 添加批注 - 使用改进的方法
68
68
  addCommentsToWorksheet(worksheet, dataForStyles, excelData.leafColumns, excelData.headerRowCount);
69
69
  // 导出文件
@@ -376,7 +376,7 @@ function createWorksheetWithMerge(workbook, excelData, mergeKeys, sheetName) {
376
376
  }
377
377
  return worksheet;
378
378
  }
379
- function applyExcelStyles(worksheet, data, numKeys, columns, headerRowCount, hasTopDescription, topDescriptionRowHeight) {
379
+ function applyExcelStyles(worksheet, data, numKeys, dateKeys, columns, headerRowCount, hasTopDescription, topDescriptionRowHeight) {
380
380
  var _a, _b, _c;
381
381
  if (headerRowCount === void 0) { headerRowCount = 1; }
382
382
  if (hasTopDescription === void 0) { hasTopDescription = false; }
@@ -539,20 +539,47 @@ function applyExcelStyles(worksheet, data, numKeys, columns, headerRowCount, has
539
539
  }
540
540
  }
541
541
  }
542
+ // 日期列格式
543
+ if (dateKeys && dateKeys.length > 0 && columns) {
544
+ for (var rowIndex = 0; rowIndex < data.length; rowIndex++) {
545
+ var rowData = data[rowIndex];
546
+ var _loop_3 = function (dateKey) {
547
+ var colIndex = columns.findIndex(function (col) { return col.dataIndex === dateKey.dataIndex; });
548
+ if (colIndex === -1)
549
+ return "continue";
550
+ var cell = worksheet.getCell(headerRowCount + rowIndex + 1, colIndex + 1);
551
+ var cellValue = rowData[dateKey.dataIndex];
552
+ if (cellValue) {
553
+ try {
554
+ var date = dayjs(cellValue).toDate();
555
+ cell.value = date;
556
+ cell.numFmt = columns[colIndex].dateFormat;
557
+ }
558
+ catch (e) {
559
+ console.warn("日期格式转换失败:", e);
560
+ }
561
+ }
562
+ };
563
+ for (var _e = 0, dateKeys_1 = dateKeys; _e < dateKeys_1.length; _e++) {
564
+ var dateKey = dateKeys_1[_e];
565
+ _loop_3(dateKey);
566
+ }
567
+ }
568
+ }
542
569
  }
543
570
  /**
544
571
  * 主要的导出函数,使用改进的批注功能
545
572
  */
546
- function exportToExcelWithMerge(records, columns, mergeKeys, numKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight) {
573
+ function exportToExcelWithMerge(records, columns, mergeKeys, numKeys, dateKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight) {
547
574
  if (fileName === void 0) { fileName = "export.xlsx"; }
548
575
  if (sheetName === void 0) { sheetName = "Sheet1"; }
549
- return exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight);
576
+ return exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys, dateKeys, fileName, sheetName, columnHeaders, summaryConfig, topDescription, topDescriptionRowHeight);
550
577
  }
551
578
  /**
552
579
  * 简化版本的导出函数
553
580
  */
554
581
  function exportToExcelSimple(records, config) {
555
- return exportToExcelWithMerge(records, config.columns || [], config.mergeKeys, config.numKeys || [], config.fileName || "export.xlsx", config.sheetName || "Sheet1", config.columnHeaders, config.summaryConfig, config.topDescription, config.topDescriptionRowHeight);
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);
556
583
  }
557
584
  /**
558
585
  * Hook 版本,支持选择导出方式
@@ -561,6 +588,7 @@ function useExcelExport(records, config) {
561
588
  var columns = config.columns, isAutoMerge = config.isAutoMerge, columnHeaders = config.columnHeaders, summaryConfig = config.summaryConfig;
562
589
  var mergeKeys = useMergeKeys(columns, isAutoMerge);
563
590
  var numKeys = useNumKeys(columns);
591
+ var dateKeys = useDateKeys(columns);
564
592
  var exportFunction = useMemoizedFn(function (fileName, options) {
565
593
  var _a = options || {}, topDescription = _a.topDescription, topDescriptionRowHeight = _a.topDescriptionRowHeight, time = _a.time;
566
594
  if (!fileName.includes(".xlsx")) {
@@ -573,6 +601,7 @@ function useExcelExport(records, config) {
573
601
  columns: columns,
574
602
  mergeKeys: mergeKeys,
575
603
  numKeys: numKeys,
604
+ dateKeys: dateKeys,
576
605
  fileName: fileName,
577
606
  columnHeaders: columnHeaders,
578
607
  summaryConfig: summaryConfig,
@@ -400,6 +400,22 @@ var useNumKeys = function (columns) {
400
400
  }, [columns]);
401
401
  return numKeys;
402
402
  };
403
+ /**
404
+ * 获取带有 dateFormat 的列的 keys
405
+ */
406
+ var useDateKeys = function (columns) {
407
+ var dateKeys = useMemo(function () {
408
+ var leafColumns = getLeafColumns(columns);
409
+ return leafColumns
410
+ .filter(function (item) { return item.dateFormat !== undefined; })
411
+ .map(function (item) { return ({
412
+ key: item.key,
413
+ dataIndex: item.dataIndex,
414
+ dateFormat: item.dateFormat,
415
+ }); });
416
+ }, [columns]);
417
+ return dateKeys;
418
+ };
403
419
  /**
404
420
  * 自动合并的一些处理
405
421
  */
@@ -608,4 +624,4 @@ function useCustomFilter(dataSource) {
608
624
  return [newDataSource, handleFilterConfigChange];
609
625
  }
610
626
 
611
- export { useAddAndDelChange, useAutoMerge, useCalcScrollY, useCustomFilter, useCustomSort, useEditChange, useMergeAddAndDel, useMergeKeys, useMoveRowChange, useNumKeys, useScuRfresh };
627
+ export { useAddAndDelChange, useAutoMerge, useCalcScrollY, useCustomFilter, useCustomSort, useDateKeys, useEditChange, useMergeAddAndDel, useMergeKeys, useMoveRowChange, useNumKeys, useScuRfresh };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",