zmdms-webui 2.4.2 → 2.4.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.
@@ -249,21 +249,19 @@ function CanvasTable(props) {
249
249
  onColumnResize: handleColumnResize,
250
250
  }), resizeState = _3.resizeState, checkResizeHandle = _3.checkResizeHandle, startResize = _3.startResize, updateResize = _3.updateResize, endResize = _3.endResize, setHoverResizeColumn = _3.setHoverResizeColumn, getColumnWidth = _3.getColumnWidth, RESIZE_HANDLE_WIDTH = _3.RESIZE_HANDLE_WIDTH;
251
251
  // 复制到剪贴板
252
- var getSelectedCellsText = useCopyToClipboard({
252
+ var _4 = useCopyToClipboard({
253
253
  cellSelection: state.cellSelection,
254
254
  processedDataSource: finalDataSource,
255
255
  columns: processedColumns,
256
256
  containerRef: containerRef,
257
- }).getSelectedCellsText;
257
+ }), getSelectedCellsText = _4.getSelectedCellsText, copyToClipboard = _4.copyToClipboard;
258
258
  // 处理右键菜单的复制操作
259
259
  var handleCopy = useCallback(function () {
260
260
  var text = getSelectedCellsText();
261
- if (text && navigator.clipboard) {
262
- navigator.clipboard.writeText(text).catch(function (err) {
263
- console.error("Failed to copy:", err);
264
- });
261
+ if (text) {
262
+ copyToClipboard(text);
265
263
  }
266
- }, [getSelectedCellsText]);
264
+ }, [getSelectedCellsText, copyToClipboard]);
267
265
  // 过滤勾选框和index行给导出用
268
266
  var exportColumns = useMemo(function () {
269
267
  return processedColumns.filter(function (item) { return !item.key.includes("__"); });
@@ -272,10 +270,10 @@ function CanvasTable(props) {
272
270
  var exportExcel = useExcelExport(newDataSource, {
273
271
  columns: exportColumns,
274
272
  isAutoMerge: isAutoMerge,
275
- summaryConfig: [],
273
+ summaryConfig: (exportExcelConfig === null || exportExcelConfig === void 0 ? void 0 : exportExcelConfig.isExportNoSummary) ? undefined : [],
276
274
  });
277
275
  // 交互事件处理(使用baseScrollbarMetrics的maxScrollTop/maxScrollLeft以保持稳定)
278
- var _4 = useTableInteraction({
276
+ var _5 = useTableInteraction({
279
277
  state: state,
280
278
  setState: setState,
281
279
  scrollState: scrollState,
@@ -322,7 +320,7 @@ function CanvasTable(props) {
322
320
  fixedRowsCount: fixedRowsCount,
323
321
  fixedRowsConfig: fixedRowsConfig,
324
322
  summaryFixed: summaryFixed,
325
- }), handleCanvasMouseDown = _4.handleCanvasMouseDown, handleCanvasMouseMove = _4.handleCanvasMouseMove, handleCanvasMouseUp = _4.handleCanvasMouseUp, handleCanvasMouseLeave = _4.handleCanvasMouseLeave, handleCanvasContextMenu = _4.handleCanvasContextMenu;
323
+ }), handleCanvasMouseDown = _5.handleCanvasMouseDown, handleCanvasMouseMove = _5.handleCanvasMouseMove, handleCanvasMouseUp = _5.handleCanvasMouseUp, handleCanvasMouseLeave = _5.handleCanvasMouseLeave, handleCanvasContextMenu = _5.handleCanvasContextMenu;
326
324
  // 渲染表格
327
325
  useTableRender(__assign(__assign({ canvasRef: canvasRef, processedDataSource: finalDataSource, columnRenderInfos: columnRenderInfos, columns: processedColumns, // 传递原始columns用于渲染多级表头
328
326
  state: state, scrollState: scrollState, rowSelection: rowSelection, containerWidth: containerWidth, containerHeight: containerHeight, headerHeight: calculatedHeaderHeight, baseHeaderHeight: headerHeight, // 传入原始基础高度用于计算每层高度
@@ -421,6 +419,13 @@ function CanvasTable(props) {
421
419
  scrollTo: function (params) {
422
420
  setScrollState(function (prev) { return (__assign(__assign({}, prev), { scrollLeft: params.x !== undefined ? params.x : prev.scrollLeft, scrollTop: params.y !== undefined ? params.y : prev.scrollTop })); });
423
421
  },
422
+ /** 获取滚动条位置信息 */
423
+ getScrollPosition: function () {
424
+ return {
425
+ x: scrollState.scrollLeft,
426
+ y: scrollState.scrollTop,
427
+ };
428
+ },
424
429
  /** 获取当前排序状态 */
425
430
  getSortState: function () {
426
431
  return {
@@ -450,6 +455,8 @@ function CanvasTable(props) {
450
455
  state.filters,
451
456
  setState,
452
457
  setScrollState,
458
+ scrollState.scrollLeft,
459
+ scrollState.scrollTop,
453
460
  ]);
454
461
  return (jsx(Spin, __assign({ spinning: loading }, { children: jsxs("div", __assign({ ref: containerRef, id: canvasTableId, className: "canvas-table-container ".concat(className || ""), tabIndex: 0, style: __assign(__assign({}, style), { position: "relative", width: width || "100%", height: containerHeight, overflow: "hidden", touchAction: "none", outline: "none" }) }, { children: [jsx("canvas", { ref: canvasRef, onMouseDown: handleCanvasMouseDown, onMouseMove: handleCanvasMouseMove, onMouseUp: handleCanvasMouseUp, onMouseLeave: handleCanvasMouseLeave, onContextMenu: handleCanvasContextMenu, style: {
455
462
  display: "block",
@@ -173,6 +173,10 @@ interface ICanvasColumnType<RecordType = any> {
173
173
  * 是否加上千分符
174
174
  */
175
175
  thousand?: boolean;
176
+ /**
177
+ * 空值时显示的文本,默认为 "—"
178
+ */
179
+ emptyText?: string;
176
180
  /**
177
181
  * 设置单元格属性(用于合并单元格等)
178
182
  * 参考 antd table 的 onCell 用法
@@ -414,6 +418,7 @@ interface ICanvasTableProps<RecordType = any> {
414
418
  time?: string;
415
419
  topDescriptionRowHeight?: number;
416
420
  fileName: string;
421
+ isExportNoSummary?: boolean;
417
422
  };
418
423
  }
419
424
  /**
@@ -463,6 +468,16 @@ interface ICanvasTableRefHandle {
463
468
  x?: number;
464
469
  y?: number;
465
470
  }) => void;
471
+ /**
472
+ * 获取滚动条位置信息
473
+ * @returns 包含 x(水平) 和 y(垂直) 滚动位置的对象
474
+ */
475
+ getScrollPosition: () => {
476
+ /** 水平滚动位置 */
477
+ x: number;
478
+ /** 垂直滚动位置 */
479
+ y: number;
480
+ };
466
481
  /**
467
482
  * 获取当前排序状态
468
483
  */
@@ -18,8 +18,10 @@ var formatDate = function (value, format) {
18
18
  * 格式化单元格值
19
19
  */
20
20
  var formatCellValue = function (value, column) {
21
- if (value === null || value === undefined)
22
- return "";
21
+ // 空值处理:nullundefined、空字符串
22
+ if (value === null || value === undefined || value === "") {
23
+ return column.emptyText !== undefined ? column.emptyText : "— —";
24
+ }
23
25
  var formattedValue = value;
24
26
  // 日期格式化
25
27
  if (column.dateFormat) {
@@ -245,6 +245,10 @@ interface IColumnType<RecordType> extends Omit<ColumnType<RecordType>, "render">
245
245
  dateFormat?: string;
246
246
  precision?: number;
247
247
  thousand?: boolean;
248
+ /**
249
+ * 空值时显示的文本,默认为 "—"
250
+ */
251
+ emptyText?: string;
248
252
  }
249
253
  interface IRenderOptions {
250
254
  insertTableFromClipboard: IFuncInsertTableFromClipboard;
@@ -289,13 +293,32 @@ interface ITableRefHandel {
289
293
  */
290
294
  clearErrorClass?: () => void;
291
295
  /**
292
- * 滚动
296
+ * 滚动到指定位置
297
+ * 虚拟滚动时:使用 virtuallist-antd 的 scrollTo 方法,需要传 row、y、vid
298
+ * 普通滚动时:操作 DOM,可以传 y、x 或 index
299
+ * @param options.row - 虚拟滚动时滚动到第几行
300
+ * @param options.y - 垂直滚动的像素值
301
+ * @param options.x - 水平滚动的像素值
302
+ * @param options.vid - 虚拟滚动的唯一标识符
303
+ * @param options.index - 滚动到指定行索引(普通滚动)
304
+ */
305
+ scrollTo?: (options: {
306
+ row?: number;
307
+ y?: number;
308
+ x?: number;
309
+ vid?: string;
310
+ index?: number;
311
+ }) => void;
312
+ /**
313
+ * 获取滚动条位置信息
314
+ * @returns 包含 x(水平) 和 y(垂直) 滚动位置的对象
293
315
  */
294
- scrollTo?: (obj: {
295
- row: number;
316
+ getScrollPosition?: () => {
317
+ /** 水平滚动位置 */
318
+ x: number;
319
+ /** 垂直滚动位置 */
296
320
  y: number;
297
- vid: string;
298
- }) => void;
321
+ };
299
322
  /**
300
323
  * 重置
301
324
  */
@@ -19,7 +19,7 @@ import useSummary from './useSummary.js';
19
19
  import useInnerPagination, { getInnerIndex } from './useInnerPagination.js';
20
20
  import { useScuRfresh, useCustomSort, useCalcScrollY, useEditChange, useMoveRowChange, useAddAndDelChange, useCustomFilter, useAutoMerge } from './hooks.js';
21
21
  import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
22
- import { VList, scrollTo } from '../node_modules/virtuallist-antd/dist/index.es.js';
22
+ import { scrollTo, VList } from '../node_modules/virtuallist-antd/dist/index.es.js';
23
23
  import useTableValidate, { tableValidate } from './useTableValidate.js';
24
24
  import TitleDirectionColumn from './components/TitleDirectionColumn.js';
25
25
  import { useExcelExport } from './excel.js';
@@ -193,6 +193,58 @@ var Table = function (props) {
193
193
  });
194
194
  // 表格验证
195
195
  var _y = useTableValidate(), tableRef = _y.tableRef, getCurrentTable = _y.getCurrentTable, clearErrorClass = _y.clearErrorClass;
196
+ // 滚动条控制方法
197
+ var scrollToPosition = useMemoizedFn(function (options) {
198
+ var _a;
199
+ // 如果是虚拟滚动,使用 virtuallist-antd 的 scrollTo 方法
200
+ if (virtualKey && options.vid) {
201
+ scrollTo({
202
+ row: options.row || 0,
203
+ y: options.y || 0,
204
+ vid: options.vid || virtualKey,
205
+ });
206
+ }
207
+ else {
208
+ // 普通滚动,操作 DOM
209
+ var tableBody = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".ant-table-body");
210
+ if (tableBody) {
211
+ // 如果指定了 y 值,直接滚动到指定位置
212
+ if (typeof options.y === "number") {
213
+ tableBody.scrollTop = options.y;
214
+ }
215
+ // 如果指定了 x 值,直接滚动到指定位置
216
+ if (typeof options.x === "number") {
217
+ tableBody.scrollLeft = options.x;
218
+ }
219
+ // 如果指定了 index,滚动到指定行
220
+ if (typeof options.index === "number") {
221
+ var rows = tableBody.querySelectorAll(".ant-table-row");
222
+ var targetRow = rows[options.index];
223
+ if (targetRow) {
224
+ targetRow.scrollIntoView({
225
+ behavior: "smooth",
226
+ block: "center",
227
+ });
228
+ }
229
+ }
230
+ }
231
+ }
232
+ });
233
+ // 获取滚动条位置
234
+ var getScrollPosition = useMemoizedFn(function () {
235
+ var _a;
236
+ var tableBody = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".ant-table-body");
237
+ if (tableBody) {
238
+ return {
239
+ x: tableBody.scrollLeft,
240
+ y: tableBody.scrollTop,
241
+ };
242
+ }
243
+ return {
244
+ x: 0,
245
+ y: 0,
246
+ };
247
+ });
196
248
  // 虚拟滚动选项
197
249
  var vComponents = useMemo(function () {
198
250
  if (virtualKey) {
@@ -307,9 +359,20 @@ var Table = function (props) {
307
359
  }); },
308
360
  /** 清除错误样式 */
309
361
  clearErrorClass: clearErrorClass,
310
- /** 虚拟滚动 滚动到顶部方法 */
311
- scrollTo: function (obj) {
312
- scrollTo(obj);
362
+ /**
363
+ * 滚动到指定位置
364
+ * 虚拟滚动时使用 virtuallist-antd 的 scrollTo 方法
365
+ * 普通滚动时操作 DOM
366
+ */
367
+ scrollTo: function (options) {
368
+ scrollToPosition(options);
369
+ },
370
+ /**
371
+ * 获取滚动条位置信息
372
+ * @returns 包含滚动位置和容器尺寸的对象
373
+ */
374
+ getScrollPosition: function () {
375
+ return getScrollPosition();
313
376
  },
314
377
  /** 动态列配置重置 */
315
378
  onResetDynamicList: function () {
@@ -324,8 +324,10 @@ function useColumns(columns, options) {
324
324
  if (typeof text === "object") {
325
325
  return PLACEHOLDER_NULL;
326
326
  }
327
- if (text == null || text === "")
328
- return PLACEHOLDER_NULL;
327
+ // 空值处理:null、undefined、空字符串
328
+ if (text == null || text === "") {
329
+ return _column.emptyText !== undefined ? _column.emptyText : "—";
330
+ }
329
331
  if (_column.dateFormat)
330
332
  return dayjs(text).format(_column.dateFormat);
331
333
  if (_column.precision)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",