@cqsjjb/jjb-react-admin-component 3.3.9 → 3.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Table/index.js CHANGED
@@ -3,7 +3,7 @@ import React, { useRef, useEffect, useState, useCallback } from 'react';
3
3
  import { ProTable } from '@ant-design/pro-components';
4
4
  import './index.less';
5
5
  import { antPrefix } from './utils';
6
- export default function TablePro(props) {
6
+ function TablePro(props) {
7
7
  const prefix = antPrefix || 'ant';
8
8
  const baseCls = `.${prefix}-table`;
9
9
  const ref = useRef(null);
@@ -12,6 +12,9 @@ export default function TablePro(props) {
12
12
  const tableFooterCls = `${baseCls}-footer`;
13
13
  const {
14
14
  enableAutoScrollY = true,
15
+ rowKey,
16
+ columns,
17
+ scroll,
15
18
  options = {
16
19
  reload: false,
17
20
  density: true,
@@ -25,6 +28,23 @@ export default function TablePro(props) {
25
28
  ...restProps
26
29
  } = props;
27
30
  const [scrollY, setScrollY] = useState(undefined);
31
+
32
+ // 1. rowKey 兜底处理:如果没有 rowKey,使用数据索引下标
33
+ const finalRowKey = rowKey || ((record, index) => index);
34
+
35
+ // 3. scroll 处理:如果没有 scroll,设置 scroll={{ x: 1000 }},注意要合并 y 值
36
+ const finalScroll = React.useMemo(() => {
37
+ const baseScroll = scroll || {
38
+ x: 1000
39
+ };
40
+ if (enableAutoScrollY) {
41
+ return {
42
+ ...baseScroll,
43
+ y: scrollY || 0
44
+ };
45
+ }
46
+ return baseScroll;
47
+ }, [scroll, enableAutoScrollY, scrollY]);
28
48
  const timerRef = useRef(null);
29
49
  const calcTableScrollY = () => {
30
50
  const tableBody = ref.current?.querySelector?.(tableBodyCls);
@@ -34,7 +54,7 @@ export default function TablePro(props) {
34
54
  const tablePagination = ref.current?.querySelector?.(tablePaginationCls);
35
55
  const tablePaginationRect = tablePagination?.getBoundingClientRect();
36
56
  const tableFooterHeight = tableFooterRect?.height || 0;
37
- const tablePaginationMargin = 16;
57
+ const tablePaginationMargin = 16 * 2;
38
58
  const tablePaginationHeight = tablePaginationRect?.height || 0;
39
59
  const border = 2;
40
60
  const margin = 20;
@@ -54,46 +74,45 @@ export default function TablePro(props) {
54
74
  }, []);
55
75
  useEffect(() => {
56
76
  if (!ref.current || !enableAutoScrollY) return;
57
-
58
77
  // 创建 ResizeObserver 监听元素尺寸变化
59
- const resizeObserver = new ResizeObserver(() => {
78
+ const resizeObserver1 = new ResizeObserver(() => {
60
79
  // 等待 table-pagination 元素生成后再计算
61
80
  debouncedCalcScrollY();
62
81
  });
63
82
  const mutationObserver = new MutationObserver(() => {
64
83
  debouncedCalcScrollY();
65
84
  });
66
- mutationObserver.observe(ref.current, {
85
+ mutationObserver.observe(ref.current.parentElement, {
67
86
  childList: true,
68
87
  subtree: true,
69
88
  attributes: true
70
89
  });
71
90
 
72
91
  // 开始观察 ref.current 的尺寸变化
73
- resizeObserver.observe(ref.current);
92
+ resizeObserver1.observe(ref.current);
74
93
  return () => {
75
94
  if (timerRef.current) {
76
95
  clearTimeout(timerRef.current);
77
96
  }
78
- resizeObserver.disconnect();
97
+ resizeObserver1.disconnect();
79
98
  mutationObserver.disconnect();
80
99
  };
81
100
  }, [ref, enableAutoScrollY, debouncedCalcScrollY]);
82
101
  return /*#__PURE__*/React.createElement("div", {
83
- ref: ref,
84
- style: {
85
- height: '100%'
86
- }
102
+ ref: ref
87
103
  }, /*#__PURE__*/React.createElement(ProTable, _extends({
88
104
  ghost: true,
105
+ bordered: true,
106
+ defaultSize: "default",
89
107
  columnEmptyText: true,
90
108
  search: false,
91
- scroll: enableAutoScrollY ? {
92
- y: scrollY || 0
93
- } : undefined,
109
+ scroll: finalScroll,
110
+ rowKey: finalRowKey,
94
111
  className: `${antPrefix}-gbs-pro-table`,
95
112
  options: options
96
113
  }, restProps, {
97
- columns: restProps.columns
114
+ columns: columns
98
115
  })));
99
- }
116
+ }
117
+ TablePro.displayName = 'TablePro';
118
+ export default TablePro;
@@ -1,16 +1,17 @@
1
1
  import React from 'react';
2
- import { tools } from '@cqsjjb/jjb-common-lib';
3
2
  import { Dropdown, Space } from 'antd';
4
- export default function TableAction({
3
+ import { EllipsisOutlined } from '@ant-design/icons';
4
+ function TableAction({
5
5
  maximum = 3,
6
6
  children,
7
7
  space,
8
+ enabledIcon = true,
8
9
  placement = 'bottomRight',
9
10
  // 下拉菜单位置,默认 bottomRight
10
11
  trigger = ['hover'] // 下拉触发方式,默认 hover
11
12
  }) {
12
13
  // 将 children 统一成数组并过滤空值
13
- const childArray = (tools.isArray(children) ? children : [].concat(children)).filter(Boolean);
14
+ const childArray = (Array.isArray(children) ? children : [].concat(children)).filter(Boolean);
14
15
  const showArray = childArray.slice(0, maximum);
15
16
  const hideArray = childArray.slice(maximum);
16
17
  return /*#__PURE__*/React.createElement(Space, {
@@ -22,7 +23,9 @@ export default function TableAction({
22
23
  label: child
23
24
  }))
24
25
  },
25
- placement: placement,
26
- trigger: trigger
27
- }, /*#__PURE__*/React.createElement("a", null, "\u66F4\u591A")));
28
- }
26
+ trigger: trigger,
27
+ placement: placement
28
+ }, /*#__PURE__*/React.createElement("a", null, enabledIcon ? /*#__PURE__*/React.createElement(EllipsisOutlined, null) : /*#__PURE__*/React.createElement("span", null, "\u66F4\u591A"))));
29
+ }
30
+ TableAction.displayName = 'TableAction';
31
+ export default TableAction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/jjb-react-admin-component",
3
- "version": "3.3.9",
3
+ "version": "3.3.11",
4
4
  "description": "jjb-react-admin-组件库@new",
5
5
  "main": "index.js",
6
6
  "author": "jjb-front-team",
@@ -13,12 +13,10 @@
13
13
  "@ant-design/pro-layout": "latest",
14
14
  "@cqsjjb-formily/renderer": "latest",
15
15
  "@wangeditor-next/editor": "latest",
16
- "axios": "^1.6.5",
17
16
  "cropperjs": "^1.6.2",
18
17
  "lodash": "^4.17.21",
19
18
  "react-cropper": "2.3.3",
20
19
  "spark-md5": "^3.0.2",
21
- "styled-components": "^6.1.19",
22
- "use-antd-resizable-header": "latest"
20
+ "styled-components": "^6.1.19"
23
21
  }
24
22
  }
package/tools/index.js CHANGED
@@ -71,7 +71,7 @@ export function isHttpUrl(v) {
71
71
  * @return {string}
72
72
  */
73
73
  export function getPrefixCls() {
74
- return window.process?.env?.app?.antd['ant-prefix'] || 'ant';
74
+ return process?.env?.app?.antd['ant-prefix'] || 'ant';
75
75
  }
76
76
  export function getAlgorithm() {
77
77
  const value = document.documentElement.style.getPropertyValue(