@yeeyoon/library 2.7.8 → 2.8.2
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.
@@ -1,16 +1,33 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { useState, useEffect } from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import ProTable from '@ant-design/pro-table';
|
4
4
|
import { mergeTableColumnCommonConfig } from '../../../utils/utils';
|
5
5
|
|
6
|
+
let paginationData = {
|
7
|
+
current: 1,
|
8
|
+
pageSize: 10,
|
9
|
+
};
|
10
|
+
let sortData = {};
|
11
|
+
let filterData = {};
|
12
|
+
|
6
13
|
const CommonTable = (props) => {
|
7
14
|
const {
|
8
15
|
data,
|
9
16
|
dataTransform,
|
10
17
|
paginationKey = ['each_page', 'current_page'],
|
18
|
+
systemTags = [],
|
11
19
|
} = props;
|
20
|
+
const [paginationCurrent, setPaginationCurrent] = useState(1);
|
12
21
|
const { rowKey, columns, reqFunc, reqParams, reqCbFn, ...rest } = data;
|
13
|
-
|
22
|
+
useEffect(() => {
|
23
|
+
paginationData = {
|
24
|
+
current: 1,
|
25
|
+
pageSize: 10,
|
26
|
+
};
|
27
|
+
sortData = {};
|
28
|
+
filterData = {};
|
29
|
+
}, [columns]);
|
30
|
+
|
14
31
|
return (
|
15
32
|
<ProTable
|
16
33
|
rowKey={(record) => record[rowKey]}
|
@@ -18,6 +35,7 @@ const CommonTable = (props) => {
|
|
18
35
|
pagination={{
|
19
36
|
position: ['bottomCenter'],
|
20
37
|
pageSize: 10,
|
38
|
+
current: paginationCurrent,
|
21
39
|
}}
|
22
40
|
options={false}
|
23
41
|
scroll={{
|
@@ -27,12 +45,14 @@ const CommonTable = (props) => {
|
|
27
45
|
if (typeof reqFunc !== 'function') return;
|
28
46
|
const { current, pageSize, ...rest } = params;
|
29
47
|
const resp = await reqFunc({
|
30
|
-
[paginationKey[0]]: pageSize,
|
31
|
-
[paginationKey[1]]: current,
|
48
|
+
[paginationKey[0]]: paginationData.pageSize || pageSize,
|
49
|
+
[paginationKey[1]]: paginationData.current || current,
|
32
50
|
...rest,
|
33
51
|
...reqParams,
|
34
|
-
...
|
52
|
+
...sortData,
|
53
|
+
...filterData,
|
35
54
|
});
|
55
|
+
filterData = {};
|
36
56
|
const { total_data, data } = dataTransform ? dataTransform(resp) : resp;
|
37
57
|
if (reqCbFn) reqCbFn(params, { data, total: total_data });
|
38
58
|
return {
|
@@ -42,16 +62,38 @@ const CommonTable = (props) => {
|
|
42
62
|
};
|
43
63
|
}}
|
44
64
|
onChange={(pagination, filters, sorter) => {
|
65
|
+
// console.log(pagination, filters, sorter, 'xxxxxxxx');
|
66
|
+
if (pagination) {
|
67
|
+
const { current, pageSize } = pagination;
|
68
|
+
setPaginationCurrent(current);
|
69
|
+
paginationData = { current, pageSize };
|
70
|
+
}
|
71
|
+
if (filters) {
|
72
|
+
Object.keys(filters).forEach((key) => {
|
73
|
+
if (filters[key]) {
|
74
|
+
filterData[key] = filters[key];
|
75
|
+
}
|
76
|
+
});
|
77
|
+
filterData = {
|
78
|
+
filters: JSON.stringify({
|
79
|
+
system_tags: systemTags,
|
80
|
+
...filterData,
|
81
|
+
}),
|
82
|
+
};
|
83
|
+
rest.actionRef && rest.actionRef.current.reload();
|
84
|
+
}
|
45
85
|
if (sorter.field) {
|
46
86
|
const { field, order, column } = sorter;
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
87
|
+
if (!column) sortData = {};
|
88
|
+
else {
|
89
|
+
const { sortType } = column;
|
90
|
+
sortData = {
|
91
|
+
sort_direction: `${order === 'ascend' ? 'asc' : 'desc'}`,
|
92
|
+
sort_by: `${field}${sortType ? '.' + sortType : ''}`,
|
93
|
+
};
|
94
|
+
}
|
53
95
|
} else {
|
54
|
-
|
96
|
+
sortData = {};
|
55
97
|
}
|
56
98
|
}}
|
57
99
|
{...rest}
|
@@ -63,6 +105,7 @@ CommonTable.propTypes = {
|
|
63
105
|
data: PropTypes.object,
|
64
106
|
dataTransform: PropTypes.func,
|
65
107
|
paginationKey: PropTypes.array,
|
108
|
+
systemTags: PropTypes.array,
|
66
109
|
};
|
67
110
|
|
68
111
|
export default CommonTable;
|
@@ -57,6 +57,7 @@ const Header = (props) => {
|
|
57
57
|
productName = 'profile',
|
58
58
|
avatar,
|
59
59
|
userName,
|
60
|
+
slot = <></>,
|
60
61
|
} = props;
|
61
62
|
const [platforms, setPlatforms] = useState([]);
|
62
63
|
const [userInfo, setUserInfo] = useState(null);
|
@@ -234,6 +235,7 @@ const Header = (props) => {
|
|
234
235
|
</span>
|
235
236
|
)}
|
236
237
|
</span>
|
238
|
+
<div className={styles['comp-header__slot']}>{slot}</div>
|
237
239
|
</div>
|
238
240
|
<div className={styles['comp-header__right-content']}>
|
239
241
|
<span
|
@@ -325,6 +327,7 @@ Header.propTypes = {
|
|
325
327
|
productName: PropTypes.string,
|
326
328
|
avatar: PropTypes.string,
|
327
329
|
userName: PropTypes.string,
|
330
|
+
slot: PropTypes.node,
|
328
331
|
};
|
329
332
|
|
330
333
|
export default Header;
|
package/lib/config/env.js
CHANGED
package/package.json
CHANGED
package/src/pages/index.js
CHANGED
@@ -14,7 +14,7 @@ export default function () {
|
|
14
14
|
}, []);
|
15
15
|
return (
|
16
16
|
<>
|
17
|
-
<Header productName="profile" />
|
17
|
+
<Header productName="profile" slot={<div>nasa</div>} />
|
18
18
|
{/* <TenantSelector
|
19
19
|
tenantId="14bfb5d71d1011eca9820c42a1f6bf88"
|
20
20
|
tenantIdChangeCb={(id) => console.log(id)}
|