zmdms-webui 1.7.1 → 1.7.3

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.
@@ -30,7 +30,7 @@ function useEditChange(dataSourceRef, onTableChange) {
30
30
  * @returns 排序相关方法
31
31
  */
32
32
  function useMoveRowChange(dataSourceRef, onTableChange, options) {
33
- var isMove = options.isMove, refreshScuCell = options.refreshScuCell, currentPage = options.currentPage;
33
+ var isMove = options.isMove, refreshScuCell = options.refreshScuCell, currentPage = options.currentPage, extraOnRow = options.extraOnRow, fixedRowsCount = options.fixedRowsCount, fixedRowsConfig = options.fixedRowsConfig;
34
34
  var moveRow = useCallback(function (dI, hI) {
35
35
  var _a;
36
36
  // 内部分页时,获取数据真正的行数
@@ -56,13 +56,30 @@ function useMoveRowChange(dataSourceRef, onTableChange, options) {
56
56
  });
57
57
  }, [dataSourceRef, onTableChange, refreshScuCell, currentPage]);
58
58
  var onRow = useCallback(function (_, index) {
59
- return {
59
+ var baseProps = {
60
60
  index: index,
61
61
  moveRow: moveRow,
62
62
  };
63
- }, [moveRow]);
63
+ // 确定固定行数量和行高
64
+ var fixedCount = (fixedRowsConfig === null || fixedRowsConfig === void 0 ? void 0 : fixedRowsConfig.count) || fixedRowsCount;
65
+ var rowHeight = (fixedRowsConfig === null || fixedRowsConfig === void 0 ? void 0 : fixedRowsConfig.rowHeight) || 36; // 默认行高36px
66
+ var customStyle = fixedRowsConfig === null || fixedRowsConfig === void 0 ? void 0 : fixedRowsConfig.style;
67
+ // 在这里处理固定行样式
68
+ if (fixedCount && index !== undefined && index < fixedCount) {
69
+ var defaultStyle = {
70
+ position: "sticky",
71
+ top: rowHeight * index,
72
+ background: "#fff",
73
+ borderBottom: "1px solid #f0f0f0",
74
+ zIndex: 10,
75
+ };
76
+ return __assign(__assign({}, baseProps), { style: customStyle
77
+ ? __assign(__assign({}, defaultStyle), customStyle) : defaultStyle });
78
+ }
79
+ return baseProps;
80
+ }, [moveRow, fixedRowsCount, fixedRowsConfig]);
64
81
  return {
65
- onRow: isMove ? onRow : undefined,
82
+ onRow: isMove || fixedRowsCount || fixedRowsConfig ? onRow : extraOnRow,
66
83
  };
67
84
  }
68
85
  /**
@@ -416,6 +416,32 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
416
416
  * 表格id
417
417
  */
418
418
  tableId?: string;
419
+ /**
420
+ * 固定前几行,后面的行使用虚拟滚动
421
+ * 当开启虚拟滚动时,可以设置固定前几行不参与虚拟滚动
422
+ */
423
+ fixedRowsCount?: number;
424
+ /**
425
+ * 固定行配置
426
+ */
427
+ fixedRowsConfig?: {
428
+ /**
429
+ * 固定行数量
430
+ */
431
+ count: number;
432
+ /**
433
+ * 行高,用于计算固定行的top位置
434
+ */
435
+ rowHeight?: number;
436
+ /**
437
+ * 固定行的样式
438
+ */
439
+ style?: React.CSSProperties;
440
+ };
441
+ /**
442
+ * 表头对齐方式
443
+ */
444
+ headerAlign?: "left" | "center" | "right";
419
445
  }
420
446
  interface IFields {
421
447
  /**
@@ -38,7 +38,7 @@ import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js'
38
38
  // completed: 实现从execl复制到表格中的功能
39
39
  var Table = function (props) {
40
40
  // console.log("表格渲染");
41
- var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, isRemeberFilter = props.isRemeberFilter, _c = props.isOrderUpdateData, isOrderUpdateData = _c === void 0 ? true : _c, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle, _d = props.isTheadTitleAdd, isTheadTitleAdd = _d === void 0 ? true : _d, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, delPopTitle = props.delPopTitle, hiddenDelBtnHandle = props.hiddenDelBtnHandle, _e = props.isDelAll, isDelAll = _e === void 0 ? true : _e, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _f = props.summaryFixed, summaryFixed = _f === void 0 ? true : _f, isInnerPagination = props.isInnerPagination, _g = props.innerPaginationPageSize, innerPaginationPageSize = _g === void 0 ? 30 : _g, _h = props.innerPaginationPosition, innerPaginationPosition = _h === void 0 ? INNER_TABLE_PAGINATION_POSITION : _h, _j = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _j === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _j, innerPaginationConfig = props.innerPaginationConfig, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _k = props.isResizableColumn, isResizableColumn = _k === void 0 ? true : _k, _l = props.isResizableTitleEllipsis, isResizableTitleEllipsis = _l === void 0 ? true : _l, _m = props.isRealTimeValidate, isRealTimeValidate = _m === void 0 ? true : _m, isMarginTop = props.isMarginTop, isMarginBottom = props.isMarginBottom, scroll = props.scroll, addAndDelProps = props.addAndDelProps, _o = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _o === void 0 ? 65 : _o, _p = props.isAutoScrollY, isAutoScrollY = _p === void 0 ? false : _p, tableId = props.tableId, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "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"]);
41
+ var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, isRemeberFilter = props.isRemeberFilter, _c = props.isOrderUpdateData, isOrderUpdateData = _c === void 0 ? true : _c, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle, _d = props.isTheadTitleAdd, isTheadTitleAdd = _d === void 0 ? true : _d, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, delPopTitle = props.delPopTitle, hiddenDelBtnHandle = props.hiddenDelBtnHandle, _e = props.isDelAll, isDelAll = _e === void 0 ? true : _e, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _f = props.summaryFixed, summaryFixed = _f === void 0 ? true : _f, isInnerPagination = props.isInnerPagination, _g = props.innerPaginationPageSize, innerPaginationPageSize = _g === void 0 ? 30 : _g, _h = props.innerPaginationPosition, innerPaginationPosition = _h === void 0 ? INNER_TABLE_PAGINATION_POSITION : _h, _j = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _j === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _j, innerPaginationConfig = props.innerPaginationConfig, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _k = props.isResizableColumn, isResizableColumn = _k === void 0 ? true : _k, _l = props.isResizableTitleEllipsis, isResizableTitleEllipsis = _l === void 0 ? true : _l, _m = props.isRealTimeValidate, isRealTimeValidate = _m === void 0 ? true : _m, isMarginTop = props.isMarginTop, isMarginBottom = props.isMarginBottom, scroll = props.scroll, addAndDelProps = props.addAndDelProps, _o = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _o === void 0 ? 65 : _o, _p = props.isAutoScrollY, isAutoScrollY = _p === void 0 ? false : _p, tableId = props.tableId, extraOnRow = props.onRow, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, headerAlign = props.headerAlign, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "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"]);
42
42
  var classes = classNames("ztxk-table", className, {
43
43
  "ztxk-table--flex": isFlex,
44
44
  });
@@ -99,6 +99,10 @@ var Table = function (props) {
99
99
  refreshScuCell: refreshScuCell,
100
100
  currentPage: currentPage,
101
101
  filterConfigRef: filterConfigRef,
102
+ extraOnRow: extraOnRow,
103
+ fixedRowsCount: fixedRowsCount,
104
+ fixedRowsConfig: fixedRowsConfig,
105
+ virtualKey: virtualKey,
102
106
  }).onRow;
103
107
  // 内部表格新增删除事件
104
108
  var onAddAndDel = useAddAndDelChange(dataSourceRef, onTableChange, {
@@ -148,6 +152,7 @@ var Table = function (props) {
148
152
  rowKey: props.rowKey,
149
153
  filterConfigRef: filterConfigRef,
150
154
  addAndDelProps: addAndDelProps,
155
+ headerAlign: headerAlign,
151
156
  }).newColumns;
152
157
  // 内部表格总结栏
153
158
  var getSummaryHandle = useSummary(summaryConfig, newColumns, {
@@ -208,9 +213,9 @@ var Table = function (props) {
208
213
  }
209
214
  // 需要支持拖拽
210
215
  if (((_b = components === null || components === void 0 ? void 0 : components.body) === null || _b === void 0 ? void 0 : _b.row) && isMove) {
211
- var row_1 = vComponents.body.row;
216
+ var originalRow_1 = vComponents.body.row;
212
217
  vComponents.body.row = function (props) {
213
- return jsx(MoveBodyRow, __assign({}, props, { vRow: row_1 }));
218
+ return jsx(MoveBodyRow, __assign({}, props, { vRow: originalRow_1 }));
214
219
  };
215
220
  }
216
221
  components = __assign(__assign({}, components), vComponents);
@@ -21,7 +21,7 @@ import ModalComponent from '../modal/modal.js';
21
21
  function useColumns(columns, options) {
22
22
  var _this = this;
23
23
  var _a, _b;
24
- var dynamicKey = options.dynamicKey, isRemeberFilter = options.isRemeberFilter, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSource = options.dataSource, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isTheadTitleAdd = options.isTheadTitleAdd, isDel = options.isDel, delPopTitle = options.delPopTitle, dynamicSettingRef = options.dynamicSettingRef, onCurrentListChange = options.onCurrentListChange, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle, isResizableColumn = options.isResizableColumn, isResizableTitleEllipsis = options.isResizableTitleEllipsis, isRealTimeValidate = options.isRealTimeValidate, hiddenDelBtnHandleRef = options.hiddenDelBtnHandleRef, hiddenAddBtnHandleRef = options.hiddenAddBtnHandleRef, rowKey = options.rowKey, filterConfigRef = options.filterConfigRef, addAndDelProps = options.addAndDelProps;
24
+ var dynamicKey = options.dynamicKey, isRemeberFilter = options.isRemeberFilter, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSource = options.dataSource, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isTheadTitleAdd = options.isTheadTitleAdd, isDel = options.isDel, delPopTitle = options.delPopTitle, dynamicSettingRef = options.dynamicSettingRef, onCurrentListChange = options.onCurrentListChange, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle, isResizableColumn = options.isResizableColumn, isResizableTitleEllipsis = options.isResizableTitleEllipsis, isRealTimeValidate = options.isRealTimeValidate, hiddenDelBtnHandleRef = options.hiddenDelBtnHandleRef, hiddenAddBtnHandleRef = options.hiddenAddBtnHandleRef, rowKey = options.rowKey, filterConfigRef = options.filterConfigRef, addAndDelProps = options.addAndDelProps, headerAlign = options.headerAlign;
25
25
  var newColumns = getTableColumns(columns, currentDynamicList).columns;
26
26
  // 表头过滤的一些配置(获取表头过滤的input的输入框的引用)
27
27
  var searchValueInputRef = useRef(null);
@@ -35,7 +35,8 @@ function useColumns(columns, options) {
35
35
  var isCopy = _column.isCopy, editable = _column.editable, editableConfig = _column.editableConfig, title = _column.title, key = _column.key, validate = _column.validate, isRequire = _column.isRequire, isFillDown = _column.isFillDown, isOrder = _column.isOrder, isStress = _column.isStress, popoverText = _column.popoverText, showType = _column.showType, isFilter = _column.isFilter, __dynamicItem__ = _column.__dynamicItem__;
36
36
  // 表格列,唯一key
37
37
  var _key = key ? key : _column === null || _column === void 0 ? void 0 : _column.dataIndex;
38
- var _g = (options || {}).keyIndex, keyIndex = _g === void 0 ? [] : _g;
38
+ var _g = options || {}, _h = _g.keyIndex, keyIndex = _h === void 0 ? [] : _h, headerAlign = _g.headerAlign;
39
+ var align = headerAlign || _column.align;
39
40
  var isRequireNode = isRequire ? (jsx("i", __assign({ className: "ztxk-column--required" }, { children: "*" }))) : null;
40
41
  if (showType) {
41
42
  _column.className = _column.className
@@ -51,7 +52,7 @@ function useColumns(columns, options) {
51
52
  // 添加自定义排序
52
53
  // 用户传入了排序属性,那么说明该列需要排序
53
54
  if (_column.sorter === true) {
54
- _column.title = (jsx(SortTitle, { title: _column.title, field: _key, onChange: customSortHandle, customOrder: order, setCustomOrder: setOrder, align: _column.align, isStress: isStress }));
55
+ _column.title = (jsx(SortTitle, { title: _column.title, field: _key, onChange: customSortHandle, customOrder: order, setCustomOrder: setOrder, align: align, isStress: isStress }));
55
56
  _column.sorter = false;
56
57
  }
57
58
  // 如果传入了一个自定义排序函数
@@ -59,12 +60,12 @@ function useColumns(columns, options) {
59
60
  var sorterHandle_1 = _column.sorter;
60
61
  _column.title = (jsx(SortTitle, { title: _column.title, field: _key, onChange: function (info) {
61
62
  customSortHandle && customSortHandle(info, { sorterHandle: sorterHandle_1 });
62
- }, customOrder: order, setCustomOrder: setOrder, align: _column.align, isStress: isStress }));
63
+ }, customOrder: order, setCustomOrder: setOrder, align: align, isStress: isStress }));
63
64
  _column.sorter = false;
64
65
  }
65
66
  // 纯粹的前端排序
66
67
  if (_column.sorter == null && isOrder) {
67
- _column.title = (jsx(SortTitle, { title: _column.title, field: _key, onChange: customSortHandle, customOrder: order, setCustomOrder: setOrder, align: _column.align, isStress: isStress }));
68
+ _column.title = (jsx(SortTitle, { title: _column.title, field: _key, onChange: customSortHandle, customOrder: order, setCustomOrder: setOrder, align: align, isStress: isStress }));
68
69
  }
69
70
  // 列头增加复制按钮
70
71
  // 列头增加往下填充
@@ -74,7 +75,7 @@ function useColumns(columns, options) {
74
75
  alignItems: "center",
75
76
  justifyContent: "space-between",
76
77
  flex: "1",
77
- } }, { children: [jsx("div", __assign({ style: { flexGrow: 1, textAlign: _column.align }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
78
+ } }, { children: [jsx("div", __assign({ style: { flexGrow: 1, textAlign: align }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
78
79
  ? (_c = _column.title) === null || _c === void 0 ? void 0 : _c.call(_column, {})
79
80
  : _column.title })), jsx(TitleOperation, { copyKey: isCopy === true ? _key : isCopy, dataSourceRef: dataSourceRef, isFillDown: isFillDown, dataKey: _key, onTableChange: onTableChange, filterConfigRef: filterConfigRef })] })));
80
81
  }
@@ -154,9 +155,7 @@ function useColumns(columns, options) {
154
155
  _column.title = (jsxs("div", __assign({ style: {
155
156
  display: "flex",
156
157
  alignItems: "center",
157
- justifyContent: _column.align
158
- ? justifyContent[_column.align]
159
- : undefined,
158
+ justifyContent: align ? justifyContent[align] : undefined,
160
159
  } }, { children: [isRequireNode, jsx("div", __assign({ className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
161
160
  ? (_f = _column.title) === null || _f === void 0 ? void 0 : _f.call(_column, {})
162
161
  : _column.title }))] })));
@@ -330,6 +329,9 @@ function useColumns(columns, options) {
330
329
  onCurrentListChange === null || onCurrentListChange === void 0 ? void 0 : onCurrentListChange(newList);
331
330
  }
332
331
  }),
332
+ style: {
333
+ textAlign: align,
334
+ },
333
335
  }); };
334
336
  }
335
337
  // 如果有子元素 递归执行逻辑
@@ -340,7 +342,11 @@ function useColumns(columns, options) {
340
342
  _column.children.forEach(function (column, index) {
341
343
  var _column = __assign(__assign({}, column), { __title: column.title });
342
344
  var newKeyIndex = __spreadArray(__spreadArray([], keyIndex, true), [_key], false);
343
- enhanceColumnHandle(_column, { keyIndex: newKeyIndex, isEdit: isEdit });
345
+ enhanceColumnHandle(_column, {
346
+ keyIndex: newKeyIndex,
347
+ isEdit: isEdit,
348
+ headerAlign: headerAlign,
349
+ });
344
350
  childrenColumns_1.push(_column);
345
351
  });
346
352
  _column.children = childrenColumns_1;
@@ -351,7 +357,7 @@ function useColumns(columns, options) {
351
357
  // __title 为 记录当前用户传入的列title
352
358
  // 因为后续title可能会因为一些功能,添加一些标签等信息
353
359
  var _column = __assign(__assign({}, column), { __title: column.title });
354
- enhanceColumnHandle(_column, { isEdit: isEdit });
360
+ enhanceColumnHandle(_column, { isEdit: isEdit, headerAlign: headerAlign });
355
361
  myNewColumns.push(_column);
356
362
  });
357
363
  var showTitleDelIcon_1 = isDelAll &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",