@yeeyoon/library 2.8.2 → 2.8.6
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.
@@ -0,0 +1,111 @@
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import ProTable from '@ant-design/pro-table';
|
4
|
+
import { mergeTableColumnCommonConfig } from '../../../utils/utils';
|
5
|
+
|
6
|
+
let paginationData = {
|
7
|
+
current: 1,
|
8
|
+
pageSize: 10,
|
9
|
+
};
|
10
|
+
let sortData = {};
|
11
|
+
let filterData = {};
|
12
|
+
|
13
|
+
const CommonTable = (props) => {
|
14
|
+
const {
|
15
|
+
data,
|
16
|
+
dataTransform,
|
17
|
+
paginationKey = ['each_page', 'current_page'],
|
18
|
+
systemTags = [],
|
19
|
+
} = props;
|
20
|
+
const [paginationCurrent, setPaginationCurrent] = useState(1);
|
21
|
+
const { rowKey, columns, reqFunc, reqParams, reqCbFn, ...rest } = data;
|
22
|
+
useEffect(() => {
|
23
|
+
paginationData = {
|
24
|
+
current: 1,
|
25
|
+
pageSize: 10,
|
26
|
+
};
|
27
|
+
sortData = {};
|
28
|
+
filterData = {};
|
29
|
+
}, [columns]);
|
30
|
+
|
31
|
+
return (
|
32
|
+
<ProTable
|
33
|
+
rowKey={(record) => record[rowKey]}
|
34
|
+
columns={mergeTableColumnCommonConfig(columns)}
|
35
|
+
pagination={{
|
36
|
+
position: ['bottomCenter'],
|
37
|
+
pageSize: 10,
|
38
|
+
current: paginationCurrent,
|
39
|
+
}}
|
40
|
+
options={false}
|
41
|
+
scroll={{
|
42
|
+
y: `${document.body.clientHeight - 200}px`,
|
43
|
+
}}
|
44
|
+
request={async (params) => {
|
45
|
+
if (typeof reqFunc !== 'function') return;
|
46
|
+
const { current, pageSize, ...rest } = params;
|
47
|
+
const resp = await reqFunc({
|
48
|
+
[paginationKey[0]]: paginationData.pageSize || pageSize,
|
49
|
+
[paginationKey[1]]: paginationData.current || current,
|
50
|
+
...rest,
|
51
|
+
...reqParams,
|
52
|
+
...sortData,
|
53
|
+
...filterData,
|
54
|
+
});
|
55
|
+
filterData = {};
|
56
|
+
const { total_data, data } = dataTransform ? dataTransform(resp) : resp;
|
57
|
+
if (reqCbFn) reqCbFn(params, { data, total: total_data });
|
58
|
+
return {
|
59
|
+
data,
|
60
|
+
total: total_data,
|
61
|
+
success: true,
|
62
|
+
};
|
63
|
+
}}
|
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
|
+
}
|
85
|
+
if (sorter.field) {
|
86
|
+
const { field, order, column } = sorter;
|
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
|
+
}
|
95
|
+
} else {
|
96
|
+
sortData = {};
|
97
|
+
}
|
98
|
+
}}
|
99
|
+
{...rest}
|
100
|
+
></ProTable>
|
101
|
+
);
|
102
|
+
};
|
103
|
+
|
104
|
+
CommonTable.propTypes = {
|
105
|
+
data: PropTypes.object,
|
106
|
+
dataTransform: PropTypes.func,
|
107
|
+
paginationKey: PropTypes.array,
|
108
|
+
systemTags: PropTypes.array,
|
109
|
+
};
|
110
|
+
|
111
|
+
export default CommonTable;
|
@@ -1,33 +1,16 @@
|
|
1
|
-
import React
|
1
|
+
import React 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
|
-
|
13
6
|
const CommonTable = (props) => {
|
14
7
|
const {
|
15
8
|
data,
|
16
9
|
dataTransform,
|
17
10
|
paginationKey = ['each_page', 'current_page'],
|
18
|
-
systemTags = [],
|
19
11
|
} = props;
|
20
|
-
const [paginationCurrent, setPaginationCurrent] = useState(1);
|
21
12
|
const { rowKey, columns, reqFunc, reqParams, reqCbFn, ...rest } = data;
|
22
|
-
|
23
|
-
paginationData = {
|
24
|
-
current: 1,
|
25
|
-
pageSize: 10,
|
26
|
-
};
|
27
|
-
sortData = {};
|
28
|
-
filterData = {};
|
29
|
-
}, [columns]);
|
30
|
-
|
13
|
+
let sortData = {};
|
31
14
|
return (
|
32
15
|
<ProTable
|
33
16
|
rowKey={(record) => record[rowKey]}
|
@@ -35,7 +18,6 @@ const CommonTable = (props) => {
|
|
35
18
|
pagination={{
|
36
19
|
position: ['bottomCenter'],
|
37
20
|
pageSize: 10,
|
38
|
-
current: paginationCurrent,
|
39
21
|
}}
|
40
22
|
options={false}
|
41
23
|
scroll={{
|
@@ -45,14 +27,12 @@ const CommonTable = (props) => {
|
|
45
27
|
if (typeof reqFunc !== 'function') return;
|
46
28
|
const { current, pageSize, ...rest } = params;
|
47
29
|
const resp = await reqFunc({
|
48
|
-
[paginationKey[0]]:
|
49
|
-
[paginationKey[1]]:
|
30
|
+
[paginationKey[0]]: pageSize,
|
31
|
+
[paginationKey[1]]: current,
|
50
32
|
...rest,
|
51
33
|
...reqParams,
|
52
34
|
...sortData,
|
53
|
-
...filterData,
|
54
35
|
});
|
55
|
-
filterData = {};
|
56
36
|
const { total_data, data } = dataTransform ? dataTransform(resp) : resp;
|
57
37
|
if (reqCbFn) reqCbFn(params, { data, total: total_data });
|
58
38
|
return {
|
@@ -62,26 +42,6 @@ const CommonTable = (props) => {
|
|
62
42
|
};
|
63
43
|
}}
|
64
44
|
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
|
-
}
|
85
45
|
if (sorter.field) {
|
86
46
|
const { field, order, column } = sorter;
|
87
47
|
if (!column) sortData = {};
|
@@ -105,7 +65,6 @@ CommonTable.propTypes = {
|
|
105
65
|
data: PropTypes.object,
|
106
66
|
dataTransform: PropTypes.func,
|
107
67
|
paginationKey: PropTypes.array,
|
108
|
-
systemTags: PropTypes.array,
|
109
68
|
};
|
110
69
|
|
111
70
|
export default CommonTable;
|
@@ -6,6 +6,7 @@ import { Menu, Dropdown, Tooltip, Avatar, Drawer, Modal, Divider } from 'antd';
|
|
6
6
|
import {
|
7
7
|
UserOutlined,
|
8
8
|
SettingOutlined,
|
9
|
+
UsergroupAddOutlined,
|
9
10
|
PoweroffOutlined,
|
10
11
|
} from '@ant-design/icons';
|
11
12
|
// import Notification from '../Notification/recent';
|
@@ -27,6 +28,7 @@ import {
|
|
27
28
|
HOST_PROFILE_DASH_BOARD,
|
28
29
|
HOST_PROFILE_USER,
|
29
30
|
HOST_PROFILE_PASSWORD,
|
31
|
+
HOST_PROFILE_GROUP,
|
30
32
|
} from '../../config/env';
|
31
33
|
|
32
34
|
import LogoProfile from './assets/profile.svg';
|
@@ -89,6 +91,14 @@ const Header = (props) => {
|
|
89
91
|
>
|
90
92
|
修改密码
|
91
93
|
</Menu.Item>
|
94
|
+
<Menu.Item
|
95
|
+
icon={<UsergroupAddOutlined />}
|
96
|
+
onClick={() => {
|
97
|
+
window.location.href = `${HOST_PROFILE_GROUP}?token=${token}`;
|
98
|
+
}}
|
99
|
+
>
|
100
|
+
群组管理
|
101
|
+
</Menu.Item>
|
92
102
|
<Menu.Item
|
93
103
|
icon={<PoweroffOutlined />}
|
94
104
|
onClick={() => {
|
package/lib/config/env.js
CHANGED
@@ -121,6 +121,7 @@ export const HOST_PROFILE_MESSAGE = getEnvHost(
|
|
121
121
|
'profile',
|
122
122
|
'/message-center/home/list'
|
123
123
|
);
|
124
|
+
export const HOST_PROFILE_GROUP = getEnvHost('profile', '/user-profile/group');
|
124
125
|
export const HOST_ZHONGTAI_XLT = getEnvHost('zhongtai_cy');
|
125
126
|
export const HOST_ZHONGTAI_CY = getEnvHost('zhongtai_xlt');
|
126
127
|
|
package/lib/utils/request.js
CHANGED
@@ -7,7 +7,14 @@ import { notification } from 'antd';
|
|
7
7
|
const TOKEN_KEY = 'X-Auth-Token';
|
8
8
|
const ID_KEY = 'X-Auth-Id';
|
9
9
|
const REST_KEY = 'Login-Rest-Info';
|
10
|
-
const
|
10
|
+
const { search, hash } = window.location;
|
11
|
+
let searchQs = '';
|
12
|
+
if (search !== '') {
|
13
|
+
searchQs = search.slice(1);
|
14
|
+
} else if (hash !== '') {
|
15
|
+
searchQs = hash.split('?')[1] || '';
|
16
|
+
}
|
17
|
+
const qsData = qs.parse(searchQs);
|
11
18
|
const { token, userId, ...rest } = qsData;
|
12
19
|
|
13
20
|
token && ls.set(TOKEN_KEY, token);
|
package/lib/utils/utils.js
CHANGED
@@ -52,6 +52,9 @@ export function mergeTableColumnCommonConfig(config) {
|
|
52
52
|
...[{ width: 100 }, { align: 'center' }],
|
53
53
|
];
|
54
54
|
break;
|
55
|
+
case 'textarea':
|
56
|
+
commonConfig = [...commonConfig, ...[{ ellipsis: false }]];
|
57
|
+
break;
|
55
58
|
}
|
56
59
|
commonConfig.forEach((value) => {
|
57
60
|
item = { ...item, ...value };
|