zmdms-webui 0.0.76 → 0.0.78

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.
Files changed (81) hide show
  1. package/dist/es/_virtual/Draggable.js +3 -0
  2. package/dist/es/_virtual/DraggableCore.js +3 -0
  3. package/dist/es/_virtual/Resizable.js +3 -0
  4. package/dist/es/_virtual/ResizableBox.js +3 -0
  5. package/dist/es/_virtual/_commonjsHelpers.js +29 -1
  6. package/dist/es/_virtual/cjs.js +3 -0
  7. package/dist/es/_virtual/clsx.m.js +6 -0
  8. package/dist/es/_virtual/domFns.js +3 -0
  9. package/dist/es/_virtual/getPrefix.js +3 -0
  10. package/dist/es/_virtual/index3.js +3 -0
  11. package/dist/es/_virtual/index4.js +3 -0
  12. package/dist/es/_virtual/index5.js +3 -0
  13. package/dist/es/_virtual/log.js +3 -0
  14. package/dist/es/_virtual/positionFns.js +3 -0
  15. package/dist/es/_virtual/propTypes.js +3 -0
  16. package/dist/es/_virtual/react-is.development.js +3 -0
  17. package/dist/es/_virtual/react-is.production.min.js +3 -0
  18. package/dist/es/_virtual/shims.js +3 -0
  19. package/dist/es/_virtual/utils.js +3 -0
  20. package/dist/es/button/button.js +14 -9
  21. package/dist/es/button/interface.d.ts +2 -0
  22. package/dist/es/dynamicsetting/dynamicDrawer.js +88 -5
  23. package/dist/es/dynamicsetting/dynamicSetting.js +7 -2
  24. package/dist/es/dynamicsetting/interface.d.ts +4 -0
  25. package/dist/es/dynamicsetting/moreConfig.js +36 -0
  26. package/dist/es/dynamicsetting/useDynamic.js +65 -25
  27. package/dist/es/form/form.d.ts +1 -1
  28. package/dist/es/form/form.js +18 -6
  29. package/dist/es/form/hooks.js +37 -5
  30. package/dist/es/form/interface.d.ts +7 -0
  31. package/dist/es/form/toggle.js +16 -0
  32. package/dist/es/node_modules/@ant-design/icons/es/icons/MenuOutlined.js +15 -0
  33. package/dist/es/node_modules/@ant-design/icons/es/utils.js +3 -1
  34. package/dist/es/node_modules/@ant-design/icons-svg/es/asn/MenuOutlined.js +5 -0
  35. package/dist/es/node_modules/@ant-design/icons-svg/es/asn/PlusOutlined.js +1 -1
  36. package/dist/es/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +19 -19
  37. package/dist/es/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +15 -15
  38. package/dist/es/node_modules/@babel/runtime/helpers/esm/typeof.js +6 -6
  39. package/dist/es/node_modules/antd-img-crop/dist/antd-img-crop.esm.js +7 -7
  40. package/dist/es/node_modules/clsx/dist/clsx.m.js +3 -0
  41. package/dist/es/node_modules/compare-versions/lib/esm/compareVersions.js +31 -0
  42. package/dist/es/node_modules/compare-versions/lib/esm/{index.js → utils.js} +1 -28
  43. package/dist/es/node_modules/object-assign/index.js +99 -0
  44. package/dist/es/node_modules/prop-types/checkPropTypes.js +115 -0
  45. package/dist/es/node_modules/prop-types/factoryWithThrowingShims.js +74 -0
  46. package/dist/es/node_modules/prop-types/factoryWithTypeCheckers.js +625 -0
  47. package/dist/es/node_modules/prop-types/index.js +28 -0
  48. package/dist/es/node_modules/prop-types/lib/ReactPropTypesSecret.js +21 -0
  49. package/dist/es/node_modules/prop-types/lib/has.js +11 -0
  50. package/dist/es/node_modules/react-draggable/build/cjs/Draggable.js +474 -0
  51. package/dist/es/node_modules/react-draggable/build/cjs/DraggableCore.js +580 -0
  52. package/dist/es/node_modules/react-draggable/build/cjs/cjs.js +18 -0
  53. package/dist/es/node_modules/react-draggable/build/cjs/utils/domFns.js +361 -0
  54. package/dist/es/node_modules/react-draggable/build/cjs/utils/getPrefix.js +85 -0
  55. package/dist/es/node_modules/react-draggable/build/cjs/utils/log.js +10 -0
  56. package/dist/es/node_modules/react-draggable/build/cjs/utils/positionFns.js +214 -0
  57. package/dist/es/node_modules/react-draggable/build/cjs/utils/shims.js +64 -0
  58. package/dist/es/node_modules/react-easy-crop/index.module.js +51 -18
  59. package/dist/es/node_modules/react-is/cjs/react-is.development.js +190 -0
  60. package/dist/es/node_modules/react-is/cjs/react-is.production.min.js +26 -0
  61. package/dist/es/node_modules/react-is/index.js +19 -0
  62. package/dist/es/node_modules/react-resizable/build/Resizable.js +262 -0
  63. package/dist/es/node_modules/react-resizable/build/ResizableBox.js +117 -0
  64. package/dist/es/node_modules/react-resizable/build/propTypes.js +120 -0
  65. package/dist/es/node_modules/react-resizable/build/utils.js +24 -0
  66. package/dist/es/node_modules/react-resizable/index.js +14 -0
  67. package/dist/es/node_modules/virtuallist-antd/dist/index.es.js +942 -0
  68. package/dist/es/table/components/EnhanceBodyRow.js +24 -0
  69. package/dist/es/table/components/EnhanceHeaderCell.js +41 -0
  70. package/dist/es/table/components/TitleOperation.js +1 -1
  71. package/dist/es/table/components/useDragRef.js +10 -11
  72. package/dist/es/table/interface.d.ts +14 -0
  73. package/dist/es/table/table.js +72 -25
  74. package/dist/es/table/useColumns.js +144 -66
  75. package/dist/es/table/useDynamicListByColumns.js +63 -20
  76. package/dist/es/table/utils.js +59 -21
  77. package/dist/index.dark.css +1 -1
  78. package/dist/index.default.css +1 -1
  79. package/package.json +5 -4
  80. package/dist/es/table/components/EnhanceRow.js +0 -21
  81. /package/dist/es/table/components/{EnhanceCell.js → EnhanceBodyCell.js} +0 -0
@@ -0,0 +1,24 @@
1
+ import { __rest, __assign } from '../../_virtual/_tslib.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useMemo } from 'react';
4
+ import classNames from '../../node_modules/classnames/index.js';
5
+ import useDragRef from './useDragRef.js';
6
+
7
+ var BasicBodyRow = function (props) {
8
+ var className = props.className, resetProps = __rest(props, ["className"]);
9
+ var classes = classNames("ztxk-table__enhance-row", className);
10
+ return jsx("tr", __assign({ className: classes }, resetProps));
11
+ };
12
+ // 拖拽行配置
13
+ var MoveBodyRow = function (props) {
14
+ var className = props.className, style = props.style, index = props.index, moveRow = props.moveRow, vRow = props.vRow, resetProps = __rest(props, ["className", "style", "index", "moveRow", "vRow"]);
15
+ var _a = useDragRef(index, moveRow), ref = _a.ref, isOver = _a.isOver, dropClassName = _a.dropClassName;
16
+ var memoStyle = useMemo(function () { return (__assign({ cursor: !moveRow ? "default" : "move" }, style)); }, [moveRow, style]);
17
+ var classes = classNames("ztxk-table__enhance-row", className, isOver ? dropClassName : "");
18
+ var tempProps = useMemo(function () {
19
+ return __assign({ ref: ref, className: classes, style: memoStyle }, resetProps);
20
+ }, [classes, resetProps, memoStyle, ref]);
21
+ return vRow ? (vRow(tempProps, ref)) : (jsx("tr", __assign({ ref: ref, style: __assign({ cursor: "move" }, style), className: classes }, resetProps)));
22
+ };
23
+
24
+ export { BasicBodyRow, MoveBodyRow };
@@ -0,0 +1,41 @@
1
+ import { __rest, __assign } from '../../_virtual/_tslib.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import React__default, { useState } from 'react';
4
+ import { Resizable } from '../../node_modules/react-resizable/index.js';
5
+ import classNames from '../../node_modules/classnames/index.js';
6
+
7
+ var EnhanceHeaderCell = function (props) {
8
+ var onResize = props.onResize, width = props.width; props.onMouseEnter; props.onMouseLeave; var restProps = __rest(props, ["onResize", "width", "onMouseEnter", "onMouseLeave"]);
9
+ // 添加偏移量
10
+ var _a = useState(0), offset = _a[0], setOffset = _a[1];
11
+ if (!width) {
12
+ return jsx("th", __assign({}, restProps));
13
+ }
14
+ return (jsx(Resizable, __assign({ width: Number(width) + Number(offset), height: 0, handle: jsx("span", {
15
+ // 有偏移量显示竖线
16
+ // className="react-resizable-handle"
17
+ className: classNames(["react-resizable-handle", offset && "active"]),
18
+ // 拖拽层偏移
19
+ style: { transform: "translateX(".concat(offset, "px)") }, onClick: function (e) {
20
+ e.stopPropagation();
21
+ e.preventDefault();
22
+ } }), onResize: function (e, _a) {
23
+ var size = _a.size;
24
+ // 这里只更新偏移量,数据列表其实并没有伸缩
25
+ setOffset(size.width - width);
26
+ }, onResizeStop: function (e, data) {
27
+ // 拖拽结束以后偏移量归零
28
+ setOffset(0);
29
+ // 这里是props传进来的事件,在外部是列数据中的onHeaderCell方法提供的事件,请自行研究官方提供的案例
30
+ onResize(e, data);
31
+ }, draggableOpts: { enableUserSelectHack: false } }, { children: jsx("th", __assign({}, restProps, { style: __assign({ overflow: "visible" }, restProps.style) }, { children: jsx("div", __assign({ style: {
32
+ width: "100%",
33
+ overflow: "hidden",
34
+ whiteSpace: "nowrap",
35
+ textOverflow: "ellipsis",
36
+ // 此处样式是在th中增加div块,为了解决拖拉时偏移虚线在右侧不出现问题
37
+ } }, { children: restProps.children })) })) })));
38
+ };
39
+ var EnhanceHeaderCell$1 = React__default.memo(EnhanceHeaderCell);
40
+
41
+ export { EnhanceHeaderCell$1 as default };
@@ -4,8 +4,8 @@ import { memo } from 'react';
4
4
  import CopyIcon from './CopyIcon.js';
5
5
  import FillDown from './FillDown.js';
6
6
  import ButtonCom from '../../button/button.js';
7
- import DownOutlined from '../../node_modules/@ant-design/icons/es/icons/DownOutlined.js';
8
7
  import { Dropdown } from 'antd';
8
+ import DownOutlined from '../../node_modules/@ant-design/icons/es/icons/DownOutlined.js';
9
9
 
10
10
  var TitleOperation = function (_a) {
11
11
  var copyKey = _a.copyKey, dataSourceRef = _a.dataSourceRef, isFillDown = _a.isFillDown, dataKey = _a.dataKey, onTableChange = _a.onTableChange;
@@ -14,10 +14,9 @@ function useDragRef(index, moveRow) {
14
14
  return {};
15
15
  }
16
16
  return {
17
- // 这里暂时不做拖放的样式 使用浏览器的默认样式
18
- // isOver: monitor.isOver(),
19
- // dropClassName:
20
- // dragIndex < index ? " drop-over-downward" : " drop-over-upward",
17
+ // 这里暂时不做拖放的样式 使用浏览器的默认样式
18
+ isOver: monitor.isOver(),
19
+ dropClassName: dragIndex < index ? " drop-over-downward" : " drop-over-upward",
21
20
  };
22
21
  },
23
22
  drop: function (item) {
@@ -26,9 +25,9 @@ function useDragRef(index, moveRow) {
26
25
  }
27
26
  moveRow(item.index, index);
28
27
  },
29
- }); }, [index]), drop = _a[1];
28
+ }); }, [index]), _b = _a[0], isOver = _b.isOver, dropClassName = _b.dropClassName, drop = _a[1];
30
29
  // 定义拖拽项
31
- var _b = useDrag({
30
+ var _c = useDrag({
32
31
  type: TABLE_DRAG_ROW_TYPE,
33
32
  item: { index: index },
34
33
  collect: function (monitor) { return ({
@@ -37,19 +36,19 @@ function useDragRef(index, moveRow) {
37
36
  canDrag: function (monitor) { var _a;
38
37
  // 解决拖拽行中有input 选中时 不让其拖拽
39
38
  return !((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.tagName.toLowerCase().match(/input|textarea/)); },
40
- }), drag = _b[1];
39
+ }), drag = _c[1];
41
40
  drop(drag(ref));
42
41
  if (moveRow) {
43
42
  return {
44
43
  ref: ref,
45
- // isOver,
46
- // dropClassName,
44
+ isOver: isOver,
45
+ dropClassName: dropClassName,
47
46
  };
48
47
  }
49
48
  return {
50
49
  ref: ref,
51
- // isOver: null,
52
- // dropClassName: null,
50
+ isOver: null,
51
+ dropClassName: null,
53
52
  };
54
53
  }
55
54
 
@@ -131,6 +131,11 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
131
131
  * 是否开启动态列配置
132
132
  */
133
133
  dynamicKey?: string;
134
+ /**
135
+ * 如果想要开启动态列配置,但是不想要页面出现操作按钮
136
+ * 一般场景用于记录宽度的变化
137
+ */
138
+ hiddenDynamicIcon?: boolean;
134
139
  /**
135
140
  * 代理动态列配置的类型
136
141
  */
@@ -158,6 +163,15 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
158
163
  * 是否开启表格拖拽排序功能
159
164
  */
160
165
  isMove?: boolean;
166
+ /**
167
+ * 是否开启表头伸缩功能
168
+ */
169
+ isResizableColumn?: boolean;
170
+ /**
171
+ * 是否开启虚拟滚动
172
+ * 传入一个虚拟滚动得key值进来即可
173
+ */
174
+ virtualKey?: string;
161
175
  /**
162
176
  * 是否显示增加行功能
163
177
  */
@@ -1,13 +1,14 @@
1
- import { __rest, __awaiter, __assign, __generator } from '../_virtual/_tslib.js';
1
+ import { __rest, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { memo, useRef, useEffect, useMemo, useCallback, useImperativeHandle } from 'react';
4
4
  import { Table as Table$1 } from 'antd';
5
- import { BasicRow, MoveRow } from './components/EnhanceRow.js';
6
- import EnhanceCell from './components/EnhanceCell.js';
5
+ import { BasicBodyRow, MoveBodyRow } from './components/EnhanceBodyRow.js';
6
+ import EnhanceCell from './components/EnhanceBodyCell.js';
7
+ import classNames from '../node_modules/classnames/index.js';
8
+ import EnhanceHeaderCell from './components/EnhanceHeaderCell.js';
7
9
  import './components/ColumnDynamic.js';
8
10
  import './components/ColumnAddDel.js';
9
11
  import './components/TitleOperation.js';
10
- import classNames from '../node_modules/classnames/index.js';
11
12
  import { TABLE_DYNAMIC_KEY, INNER_TABLE_PAGINATION_POSITION, INNER_TABLE_PAGINATION_PAGESIZEOPTIONS } from './constant.js';
12
13
  import { useColumns } from './useColumns.js';
13
14
  import { useDynamicListByColumns } from './useDynamicListByColumns.js';
@@ -15,6 +16,7 @@ import useSummary from './useSummary.js';
15
16
  import useInnerPagination, { getInnerIndex } from './useInnerPagination.js';
16
17
  import { useScuRfresh, useEditChange, useMoveRowChange, useAddAndDelChange, useCustomSort } from './hooks.js';
17
18
  import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
19
+ import { VList, scrollTo } from '../node_modules/virtuallist-antd/dist/index.es.js';
18
20
  import useTableValidate, { tableValidate } from './useTableValidate.js';
19
21
  import TitleDirectionColumn from './components/TitleDirectionColumn.js';
20
22
  import DynamicSetting from '../dynamicsetting/dynamicSetting.js';
@@ -30,7 +32,7 @@ import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js'
30
32
  // TODO: 实现表头自定义伸缩
31
33
  var Table = function (props) {
32
34
  // console.log("表格渲染");
33
- 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, columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, _c = props.isDelAll, isDelAll = _c === void 0 ? true : _c, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _d = props.summaryFixed, summaryFixed = _d === void 0 ? true : _d, isInnerPagination = props.isInnerPagination, _e = props.innerPaginationPageSize, innerPaginationPageSize = _e === void 0 ? 30 : _e, _f = props.innerPaginationPosition, innerPaginationPosition = _f === void 0 ? INNER_TABLE_PAGINATION_POSITION : _f, _g = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _g === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _g, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "addMode", "addCallback", "isDel", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "tableRefHandle", "tableName", "serviceOrder", "differences"]);
35
+ 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, hiddenDynamicIcon = props.hiddenDynamicIcon, columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, _c = props.isDelAll, isDelAll = _c === void 0 ? true : _c, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _d = props.summaryFixed, summaryFixed = _d === void 0 ? true : _d, isInnerPagination = props.isInnerPagination, _e = props.innerPaginationPageSize, innerPaginationPageSize = _e === void 0 ? 30 : _e, _f = props.innerPaginationPosition, innerPaginationPosition = _f === void 0 ? INNER_TABLE_PAGINATION_POSITION : _f, _g = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _g === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _g, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _h = props.isResizableColumn, isResizableColumn = _h === void 0 ? true : _h, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "hiddenDynamicIcon", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "addMode", "addCallback", "isDel", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "tableRefHandle", "tableName", "serviceOrder", "differences", "virtualKey", "isResizableColumn"]);
34
36
  var classes = classNames("ztxk-table", className, {
35
37
  "ztxk-table--flex": isFlex,
36
38
  });
@@ -40,14 +42,14 @@ var Table = function (props) {
40
42
  dataSourceRef.current = dataSource;
41
43
  }, [dataSource]);
42
44
  // 得到动态列配置信息
43
- var _h = useDynamicListByColumns(columns, dynamicKey), defaultDynamicList = _h.defaultDynamicList, onCurrentListChange = _h.onCurrentListChange, currentDynamicList = _h.currentDynamicList, dynamicSettingRef = _h.dynamicSettingRef;
45
+ var _j = useDynamicListByColumns(columns, dynamicKey), defaultDynamicList = _j.defaultDynamicList, onCurrentListChange = _j.onCurrentListChange, currentDynamicList = _j.currentDynamicList, dynamicSettingRef = _j.dynamicSettingRef;
44
46
  // 针对SCU和增减行 做特殊处理
45
- var _j = useScuRfresh(), refreshScuCell = _j.refreshScuCell, getRefreshScuCell = _j.getRefreshScuCell;
47
+ var _k = useScuRfresh(), refreshScuCell = _k.refreshScuCell, getRefreshScuCell = _k.getRefreshScuCell;
46
48
  // 内部分页相关配置
47
- var _k = useInnerPagination(isInnerPagination, innerPaginationPageSize, {
49
+ var _l = useInnerPagination(isInnerPagination, innerPaginationPageSize, {
48
50
  innerPaginationPosition: innerPaginationPosition,
49
51
  innerPaginationPageSizeOptions: innerPaginationPageSizeOptions,
50
- }), paginationConfig = _k.paginationConfig, currentPage = _k.currentPage, setCurrent = _k.setCurrent, pageSize = _k.pageSize;
52
+ }), paginationConfig = _l.paginationConfig, currentPage = _l.currentPage, setCurrent = _l.setCurrent, pageSize = _l.pageSize;
51
53
  // 内部表格编辑事件
52
54
  var onEditableSave = useEditChange(dataSourceRef, onTableChange);
53
55
  // 内部表格拖拽事件
@@ -66,23 +68,26 @@ var Table = function (props) {
66
68
  currentPage: currentPage,
67
69
  });
68
70
  // 自定义排序方法
69
- var _l = useCustomSort(dataSource, onTableChange, {
71
+ var _m = useCustomSort(dataSource, onTableChange, {
70
72
  refreshScuCell: refreshScuCell,
71
73
  currentPage: currentPage,
72
74
  rowKey: props === null || props === void 0 ? void 0 : props.rowKey,
73
75
  serviceOrder: serviceOrder,
74
- }), order = _l.order, setOrder = _l.setOrder, customSortHandle = _l.customSortHandle;
76
+ }), order = _m.order, setOrder = _m.setOrder, customSortHandle = _m.customSortHandle;
75
77
  // 处理列配置信息 得到新的列配置信息
76
78
  var newColumns = useColumns(columns, {
79
+ // 动态列配置相关信息
77
80
  dynamicKey: dynamicKey,
81
+ hiddenDynamicIcon: hiddenDynamicIcon,
78
82
  currentDynamicList: currentDynamicList,
83
+ dynamicSettingRef: dynamicSettingRef,
84
+ onCurrentListChange: onCurrentListChange,
79
85
  dataSource: dataSource,
80
86
  dataSourceRef: dataSourceRef,
81
87
  onEditableSave: onEditableSave,
82
88
  isEdit: isEdit,
83
89
  isAdd: isAdd,
84
90
  isDel: isDel,
85
- dynamicSettingRef: dynamicSettingRef,
86
91
  onAddAndDel: onAddAndDel,
87
92
  getRefreshScuCell: getRefreshScuCell,
88
93
  isDelAll: isDelAll,
@@ -92,6 +97,8 @@ var Table = function (props) {
92
97
  order: order,
93
98
  setOrder: setOrder,
94
99
  customSortHandle: customSortHandle,
100
+ // 伸缩列
101
+ isResizableColumn: isResizableColumn,
95
102
  }).newColumns;
96
103
  // 内部表格总结栏
97
104
  var getSummaryHandle = useSummary(summaryConfig, newColumns, {
@@ -102,30 +109,66 @@ var Table = function (props) {
102
109
  isDel: isDel,
103
110
  });
104
111
  // 表格验证
105
- var _m = useTableValidate(), tableRef = _m.tableRef, getCurrentTable = _m.getCurrentTable, clearErrorClass = _m.clearErrorClass;
112
+ var _o = useTableValidate(), tableRef = _o.tableRef, getCurrentTable = _o.getCurrentTable, clearErrorClass = _o.clearErrorClass;
113
+ // 虚拟滚动选项
114
+ var vComponents = useMemo(function () {
115
+ var _a;
116
+ if (virtualKey) {
117
+ // 使用VList 即可有虚拟列表的效果
118
+ return VList({
119
+ vid: virtualKey,
120
+ height: ((_a = props.scroll) === null || _a === void 0 ? void 0 : _a.y) ? props.scroll.y : 200,
121
+ resetTopWhenDataChange: false,
122
+ });
123
+ }
124
+ else {
125
+ return null;
126
+ }
127
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
+ }, [virtualKey]);
106
129
  // 使用高级表格需要的一些配置
107
130
  var componentsMemo = useMemo(function () {
131
+ var _a, _b;
108
132
  var components = undefined;
109
- // 如果编辑列
110
- if (isEdit) {
133
+ // 如果伸缩表头
134
+ if (isResizableColumn) {
111
135
  components = {
112
- body: {
113
- row: BasicRow,
114
- cell: EnhanceCell,
136
+ header: {
137
+ cell: EnhanceHeaderCell,
115
138
  },
116
139
  };
117
140
  }
141
+ // 如果编辑列
142
+ if (isEdit) {
143
+ components = __assign(__assign({}, components), { body: {
144
+ row: BasicBodyRow,
145
+ cell: EnhanceCell,
146
+ } });
147
+ }
118
148
  // 如果移动列
119
149
  if (isMove) {
120
- components = {
121
- body: {
122
- row: MoveRow,
150
+ components = __assign(__assign({}, components), { body: {
151
+ row: MoveBodyRow,
123
152
  cell: isEdit ? EnhanceCell : undefined,
124
- },
125
- };
153
+ } });
154
+ }
155
+ // 虚拟滚动
156
+ if (vComponents) {
157
+ // 需要支持编辑
158
+ if ((_a = components === null || components === void 0 ? void 0 : components.body) === null || _a === void 0 ? void 0 : _a.cell) {
159
+ vComponents.body.cell = components.body.cell;
160
+ }
161
+ // 需要支持拖拽
162
+ if (((_b = components === null || components === void 0 ? void 0 : components.body) === null || _b === void 0 ? void 0 : _b.row) && isMove) {
163
+ var row_1 = vComponents.body.row;
164
+ vComponents.body.row = function (props) {
165
+ return jsx(MoveBodyRow, __assign({}, props, { vRow: row_1 }));
166
+ };
167
+ }
168
+ components = __assign(__assign({}, components), vComponents);
126
169
  }
127
170
  return components;
128
- }, [isEdit, isMove]);
171
+ }, [isEdit, isMove, isResizableColumn, vComponents]);
129
172
  // 展示差异的行类方法
130
173
  var rowClassName = useCallback(function (record, index) {
131
174
  if (Array.isArray(differences) && differences.includes(index)) {
@@ -170,6 +213,10 @@ var Table = function (props) {
170
213
  }); },
171
214
  /** 清除错误样式 */
172
215
  clearErrorClass: clearErrorClass,
216
+ /** 虚拟滚动 滚动到顶部方法 */
217
+ scrollTo: function (obj) {
218
+ scrollTo(obj);
219
+ },
173
220
  };
174
221
  });
175
222
  // 表格
@@ -180,7 +227,7 @@ var Table = function (props) {
180
227
  : pagination, rowClassName: rowClassName }, resetProps)));
181
228
  return (jsxs("div", __assign({ style: isFlex
182
229
  ? { position: "relative", overflow: "hidden", flex: 1 }
183
- : { position: "relative", overflow: "hidden" }, ref: tableRef }, { children: [isMove ? (jsx(DndProvider, __assign({ backend: HTML5Backend, context: window }, { children: SingleTable }))) : (SingleTable), dynamicKey ? (jsx(DynamicSetting, { parentDynamicKey: TABLE_DYNAMIC_KEY, dynamicKey: dynamicKey, defaultList: defaultDynamicList, onCurrentListChange: onCurrentListChange, ref: dynamicSettingRef, hiddenOperationIcon: true })) : null] })));
230
+ : { position: "relative", overflow: "hidden" }, ref: tableRef }, { children: [isMove ? (jsx(DndProvider, __assign({ backend: HTML5Backend, context: window }, { children: SingleTable }))) : (SingleTable), dynamicKey ? (jsx(DynamicSetting, { parentDynamicKey: TABLE_DYNAMIC_KEY, dynamicKey: dynamicKey, defaultList: defaultDynamicList, onCurrentListChange: onCurrentListChange, ref: dynamicSettingRef, hiddenOperationIcon: true, isMore: true, isFixed: true })) : null] })));
184
231
  };
185
232
  var MemoTable = memo(Table);
186
233
  MemoTable.displayName = "ZTXK_WEBUI_Table";
@@ -1,8 +1,9 @@
1
- import { __assign } from '../_virtual/_tslib.js';
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
1
+ import { __assign, __spreadArray } from '../_virtual/_tslib.js';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import { getTableColumns } from './utils.js';
4
- import '../node_modules/classnames/index.js';
5
4
  import 'react';
5
+ import '../node_modules/classnames/index.js';
6
+ import './components/EnhanceHeaderCell.js';
6
7
  import ColumnDynamic from './components/ColumnDynamic.js';
7
8
  import ColumnAddDel, { ColumnDelAll } from './components/ColumnAddDel.js';
8
9
  import TitleOperation from './components/TitleOperation.js';
@@ -13,73 +14,150 @@ import { PLACEHOLDER_NULL } from '../config/constant.js';
13
14
  // 根据传入的一些信息 重新生成新的columns配置
14
15
  // 不适用column里面的dataIndex字段,使用key字段
15
16
  function useColumns(columns, options) {
16
- var dynamicKey = options.dynamicKey, currentDynamicList = options.currentDynamicList, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isDel = options.isDel, dynamicSettingRef = options.dynamicSettingRef, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle;
17
+ var dynamicKey = options.dynamicKey, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isDel = options.isDel, 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;
17
18
  var newColumns = getTableColumns(columns, currentDynamicList);
18
19
  // 循环遍历 neColumns 根据一些内容进行处理
19
20
  var myNewColumns = [];
20
- if (Array.isArray(newColumns)) {
21
- newColumns.forEach(function (column) {
22
- var _a, _b;
23
- var _column = __assign(__assign({}, column), { __title: column.title });
24
- 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;
25
- var _key = key ? key : _column === null || _column === void 0 ? void 0 : _column.dataIndex;
26
- // 添加自定义排序
27
- if (isOrder) {
28
- _column.title = (jsx(SortTitle, { title: title, field: _key, onChange: customSortHandle, customOrder: order, setCustomOrder: setOrder, align: _column.align, isStress: isStress }));
29
- }
30
- // 列头增加复制按钮
31
- // 列头增加往下填充
32
- if (isFillDown || isCopy) {
33
- _column.title = (jsxs("div", __assign({ style: {
34
- display: "flex",
35
- alignItems: "center",
36
- justifyContent: "space-between",
37
- flex: "1",
38
- } }, { children: [jsx("div", __assign({ style: { flexGrow: 1, textAlign: _column.align }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
39
- ? (_a = _column.title) === null || _a === void 0 ? void 0 : _a.call(_column, {})
40
- : _column.title })), jsx(TitleOperation, { copyKey: isCopy === true ? _key : isCopy, dataSourceRef: dataSourceRef, isFillDown: isFillDown, dataKey: _key, onTableChange: onTableChange })] })));
41
- }
42
- // 列头增加必填标识
43
- if (isRequire || isStress) {
44
- _column.title = (jsxs("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: [isRequire ? jsx("i", __assign({ className: "ztxk-column--required" }, { children: "*" })) : null, jsx("div", __assign({ style: { flexGrow: 1 }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
45
- ? (_b = _column.title) === null || _b === void 0 ? void 0 : _b.call(_column, {})
46
- : _column.title }))] })));
47
- }
48
- // 如果列添加可编辑配置
49
- if (editable && isEdit) {
50
- _column.onCell = function (record, index) {
51
- return ({
52
- record: record,
53
- index: index,
54
- editable: editable,
55
- editableConfig: editableConfig,
56
- dataIndex: _key,
57
- title: title,
58
- onEditableSave: onEditableSave,
59
- currentPage: currentPage,
60
- isValidate: validate ? true : false,
61
- });
62
- };
63
- }
64
- // 处理配置了scu的相关逻辑
65
- if (_column.shouldCellUpdate) {
66
- var fn_1 = _column.shouldCellUpdate;
67
- _column.shouldCellUpdate = function (record, preRecord) {
68
- if (getRefreshScuCell && getRefreshScuCell()) {
69
- return true;
21
+ var enhanceColumnHandle = function (_column, options) {
22
+ var _a, _b;
23
+ 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;
24
+ var _key = key ? key : _column === null || _column === void 0 ? void 0 : _column.dataIndex;
25
+ var _c = (options || {}).keyIndex, keyIndex = _c === void 0 ? [] : _c;
26
+ // 添加自定义排序
27
+ if (isOrder) {
28
+ _column.title = (jsx(SortTitle, { title: title, field: _key, onChange: customSortHandle, customOrder: order, setCustomOrder: setOrder, align: _column.align, isStress: isStress }));
29
+ }
30
+ // 列头增加复制按钮
31
+ // 列头增加往下填充
32
+ if (isFillDown || isCopy) {
33
+ _column.title = (jsxs("div", __assign({ style: {
34
+ display: "flex",
35
+ alignItems: "center",
36
+ justifyContent: "space-between",
37
+ flex: "1",
38
+ } }, { children: [jsx("div", __assign({ style: { flexGrow: 1, textAlign: _column.align }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
39
+ ? (_a = _column.title) === null || _a === void 0 ? void 0 : _a.call(_column, {})
40
+ : _column.title })), jsx(TitleOperation, { copyKey: isCopy === true ? _key : isCopy, dataSourceRef: dataSourceRef, isFillDown: isFillDown, dataKey: _key, onTableChange: onTableChange })] })));
41
+ }
42
+ // 列头增加必填标识
43
+ if (isRequire || isStress) {
44
+ _column.title = (jsxs("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: [isRequire ? jsx("i", __assign({ className: "ztxk-column--required" }, { children: "*" })) : null, jsx("div", __assign({ style: { flexGrow: 1 }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
45
+ ? (_b = _column.title) === null || _b === void 0 ? void 0 : _b.call(_column, {})
46
+ : _column.title }))] })));
47
+ }
48
+ // 如果列添加可编辑配置
49
+ if (editable && isEdit) {
50
+ _column.onCell = function (record, index) {
51
+ return ({
52
+ record: record,
53
+ index: index,
54
+ editable: editable,
55
+ editableConfig: editableConfig,
56
+ dataIndex: _key,
57
+ title: title,
58
+ onEditableSave: onEditableSave,
59
+ currentPage: currentPage,
60
+ isValidate: validate ? true : false,
61
+ });
62
+ };
63
+ }
64
+ // 处理配置了scu的相关逻辑
65
+ if (_column.shouldCellUpdate) {
66
+ var fn_1 = _column.shouldCellUpdate;
67
+ _column.shouldCellUpdate = function (record, preRecord) {
68
+ if (getRefreshScuCell && getRefreshScuCell()) {
69
+ return true;
70
+ }
71
+ return fn_1(record, preRecord);
72
+ };
73
+ }
74
+ // 添加render字段,
75
+ if (!_column.render && !_column.editable) {
76
+ _column.render = function (text, record, index) {
77
+ if (typeof text === "object") {
78
+ return PLACEHOLDER_NULL;
79
+ }
80
+ return text == null || text === "" ? PLACEHOLDER_NULL : text;
81
+ };
82
+ }
83
+ // 如果配置了伸缩列
84
+ if (isResizableColumn) {
85
+ _column.onHeaderCell = function (column) { return ({
86
+ width: column.width,
87
+ onResize: (function (e, _a) {
88
+ var _b, _c;
89
+ var size = _a.size;
90
+ // 更新columns配置 这里应该不需要用loadsh来深拷贝数据
91
+ var newList = (_b = currentDynamicList === null || currentDynamicList === void 0 ? void 0 : currentDynamicList.map) === null || _b === void 0 ? void 0 : _b.call(currentDynamicList, function (item) { return (__assign({}, item)); });
92
+ var result = null;
93
+ // 递归查找
94
+ if (Array.isArray(newList)) {
95
+ var _loop_1 = function (i) {
96
+ var item = newList[i];
97
+ // 如果这是顶层
98
+ if (keyIndex.length === 0) {
99
+ if (item.key === _key) {
100
+ result = item;
101
+ return "break";
102
+ }
103
+ }
104
+ else {
105
+ // 需要递归按层级查找到目标
106
+ // 找到最顶层
107
+ if (item.key === keyIndex[0]) {
108
+ var pList_1 = item.children || [];
109
+ keyIndex.slice(1).forEach(function (k) {
110
+ var _a;
111
+ pList_1 =
112
+ ((_a = pList_1 === null || pList_1 === void 0 ? void 0 : pList_1.find(function (pItem) { return pItem.key === k; })) === null || _a === void 0 ? void 0 : _a.children) || [];
113
+ });
114
+ // 找到最终目标
115
+ var lastResult = pList_1.find(function (pItem) { return pItem.key === _key; });
116
+ if (lastResult) {
117
+ result = lastResult;
118
+ }
119
+ return "break";
120
+ }
121
+ }
122
+ };
123
+ for (var i = 0; i < (newList === null || newList === void 0 ? void 0 : newList.length); i++) {
124
+ var state_1 = _loop_1(i);
125
+ if (state_1 === "break")
126
+ break;
127
+ }
128
+ }
129
+ if (result) {
130
+ result.width = size.width;
131
+ }
132
+ if (dynamicKey) {
133
+ (_c = dynamicSettingRef === null || dynamicSettingRef === void 0 ? void 0 : dynamicSettingRef.current) === null || _c === void 0 ? void 0 : _c.updateList(newList);
70
134
  }
71
- return fn_1(record, preRecord);
72
- };
73
- }
74
- // 添加render字段,
75
- if (!_column.render && !_column.editable) {
76
- _column.render = function (text, record, index) {
77
- if (typeof text === "object") {
78
- return PLACEHOLDER_NULL;
135
+ else {
136
+ onCurrentListChange === null || onCurrentListChange === void 0 ? void 0 : onCurrentListChange(newList);
79
137
  }
80
- return text == null || text === "" ? PLACEHOLDER_NULL : text;
81
- };
82
- }
138
+ }),
139
+ }); };
140
+ }
141
+ // 如果有子元素 递归执行逻辑
142
+ // 支持多级表头控制
143
+ if (Array.isArray(_column === null || _column === void 0 ? void 0 : _column.children) &&
144
+ (_column === null || _column === void 0 ? void 0 : _column.children.length) > 0) {
145
+ var childrenColumns_1 = [];
146
+ _column.children.forEach(function (column, index) {
147
+ var _column = __assign(__assign({}, column), { __title: column.title });
148
+ var newKeyIndex = __spreadArray(__spreadArray([], keyIndex, true), [_key], false);
149
+ enhanceColumnHandle(_column, { keyIndex: newKeyIndex });
150
+ childrenColumns_1.push(_column);
151
+ });
152
+ _column.children = childrenColumns_1;
153
+ }
154
+ };
155
+ if (Array.isArray(newColumns)) {
156
+ newColumns.forEach(function (column, index) {
157
+ // __title 为 记录当前用户传入的列title
158
+ // 因为后续title可能会因为一些功能,添加一些标签等信息
159
+ var _column = __assign(__assign({}, column), { __title: column.title });
160
+ enhanceColumnHandle(_column);
83
161
  myNewColumns.push(_column);
84
162
  });
85
163
  // 如果配置了增减行
@@ -98,7 +176,7 @@ function useColumns(columns, options) {
98
176
  }
99
177
  // 如果配置了动态列配置
100
178
  // 处理一些配置放置的位置
101
- if (dynamicKey) {
179
+ if (dynamicKey && !hiddenDynamicIcon) {
102
180
  myNewColumns[0].title = function () {
103
181
  return isAdd || isDel ? (jsxs(Fragment, { children: [isDelAll ? jsx(ColumnDelAll, {}) : null, jsx(ColumnDynamic, { dynamicSettingRef: dynamicSettingRef })] })) : (jsx(ColumnDynamic, { dynamicSettingRef: dynamicSettingRef }));
104
182
  };