@cqsjjb/jjb-react-admin-component 3.0.12 → 3.0.14
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.d.ts +4 -0
- package/Table/index.js +7 -4
- package/Table/index.mjs +5 -4
- package/Table/utils.js +10 -8
- package/TableAction/index.d.ts +16 -0
- package/TableAction/index.js +22 -0
- package/TableAction/index.mjs +36 -0
- package/package.json +1 -1
package/Table/index.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ import type { TableProps } from 'antd';
|
|
|
6
6
|
interface OverTableProps extends TableProps {
|
|
7
7
|
// 是否禁用内容区滚动,默认true
|
|
8
8
|
disabledResizer?: boolean;
|
|
9
|
+
// 当一个路由下存在多个表格的情况下
|
|
10
|
+
// 需要给每一个表格设置一个唯一存储索引
|
|
11
|
+
// 若没有设置则使用默认索引,请注意缓存数据会被覆盖
|
|
12
|
+
storeIndex?: string;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
interface TableFc extends React.FC<OverTableProps> {
|
package/Table/index.js
CHANGED
|
@@ -6,9 +6,12 @@ import { getElementAbsRect, antPrefix, className, setTableSize, getTableSize, ge
|
|
|
6
6
|
import './index.less';
|
|
7
7
|
require('use-antd-resizable-header/dist/style.css');
|
|
8
8
|
export default function TablePro(props) {
|
|
9
|
-
const
|
|
9
|
+
const {
|
|
10
|
+
storeIndex
|
|
11
|
+
} = props;
|
|
12
|
+
const [size, setSize] = React.useState(getTableSize(storeIndex) || 'default');
|
|
10
13
|
const [tableHeight, setTableHeight] = React.useState(0);
|
|
11
|
-
const persistenceKey = getPersistenceKey();
|
|
14
|
+
const persistenceKey = getPersistenceKey(storeIndex);
|
|
12
15
|
React.useEffect(() => {
|
|
13
16
|
let observer;
|
|
14
17
|
const table = document.querySelector(className('pro-table'));
|
|
@@ -21,7 +24,7 @@ export default function TablePro(props) {
|
|
|
21
24
|
const tBodyNativeRect = tBody.getBoundingClientRect();
|
|
22
25
|
const tFooterAbsRect = getElementAbsRect(tFooter);
|
|
23
26
|
const tPaginationAbsRect = getElementAbsRect(tPagination);
|
|
24
|
-
const gap =
|
|
27
|
+
const gap = 38;
|
|
25
28
|
const height = window.innerHeight - (gap + tBodyNativeRect.y + tFooterAbsRect.absHeight + tPaginationAbsRect.absHeight);
|
|
26
29
|
setTableHeight(height);
|
|
27
30
|
}, 100);
|
|
@@ -36,7 +39,7 @@ export default function TablePro(props) {
|
|
|
36
39
|
};
|
|
37
40
|
}, []);
|
|
38
41
|
React.useEffect(() => {
|
|
39
|
-
setTableSize(size);
|
|
42
|
+
setTableSize(size, storeIndex);
|
|
40
43
|
}, [size]);
|
|
41
44
|
const {
|
|
42
45
|
components,
|
package/Table/index.mjs
CHANGED
|
@@ -10,10 +10,11 @@ import './index.less';
|
|
|
10
10
|
require('use-antd-resizable-header/dist/style.css');
|
|
11
11
|
|
|
12
12
|
export default function TablePro(props) {
|
|
13
|
-
const
|
|
13
|
+
const { storeIndex } = props;
|
|
14
|
+
const [ size, setSize ] = React.useState(getTableSize(storeIndex) || 'default');
|
|
14
15
|
const [ tableHeight, setTableHeight ] = React.useState(0);
|
|
15
16
|
|
|
16
|
-
const persistenceKey = getPersistenceKey();
|
|
17
|
+
const persistenceKey = getPersistenceKey(storeIndex);
|
|
17
18
|
|
|
18
19
|
React.useEffect(() => {
|
|
19
20
|
let observer;
|
|
@@ -31,7 +32,7 @@ export default function TablePro(props) {
|
|
|
31
32
|
const tFooterAbsRect = getElementAbsRect(tFooter);
|
|
32
33
|
const tPaginationAbsRect = getElementAbsRect(tPagination);
|
|
33
34
|
|
|
34
|
-
const gap =
|
|
35
|
+
const gap = 38;
|
|
35
36
|
|
|
36
37
|
const height = window.innerHeight - (
|
|
37
38
|
gap +
|
|
@@ -54,7 +55,7 @@ export default function TablePro(props) {
|
|
|
54
55
|
};
|
|
55
56
|
}, []);
|
|
56
57
|
React.useEffect(() => {
|
|
57
|
-
setTableSize(size);
|
|
58
|
+
setTableSize(size, storeIndex);
|
|
58
59
|
}, [ size ]);
|
|
59
60
|
|
|
60
61
|
const {
|
package/Table/utils.js
CHANGED
|
@@ -80,20 +80,22 @@ export function className(name) {
|
|
|
80
80
|
return `.${antPrefix}-${name}`;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
export function getPersistenceKey() {
|
|
83
|
+
export function getPersistenceKey(index) {
|
|
84
84
|
const basename = process.env?.app?.basename;
|
|
85
85
|
const pathname = decodeURIComponent(window.location.pathname);
|
|
86
|
+
const insertIndex = tools.isUndefined(index) ? '' : `#{${index}}`;
|
|
87
|
+
|
|
86
88
|
return {
|
|
87
|
-
size: `${basename}#${pathname}#size`,
|
|
88
|
-
resizable: `${basename}#${pathname}#resizable`,
|
|
89
|
-
columnState: `${basename}#${pathname}#columnState`
|
|
89
|
+
size: `${basename}#${pathname}${insertIndex}#size`,
|
|
90
|
+
resizable: `${basename}#${pathname}${insertIndex}#resizable`,
|
|
91
|
+
columnState: `${basename}#${pathname}${insertIndex}#columnState`
|
|
90
92
|
};
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
export function getTableSize() {
|
|
94
|
-
return window.localStorage.getItem(getPersistenceKey().size);
|
|
95
|
+
export function getTableSize(index) {
|
|
96
|
+
return window.localStorage.getItem(getPersistenceKey(index).size);
|
|
95
97
|
}
|
|
96
98
|
|
|
97
|
-
export function setTableSize(value) {
|
|
98
|
-
return window.localStorage.setItem(getPersistenceKey().size, value);
|
|
99
|
+
export function setTableSize(value, index) {
|
|
100
|
+
return window.localStorage.setItem(getPersistenceKey(index).size, value);
|
|
99
101
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ComponentProps } from '../types';
|
|
4
|
+
|
|
5
|
+
interface TableActionProps extends ComponentProps {
|
|
6
|
+
// 每行最多显示多少个操作项,默认3
|
|
7
|
+
maximum?: number;
|
|
8
|
+
// 每个操作项之间的间距,默认8
|
|
9
|
+
space?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface TableActionFc extends React.FC<TableActionProps> {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const TableAction: TableActionFc;
|
|
16
|
+
export default TableAction;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { tools } from '@cqsjjb/jjb-common-lib';
|
|
3
|
+
import { MoreOutlined } from '@ant-design/icons';
|
|
4
|
+
import { Dropdown, Space } from 'antd';
|
|
5
|
+
export default function TableAction(props) {
|
|
6
|
+
const maximum = props.maximum || 3;
|
|
7
|
+
const children = tools.isArray(props.children) ? props.children : [].concat(props.children);
|
|
8
|
+
const showArray = children.slice(0, maximum);
|
|
9
|
+
const hideArray = children.slice(maximum);
|
|
10
|
+
return /*#__PURE__*/React.createElement(Space, {
|
|
11
|
+
size: props.space
|
|
12
|
+
}, showArray, hideArray.length !== 0 && /*#__PURE__*/React.createElement(Dropdown, {
|
|
13
|
+
menu: {
|
|
14
|
+
items: hideArray.map((record, index) => {
|
|
15
|
+
return {
|
|
16
|
+
key: index,
|
|
17
|
+
label: record
|
|
18
|
+
};
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
}, /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(MoreOutlined, null))));
|
|
22
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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));
|
|
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
|
+
}
|