@cqsjjb/jjb-react-admin-component 3.0.30 → 3.1.1

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.mjs DELETED
@@ -1,118 +0,0 @@
1
- import React from 'react';
2
-
3
- import { ProTable } from '@ant-design/pro-components';
4
- import { useAntdResizableHeader } from 'use-antd-resizable-header';
5
-
6
- import { getElementAbsRect, antPrefix, className, setTableSize, getTableSize, getPersistenceKey } from './utils';
7
-
8
- import './index.less';
9
-
10
- require('use-antd-resizable-header/dist/style.css');
11
-
12
- export default function TablePro(props) {
13
- const { storeIndex } = props;
14
- const [ size, setSize ] = React.useState(getTableSize(storeIndex) || 'default');
15
- const [ tableHeight, setTableHeight ] = React.useState(0);
16
-
17
- const persistenceKey = getPersistenceKey(storeIndex);
18
-
19
- React.useEffect(() => {
20
- let observer;
21
- const table = document.querySelector(className('pro-table'));
22
-
23
- if (!props.disabledResizer) {
24
-
25
- observer = new ResizeObserver(() => {
26
- setTimeout(() => {
27
- const tBody = document.querySelector(className('table-body'));
28
- const tFooter = document.querySelector(className('table-footer'));
29
- const tPagination = document.querySelector(className('table-pagination'));
30
-
31
- const tBodyNativeRect = tBody.getBoundingClientRect();
32
- const tFooterAbsRect = getElementAbsRect(tFooter);
33
- const tPaginationAbsRect = getElementAbsRect(tPagination);
34
-
35
- const gap = 38;
36
-
37
- const height = window.innerHeight - (
38
- gap +
39
- tBodyNativeRect.y +
40
- tFooterAbsRect.absHeight +
41
- tPaginationAbsRect.absHeight
42
- );
43
- setTableHeight(height);
44
- }, 100);
45
- });
46
-
47
- observer.observe(table);
48
- }
49
-
50
- return () => {
51
- if (observer && !props.disabledResizer) {
52
- observer.unobserve(table);
53
- observer.disconnect();
54
- }
55
- };
56
- }, []);
57
- React.useEffect(() => {
58
- setTableSize(size, storeIndex);
59
- }, [ size ]);
60
-
61
- const {
62
- components,
63
- resizableColumns,
64
- tableWidth,
65
- resetColumns
66
- // refresh
67
- } = useAntdResizableHeader({
68
- columns: props.columns,
69
- columnsState: {
70
- persistenceKey: persistenceKey.resizable,
71
- persistenceType: 'localStorage'
72
- }
73
- });
74
-
75
- const scroll = {
76
- x: tableWidth
77
- };
78
-
79
- if (!props.disabledResizer) {
80
- scroll.y = tableHeight;
81
- }
82
-
83
- return (
84
- <>
85
- <ProTable
86
- {...props}
87
- ghost
88
- columnEmptyText
89
- size={size}
90
- search={false}
91
- scroll={scroll}
92
- columns={resizableColumns}
93
- className={`${antPrefix}-gbs-pro-table`}
94
- options={{
95
- reload: false,
96
- fullScreen: true,
97
- setting: {
98
- checkedReset: true,
99
- extra: (
100
- <a
101
- className={`${antPrefix}-pro-table-column-setting-action-rest-button`}
102
- onClick={resetColumns}
103
- >
104
- 重置列宽
105
- </a>
106
- )
107
- }
108
- }}
109
- components={components}
110
- columnsState={{
111
- persistenceKey: persistenceKey.columnState,
112
- persistenceType: 'localStorage'
113
- }}
114
- onSizeChange={setSize}
115
- />
116
- </>
117
- );
118
- }
@@ -1,36 +0,0 @@
1
- import React from 'react';
2
-
3
- import { tools } from '@cqsjjb/jjb-common-lib';
4
- import { MoreOutlined } from '@ant-design/icons';
5
- import { Dropdown, Space } from 'antd';
6
-
7
- export default function TableAction(props) {
8
- const maximum = props.maximum || 3;
9
- const children = (tools.isArray(props.children)
10
- ? props.children
11
- : [].concat(props.children)).filter(i => i);
12
- const showArray = children.slice(0, maximum);
13
- const hideArray = children.slice(maximum);
14
-
15
- return (
16
- <Space size={props.space}>
17
- {showArray}
18
- {hideArray.length !== 0 && (
19
- <Dropdown
20
- menu={{
21
- items: hideArray.map((record, index) => {
22
- return {
23
- key: index,
24
- label: record
25
- };
26
- })
27
- }}
28
- >
29
- <a>
30
- <MoreOutlined />
31
- </a>
32
- </Dropdown>
33
- )}
34
- </Space>
35
- );
36
- }