cfel-base-components 0.0.20 → 0.0.21
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/config/webpack.base.js +1 -1
- package/demo/src/index.html +26 -0
- package/demo/src/index.jsx +4 -50
- package/package.json +5 -2
- package/src/apiRequest/config.ts +71 -0
- package/src/apiRequest/hosts.ts +6 -0
- package/src/apiRequest/iotConfig.ts +71 -0
- package/src/components/account/api.ts +11 -0
- package/src/components/account/index.tsx +130 -21
- package/src/components/accountInfo/api.ts +26 -0
- package/src/components/accountInfo/index.tsx +164 -32
- package/src/components/role/api.ts +9 -0
- package/src/components/role/index.tsx +105 -22
- package/src/components/roleInfo/api.ts +22 -0
- package/src/components/roleInfo/index.tsx +186 -41
- package/src/hooks/useTableHooks.ts +60 -0
- package/src/index.tsx +5 -2
- package/src/utils/index.ts +29 -0
- package/lib/index.js +0 -1
- package/lib/index.min.css +0 -2
package/config/webpack.base.js
CHANGED
package/demo/src/index.html
CHANGED
|
@@ -12,6 +12,32 @@
|
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="root"></div>
|
|
15
|
+
<script>
|
|
16
|
+
window.g_config = {
|
|
17
|
+
token: "7718735d-6131-4d96-8e3e-b40e494cd98c",
|
|
18
|
+
tenant: {
|
|
19
|
+
id: 1674706582226763778,
|
|
20
|
+
corpId: "dingc9dbc42450ccf06e4ac5d6980864d335",
|
|
21
|
+
source: "\u9489\u9489",
|
|
22
|
+
name: "\u8FDC\u822A\u8DE8\u56FD\u63A7\u80A1\u96C6\u56E2",
|
|
23
|
+
shortName: "\u8FDC\u822A\u8DE8\u56FD\u63A7\u80A1\u96C6\u56E2",
|
|
24
|
+
logo: ""
|
|
25
|
+
},
|
|
26
|
+
user: {
|
|
27
|
+
id: 1676424765496406018,
|
|
28
|
+
userId: "01436565094521893533",
|
|
29
|
+
unionId: "xsU4QrgEfZxxj8YxEWAYJAiEiE",
|
|
30
|
+
name: "\u5434\u91D1\u521A",
|
|
31
|
+
avatar: "https:\/\/pic.imgdb.cn\/item\/64a520d21ddac507cc4653d3.jpg",
|
|
32
|
+
account: "15957797376",
|
|
33
|
+
roleInfo: []
|
|
34
|
+
},
|
|
35
|
+
logoutUrl: "\/sso\/logout?back=http%3A%2F%2Flios-iot-obee-daily.chengfengerlai.com%2Fdelivery",
|
|
36
|
+
switchTenantUrl: "https:\/\/cfel-sso-daily.chengfengerlai.com\/tenant\/switch?fakeAccountId=1676424765496406018\u0026redirect=http:\/\/lios-iot-obee-daily.chengfengerlai.com\/sso\/login?back=http%3A%2F%2Flios-iot-obee-daily.chengfengerlai.com%2Fdelivery",
|
|
37
|
+
productCode: "lios-iot-obee",
|
|
38
|
+
env: "daily"
|
|
39
|
+
};
|
|
40
|
+
</script>
|
|
15
41
|
<script src="dev.js"></script>
|
|
16
42
|
</body>
|
|
17
43
|
</html>
|
package/demo/src/index.jsx
CHANGED
|
@@ -24,58 +24,12 @@ const App = () => {
|
|
|
24
24
|
// </Layout >
|
|
25
25
|
<>
|
|
26
26
|
|
|
27
|
-
{/* <Account
|
|
28
|
-
// dataList={dataList} //表格数据
|
|
29
|
-
// columns={columns} //列
|
|
30
|
-
// isLoading={isLoading} //加载
|
|
31
|
-
// handleRoload={handleRoload} //分页
|
|
32
|
-
// handleOnReset={handleOnReset} //重置
|
|
33
|
-
// handleOnFinish={handleOnFinish} //搜索
|
|
34
|
-
// pagination={pagination} //分页配置
|
|
35
|
-
></Account> */}
|
|
27
|
+
{/* <Account></Account> */}
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
timeFormatter={timeFormatter} //时间戳转换
|
|
40
|
-
dataList={dataList} //表格数据
|
|
41
|
-
columns={columns} //列
|
|
42
|
-
isLoading={isLoading} //加载
|
|
43
|
-
handleRoload={handleRoload} //分页
|
|
44
|
-
pagination={pagination} //分页配置
|
|
45
|
-
isBoundRolesFunc={isBoundRolesFunc} //绑定/解绑事件
|
|
46
|
-
getQueryBoundRolesFunc={getQueryBoundRolesFunc} //绑定打开弹框
|
|
47
|
-
editAccountOpen={editAccountOpen}// 弹框状态
|
|
48
|
-
setEditAccountOpen={setEditAccountOpen}// 关闭弹框
|
|
49
|
-
rolelistRoleData={rolelistRoleData} //弹框总角色数据
|
|
50
|
-
roleCheckData={roleCheckData} //弹框当前选中
|
|
51
|
-
/> */}
|
|
52
|
-
{/* <Role
|
|
53
|
-
// dataList={dataList} //表格数据
|
|
54
|
-
// columns={columns} //列
|
|
55
|
-
// isLoading={isLoading} //加载
|
|
56
|
-
// handleRoload={handleRoload} //分页
|
|
57
|
-
// handleOnReset={handleOnReset} //重置
|
|
58
|
-
// handleOnFinish={handleOnFinish} //搜索
|
|
59
|
-
// pagination={pagination} //分页配置
|
|
60
|
-
></Role> */}
|
|
29
|
+
<AccountInfo />
|
|
30
|
+
{/* <Role ></Role> */}
|
|
61
31
|
|
|
62
|
-
{/* <RoleInfo
|
|
63
|
-
roleInfo={roleInfo} //角色详情
|
|
64
|
-
timeFormatter={timeFormatter} //时间戳转换
|
|
65
|
-
dataList={dataList} //表格数据
|
|
66
|
-
columns={columns} //列
|
|
67
|
-
isLoading={isLoading} //加载
|
|
68
|
-
handleRoload={handleRoload} //分页
|
|
69
|
-
pagination={pagination} //分页配置
|
|
70
|
-
handleOnFinish={handleOnFinish} //搜索
|
|
71
|
-
handleOnReset={handleOnReset} //重置
|
|
72
|
-
queryByKeywordFunc={queryByKeywordFunc}//搜索
|
|
73
|
-
getQueryBoundRolesFunc={getQueryBoundRolesFunc} //绑定打开弹框
|
|
74
|
-
editAccountOpen={editAccountOpen}// 弹框状态
|
|
75
|
-
setEditAccountOpen={setEditAccountOpen}// 关闭弹框
|
|
76
|
-
roleBoundAccountsFunc={roleBoundAccountsFunc} //绑定/解绑事件
|
|
77
|
-
|
|
78
|
-
/> */}
|
|
32
|
+
{/* <RoleInfo/> */}
|
|
79
33
|
</>
|
|
80
34
|
);
|
|
81
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cfel-base-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "cfel-base-components",
|
|
5
5
|
"main": "/src/index.tsx",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -38,7 +38,10 @@
|
|
|
38
38
|
"webpack": "^5.88.1",
|
|
39
39
|
"webpack-cli": "^5.1.4",
|
|
40
40
|
"webpack-dev-server": "^4.15.1",
|
|
41
|
-
"webpack-merge": "^5.9.0"
|
|
41
|
+
"webpack-merge": "^5.9.0",
|
|
42
|
+
"axios": "^1.4.0",
|
|
43
|
+
"lodash": "^4.17.21",
|
|
44
|
+
"@types/lodash": "^4.14.195"
|
|
42
45
|
},
|
|
43
46
|
"peerDependencies": {
|
|
44
47
|
"@ant-design/icons": "^5.1.4",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import axios, { AxiosRequestHeaders } from 'axios';
|
|
2
|
+
import { notification } from 'antd';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
let UMI_APP_BASEURL = window.location.origin || process.env
|
|
6
|
+
const instance = axios.create({ baseURL: 'https://lios-iot-daily.chengfengerlai.com' });
|
|
7
|
+
|
|
8
|
+
instance.interceptors.request.use(
|
|
9
|
+
(config: any) => {
|
|
10
|
+
config.headers = {
|
|
11
|
+
...config.headers,
|
|
12
|
+
"cfel-token": (window as any)?.g_config?.token
|
|
13
|
+
} as AxiosRequestHeaders;
|
|
14
|
+
|
|
15
|
+
config.params = {
|
|
16
|
+
...config.params,
|
|
17
|
+
productCode: (window as any)?.g_config?.productCode,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return config;
|
|
21
|
+
},
|
|
22
|
+
(error: any) => Promise.reject(error)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
instance.interceptors.response.use(
|
|
26
|
+
//状态码为2xx的时候执行
|
|
27
|
+
(response: any) => {
|
|
28
|
+
const { data = {} } = response;
|
|
29
|
+
const { success, content, errorCode, errorMsg } = data;
|
|
30
|
+
|
|
31
|
+
if (!success) {
|
|
32
|
+
notification.error({
|
|
33
|
+
message: errorMsg
|
|
34
|
+
});
|
|
35
|
+
return Promise.reject(data);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return content;
|
|
39
|
+
},
|
|
40
|
+
//状态码不为2xx的时候执行
|
|
41
|
+
(error: any) => {
|
|
42
|
+
const { response = {} } = error;
|
|
43
|
+
const { status } = response;
|
|
44
|
+
|
|
45
|
+
enum CodeMessage {
|
|
46
|
+
'发出的请求有错误,服务器没有进行新建或修改数据的操作。' = 400,
|
|
47
|
+
'用户未登录。' = 401,
|
|
48
|
+
'用户得到授权,但是访问是被禁止的。' = 403,
|
|
49
|
+
'发出的请求针对的是不存在的记录,服务器没有进行操作。' = 404,
|
|
50
|
+
'请求的格式不可得。' = 406,
|
|
51
|
+
'请求的资源被永久删除,且不会再得到的。' = 410,
|
|
52
|
+
'当创建一个对象时,发生一个验证错误。' = 422,
|
|
53
|
+
'服务器发生错误,请检查服务器。' = 500,
|
|
54
|
+
'网关错误。' = 502,
|
|
55
|
+
'服务不可用,服务器暂时过载或维护。' = 503,
|
|
56
|
+
'网关超时。' = 504
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
notification.error({
|
|
60
|
+
message: response?.data?.message || CodeMessage[status]
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (status === 401) {
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return Promise.reject(error);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export default instance;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import axios, { AxiosRequestHeaders } from 'axios';
|
|
2
|
+
import { notification } from 'antd';
|
|
3
|
+
import { hosts } from './hosts'
|
|
4
|
+
|
|
5
|
+
const env = (window as any)?.g_config?.env
|
|
6
|
+
const instance = axios.create({ baseURL: hosts["iot"][env] });
|
|
7
|
+
|
|
8
|
+
instance.interceptors.request.use(
|
|
9
|
+
(config: any) => {
|
|
10
|
+
config.headers = {
|
|
11
|
+
...config.headers,
|
|
12
|
+
"cfel-token": (window as any)?.g_config?.token
|
|
13
|
+
} as AxiosRequestHeaders;
|
|
14
|
+
|
|
15
|
+
config.params = {
|
|
16
|
+
...config.params,
|
|
17
|
+
productCode: (window as any)?.g_config?.productCode,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return config;
|
|
21
|
+
},
|
|
22
|
+
(error: any) => Promise.reject(error)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
instance.interceptors.response.use(
|
|
26
|
+
//状态码为2xx的时候执行
|
|
27
|
+
(response: any) => {
|
|
28
|
+
const { data = {} } = response;
|
|
29
|
+
const { success, content, errorCode, errorMsg } = data;
|
|
30
|
+
|
|
31
|
+
if (!success) {
|
|
32
|
+
notification.error({
|
|
33
|
+
message: errorMsg
|
|
34
|
+
});
|
|
35
|
+
return Promise.reject(data);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return content;
|
|
39
|
+
},
|
|
40
|
+
//状态码不为2xx的时候执行
|
|
41
|
+
(error: any) => {
|
|
42
|
+
const { response = {} } = error;
|
|
43
|
+
const { status } = response;
|
|
44
|
+
|
|
45
|
+
enum CodeMessage {
|
|
46
|
+
'发出的请求有错误,服务器没有进行新建或修改数据的操作。' = 400,
|
|
47
|
+
'用户未登录。' = 401,
|
|
48
|
+
'用户得到授权,但是访问是被禁止的。' = 403,
|
|
49
|
+
'发出的请求针对的是不存在的记录,服务器没有进行操作。' = 404,
|
|
50
|
+
'请求的格式不可得。' = 406,
|
|
51
|
+
'请求的资源被永久删除,且不会再得到的。' = 410,
|
|
52
|
+
'当创建一个对象时,发生一个验证错误。' = 422,
|
|
53
|
+
'服务器发生错误,请检查服务器。' = 500,
|
|
54
|
+
'网关错误。' = 502,
|
|
55
|
+
'服务不可用,服务器暂时过载或维护。' = 503,
|
|
56
|
+
'网关超时。' = 504
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
notification.error({
|
|
60
|
+
message: response?.data?.message || CodeMessage[status]
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (status === 401) {
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return Promise.reject(error);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export default instance;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import request from "../../apiRequest/config"
|
|
2
|
+
|
|
3
|
+
//分页查询账号
|
|
4
|
+
export const accountPage= (data?: any) => {
|
|
5
|
+
return request.post("/api/permission/account/page.json", { ...data })
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const updateDevice = (data?: any) => {
|
|
9
|
+
return request.post("/api/wifi/device/bound/space/update.json", { ...data })
|
|
10
|
+
}
|
|
11
|
+
|
|
@@ -1,33 +1,142 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import useTableHooks from "../../hooks/useTableHooks"
|
|
2
3
|
import PageContainer from '../PageContainer';
|
|
3
4
|
import QueryFilter from '../QueryFilter';
|
|
4
5
|
import ProTable from '../ProTable';
|
|
5
6
|
import Pagination from '../Pagination';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
} from '
|
|
7
|
+
import { ProFormText,} from '@ant-design/pro-components';
|
|
8
|
+
import { Space, } from 'antd';
|
|
9
|
+
import { get } from 'lodash';
|
|
10
|
+
import { timeFormatter } from '../../utils';
|
|
11
|
+
import { accountPage } from "./api"
|
|
12
|
+
|
|
9
13
|
import "./index.scss"
|
|
10
14
|
|
|
11
15
|
|
|
12
|
-
export interface AccountProps {
|
|
13
|
-
dataList: any;
|
|
14
|
-
columns: any;
|
|
15
|
-
isLoading: any;
|
|
16
|
-
handleRoload: () => any;
|
|
17
|
-
pagination: any;
|
|
18
|
-
handleOnReset: (item: any) => any;
|
|
19
|
-
handleOnFinish: (item: any) => any;
|
|
20
|
-
}
|
|
21
16
|
|
|
22
|
-
export default function Account({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
export default function Account() {
|
|
18
|
+
const searchFormRef: any = useRef()
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
execute()
|
|
22
|
+
}, [])
|
|
23
|
+
|
|
24
|
+
const columns: any = [
|
|
25
|
+
{
|
|
26
|
+
title: '名称',
|
|
27
|
+
dataIndex: 'name',
|
|
28
|
+
key: 'name',
|
|
29
|
+
render: (text: any) => {
|
|
30
|
+
return <span>{text}</span>
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
title: '账号',
|
|
35
|
+
dataIndex: 'account',
|
|
36
|
+
key: 'account',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: '工号',
|
|
40
|
+
dataIndex: 'jobNumber',
|
|
41
|
+
key: 'jobNumber',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: '手机号',
|
|
45
|
+
dataIndex: 'mobile',
|
|
46
|
+
key: 'mobile',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: '邮箱',
|
|
50
|
+
dataIndex: 'email',
|
|
51
|
+
key: 'email',
|
|
52
|
+
ellipsis: true,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: '是否企业管理员',
|
|
56
|
+
dataIndex: 'isAdmin',
|
|
57
|
+
key: 'isAdmin',
|
|
58
|
+
render: (text: any, rowData: any) => {
|
|
59
|
+
if (rowData.isAdmin) {
|
|
60
|
+
return '是'
|
|
61
|
+
} else {
|
|
62
|
+
return '否'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
title: '创建时间',
|
|
69
|
+
dataIndex: 'gmtCreate',
|
|
70
|
+
key: 'gmtCreate',
|
|
71
|
+
render: (cell: any) => {
|
|
72
|
+
return timeFormatter(cell)
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: '修改时间',
|
|
77
|
+
dataIndex: 'gmtModified',
|
|
78
|
+
key: 'gmtModified',
|
|
79
|
+
render: (cell: any) => {
|
|
80
|
+
return timeFormatter(cell)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: '操作',
|
|
85
|
+
fixed: 'right',
|
|
86
|
+
width: 80,
|
|
87
|
+
render: (rowdata: any) => (
|
|
88
|
+
<Space>
|
|
89
|
+
<a
|
|
90
|
+
onClick={() => {
|
|
91
|
+
let origin = window.location?.origin
|
|
92
|
+
let baseUrl = window.location?.pathname.slice(1).split('/')[0]
|
|
93
|
+
window.location.href = `${origin}/${baseUrl}/account-info?id=${rowdata.id}`
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
配置
|
|
97
|
+
</a>
|
|
98
|
+
</Space>
|
|
99
|
+
),
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
const handleOnReset: any = async (values: any) => {
|
|
104
|
+
searchFormRef.current = { ...values }
|
|
105
|
+
execute({
|
|
106
|
+
innerPageNo: 1,
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const handleOnFinish: any = async (values: any) => {
|
|
111
|
+
searchFormRef.current = { ...values }
|
|
112
|
+
execute()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const readDataList = ({
|
|
116
|
+
innerPageNo,
|
|
117
|
+
innerPageSize,
|
|
118
|
+
}: any) => {
|
|
119
|
+
return accountPage({
|
|
120
|
+
currentPage: innerPageNo,
|
|
121
|
+
pageSize: innerPageSize,
|
|
122
|
+
...searchFormRef.current,
|
|
123
|
+
}).then((res: any) => {
|
|
124
|
+
let records = get(res, "records", [])
|
|
125
|
+
let total = get(res, "total", 0)
|
|
126
|
+
return {
|
|
127
|
+
dataList: records,
|
|
128
|
+
totalCount: total
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const { execute, dataList, isLoading, pagination } = useTableHooks({
|
|
134
|
+
asyncFunction: readDataList
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
const handleRoload = () => {
|
|
138
|
+
execute()
|
|
139
|
+
}
|
|
31
140
|
|
|
32
141
|
return (
|
|
33
142
|
<PageContainer>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import request from "../../apiRequest/config"
|
|
2
|
+
|
|
3
|
+
//按账号id查询账号信息
|
|
4
|
+
export const getAccount= (data?: any) => {
|
|
5
|
+
return request.post("/api/permission/account/getAccount.json", { ...data })
|
|
6
|
+
}
|
|
7
|
+
//根据账号查询绑定的角色 分页
|
|
8
|
+
export const pageBoundRoles= (data?: any) => {
|
|
9
|
+
return request.post("/api/permission/accountRole/pageBoundRoles.json", { ...data })
|
|
10
|
+
}
|
|
11
|
+
//根据账号查询绑定的角色
|
|
12
|
+
export const queryBoundRoles= (data?: any) => {
|
|
13
|
+
return request.post("/api/permission/accountRole/queryBoundRoles.json", { ...data })
|
|
14
|
+
}
|
|
15
|
+
//获取所有角色
|
|
16
|
+
export const rolelistRole = (data?: any) => {
|
|
17
|
+
return request.get("/api/permission/role/listRole.json", { ...data })
|
|
18
|
+
}
|
|
19
|
+
//账号下绑定角色
|
|
20
|
+
export const accountBoundRoles= (data?: any) => {
|
|
21
|
+
return request.post("/api/permission/accountRole/accountBoundRoles.json", { ...data })
|
|
22
|
+
}
|
|
23
|
+
//账号下解绑角色
|
|
24
|
+
export const accountUnboundRoles= (data?: any) => {
|
|
25
|
+
return request.post("/api/permission/accountRole/accountUnboundRoles.json", { ...data })
|
|
26
|
+
}
|
|
@@ -1,47 +1,179 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import useTableHooks from "../../hooks/useTableHooks"
|
|
2
3
|
import Pagecontainer from '../PageContainer';
|
|
3
4
|
import ProTable from '../ProTable';
|
|
4
5
|
import Pagination from '../Pagination';
|
|
5
|
-
|
|
6
|
+
import { get } from 'lodash';
|
|
6
7
|
import { Modal, Button, Divider, Descriptions, Space, message, Avatar } from 'antd';
|
|
7
8
|
import { UserOutlined } from '@ant-design/icons';
|
|
8
9
|
import EditAccountDrawer from './EditAccountDrawer/index'
|
|
9
|
-
|
|
10
|
+
import { timeFormatter, getUrlParams } from '../../utils';
|
|
11
|
+
import {
|
|
12
|
+
getAccount,
|
|
13
|
+
pageBoundRoles,
|
|
14
|
+
queryBoundRoles,
|
|
15
|
+
rolelistRole,
|
|
16
|
+
accountBoundRoles,
|
|
17
|
+
accountUnboundRoles
|
|
18
|
+
} from './api'
|
|
10
19
|
import "./index.scss"
|
|
11
20
|
|
|
12
|
-
export interface AccountInfoProps {
|
|
13
|
-
accountInfo: any;
|
|
14
|
-
timeFormatter: (item: any) => any;
|
|
15
|
-
dataList: any;
|
|
16
|
-
columns: any;
|
|
17
|
-
isLoading: any;
|
|
18
|
-
handleRoload: () => any;
|
|
19
|
-
pagination: any;
|
|
20
|
-
isBoundRolesFunc: (type: any, item: any) => any;
|
|
21
|
-
getQueryBoundRolesFunc: () => any;
|
|
22
|
-
editAccountOpen: any
|
|
23
|
-
setEditAccountOpen: (item: any) => any;
|
|
24
|
-
rolelistRoleData: any,
|
|
25
|
-
roleCheckData: any,
|
|
26
|
-
}
|
|
27
21
|
|
|
28
|
-
export default function AccountInfo({
|
|
29
|
-
accountInfo,//用户详情
|
|
30
|
-
timeFormatter,//时间戳转换
|
|
31
|
-
dataList,//表格数据
|
|
32
|
-
columns,//列
|
|
33
|
-
isLoading,//加载
|
|
34
|
-
handleRoload,//分页
|
|
35
|
-
pagination,//分页配置
|
|
36
|
-
isBoundRolesFunc,//绑定/解绑事件
|
|
37
|
-
getQueryBoundRolesFunc,//绑定打开弹框
|
|
38
|
-
editAccountOpen, //弹框状态
|
|
39
|
-
setEditAccountOpen, //关闭弹框
|
|
40
|
-
rolelistRoleData, //总角色数据
|
|
41
|
-
roleCheckData, //当前选中
|
|
42
22
|
|
|
43
|
-
|
|
23
|
+
export default function AccountInfo() {
|
|
24
|
+
const [accountInfo, setAccountInfoInfo]: any = useState({})
|
|
25
|
+
const [pageId, setPageId] = useState('')
|
|
26
|
+
const [rolelistRoleData, setRolelistRoleData]: any = useState([]); // 角色总数据
|
|
27
|
+
const [roleCheckData, setRoleCheckData]: any = useState([]); //当前选中的角色list
|
|
28
|
+
const [editAccountOpen, setEditAccountOpen] = useState(false);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
let id = getUrlParams('id')
|
|
32
|
+
if (!id) return
|
|
33
|
+
setPageId(id)
|
|
34
|
+
initGetData()
|
|
35
|
+
}, [])
|
|
36
|
+
|
|
37
|
+
const columns: any = [
|
|
38
|
+
{
|
|
39
|
+
title: '角色名称',
|
|
40
|
+
dataIndex: 'roleName',
|
|
41
|
+
key: 'roleName',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: '角色编码',
|
|
45
|
+
dataIndex: 'roleCode',
|
|
46
|
+
key: 'roleCode',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: '来源',
|
|
50
|
+
dataIndex: 'source',
|
|
51
|
+
key: 'source',
|
|
52
|
+
render: (cell: any) => {
|
|
53
|
+
if (cell == 'system') {
|
|
54
|
+
return '系统创建'
|
|
55
|
+
} else if (cell == 'user') {
|
|
56
|
+
return '用户自建'
|
|
57
|
+
} else if (cell == 'user') {
|
|
58
|
+
return '未知'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: '描述',
|
|
64
|
+
dataIndex: 'description',
|
|
65
|
+
key: 'description',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: '创建时间',
|
|
69
|
+
dataIndex: 'gmtCreate',
|
|
70
|
+
key: 'gmtCreate',
|
|
71
|
+
render: (cell: any) => {
|
|
72
|
+
return timeFormatter(cell)
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: '修改时间',
|
|
77
|
+
dataIndex: 'gmtModified',
|
|
78
|
+
key: 'gmtModified',
|
|
79
|
+
render: (cell: any) => {
|
|
80
|
+
return timeFormatter(cell)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: '操作',
|
|
85
|
+
width: 80,
|
|
86
|
+
fixed: "right",
|
|
87
|
+
render: (rowdata: any,) => <Space>
|
|
88
|
+
<a onClick={() => {
|
|
89
|
+
Modal.confirm({
|
|
90
|
+
title: "确认解绑吗?",
|
|
91
|
+
content: '',
|
|
92
|
+
onOk: () => {
|
|
93
|
+
isBoundRolesFunc(false, { roleCodes: [rowdata.roleCode] })
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}}>解绑</a>
|
|
97
|
+
</Space>
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
//初始化请求数据
|
|
103
|
+
const initGetData = () => {
|
|
104
|
+
let id = getUrlParams('id')
|
|
105
|
+
getAccountFunc({ id })
|
|
106
|
+
execute({ "accountId": id })
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const getAccountFunc = (data: any) => {
|
|
110
|
+
setAccountInfoInfo({})
|
|
111
|
+
getAccount({
|
|
112
|
+
...data,
|
|
113
|
+
}).then((res: any) => {
|
|
114
|
+
setAccountInfoInfo(res || {})
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const readDataList = ({
|
|
119
|
+
innerPageNo,
|
|
120
|
+
innerPageSize,
|
|
121
|
+
...otherOptions
|
|
122
|
+
}: any) => {
|
|
123
|
+
return pageBoundRoles({
|
|
124
|
+
currentPage: innerPageNo,
|
|
125
|
+
pageSize: innerPageSize,
|
|
126
|
+
...otherOptions
|
|
127
|
+
}).then((res: any) => {
|
|
128
|
+
let records = get(res, "records", [])
|
|
129
|
+
let total = get(res, "total", 0)
|
|
130
|
+
return {
|
|
131
|
+
dataList: records,
|
|
132
|
+
totalCount: total
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
const { execute, dataList, isLoading, pagination } = useTableHooks({
|
|
137
|
+
asyncFunction: readDataList
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
const handleRoload = () => {
|
|
141
|
+
execute({ "accountId": pageId })
|
|
142
|
+
}
|
|
44
143
|
|
|
144
|
+
const getQueryBoundRolesFunc = () => {
|
|
145
|
+
Promise.all([queryBoundRoles({ accountId: pageId }), rolelistRole()]).then((res) => {
|
|
146
|
+
let boundRoles: any = res[0]
|
|
147
|
+
let roleList: any = res[1]
|
|
148
|
+
let result = []
|
|
149
|
+
for (var i = 0; i < roleList.length; i++) {
|
|
150
|
+
var item = roleList[i]
|
|
151
|
+
var repeat = false
|
|
152
|
+
for (var j = 0; j < boundRoles.length; j++) {
|
|
153
|
+
if (item.roleCode === boundRoles[j].roleCode) {
|
|
154
|
+
repeat = true
|
|
155
|
+
break
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (repeat) {
|
|
159
|
+
result.push(item.roleCode)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
setRolelistRoleData(roleList)
|
|
163
|
+
setRoleCheckData(result)
|
|
164
|
+
setEditAccountOpen(true)
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
const isBoundRolesFunc = (type: any, { roleCodes }: any) => {
|
|
168
|
+
return (type ? accountBoundRoles : accountUnboundRoles)({
|
|
169
|
+
"accountId": pageId,
|
|
170
|
+
"roleCodes": roleCodes
|
|
171
|
+
}).then(() => {
|
|
172
|
+
message.success(`${type ? '绑定' : '解绑'}成功`)
|
|
173
|
+
execute({ "accountId": pageId })
|
|
174
|
+
setEditAccountOpen(false)
|
|
175
|
+
})
|
|
176
|
+
}
|
|
45
177
|
return (
|
|
46
178
|
<Pagecontainer>
|
|
47
179
|
<Divider orientation="left">
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import request from "../../apiRequest/config"
|
|
2
|
+
|
|
3
|
+
export const pageRequest = (data?: any) => {
|
|
4
|
+
return request.post("/api/permission/role/page.json", { ...data })
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const updateConfig = (data?: any) => {
|
|
8
|
+
return request.post("/api/wifi/device/bound/radioConfig/updateConfig.json", { ...data })
|
|
9
|
+
}
|
|
@@ -1,32 +1,115 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import useTableHooks from "../../hooks/useTableHooks"
|
|
3
|
+
|
|
2
4
|
import PageContainer from '../PageContainer';
|
|
3
5
|
import QueryFilter from '../QueryFilter';
|
|
4
6
|
import ProTable from '../ProTable';
|
|
5
7
|
import Pagination from '../Pagination';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
} from
|
|
8
|
+
import { get } from 'lodash';
|
|
9
|
+
import { Space, } from 'antd';
|
|
10
|
+
import { pageRequest, } from "./api"
|
|
11
|
+
|
|
12
|
+
import { ProFormText, } from '@ant-design/pro-components';
|
|
13
|
+
import { timeFormatter } from '../../utils';
|
|
14
|
+
|
|
9
15
|
import "./index.scss"
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
columns
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
|
|
18
|
+
export default function Role() {
|
|
19
|
+
const searchFormRef: any = useRef()
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
init()
|
|
23
|
+
execute()
|
|
24
|
+
}, [])
|
|
25
|
+
|
|
26
|
+
const init = () => {
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const columns: any = [
|
|
30
|
+
{
|
|
31
|
+
title: '角色名称',
|
|
32
|
+
dataIndex: 'roleName',
|
|
33
|
+
key: 'roleName',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: '角色编码',
|
|
37
|
+
dataIndex: 'roleCode',
|
|
38
|
+
key: 'roleCode',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: '角色描述',
|
|
42
|
+
dataIndex: 'description',
|
|
43
|
+
key: 'description',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: '创建时间',
|
|
47
|
+
dataIndex: 'gmtCreate',
|
|
48
|
+
key: 'gmtCreate',
|
|
49
|
+
render: (cell: any) => {
|
|
50
|
+
return timeFormatter(cell)
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: '更新时间',
|
|
55
|
+
dataIndex: 'gmtModified',
|
|
56
|
+
key: 'gmtModified',
|
|
57
|
+
render: (cell: any) => {
|
|
58
|
+
return timeFormatter(cell)
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: '操作',
|
|
63
|
+
width: 80,
|
|
64
|
+
fixed: "right",
|
|
65
|
+
render: (rowdata: any,) => <Space>
|
|
66
|
+
<a onClick={() => {
|
|
67
|
+
let origin = window.location?.origin
|
|
68
|
+
let baseUrl = window.location?.pathname.slice(1).split('/')[0]
|
|
69
|
+
window.location.href = `${origin}/${baseUrl}/role-info?roleCode=${rowdata.roleCode}`
|
|
70
|
+
}}>赋予账号</a>
|
|
71
|
+
</Space>
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const handleOnReset: any = async (values: any) => {
|
|
76
|
+
searchFormRef.current = { ...values }
|
|
77
|
+
execute({
|
|
78
|
+
innerPageNo: 1,
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const handleOnFinish: any = async (values: any) => {
|
|
83
|
+
searchFormRef.current = { ...values }
|
|
84
|
+
execute()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const readDataList = ({
|
|
88
|
+
innerPageNo,
|
|
89
|
+
innerPageSize,
|
|
90
|
+
}: any) => {
|
|
91
|
+
return pageRequest({
|
|
92
|
+
currentPage: innerPageNo,
|
|
93
|
+
pageSize: innerPageSize,
|
|
94
|
+
...searchFormRef.current
|
|
95
|
+
}).then((res: any) => {
|
|
96
|
+
let records = get(res, "records", [])
|
|
97
|
+
let total = get(res, "total", 0)
|
|
98
|
+
return {
|
|
99
|
+
dataList: records,
|
|
100
|
+
totalCount: total
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const { execute, dataList, isLoading, pagination } = useTableHooks({
|
|
106
|
+
asyncFunction: readDataList
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
const handleRoload = () => {
|
|
110
|
+
execute()
|
|
111
|
+
}
|
|
112
|
+
|
|
30
113
|
return (
|
|
31
114
|
<PageContainer >
|
|
32
115
|
<QueryFilter
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import request from "../../apiRequest/config"
|
|
2
|
+
|
|
3
|
+
//根据角色分页查询绑定的账号
|
|
4
|
+
export const pageBoundAccounts= (data?: any) => {
|
|
5
|
+
return request.post("/api/permission/accountRole/pageBoundAccounts.json", { ...data })
|
|
6
|
+
}
|
|
7
|
+
//按关键词查询账号信息
|
|
8
|
+
export const queryByKeyword= (data?: any) => {
|
|
9
|
+
return request.post("/api/permission/account/queryByKeyword.json", { ...data })
|
|
10
|
+
}
|
|
11
|
+
//角色下绑定账号
|
|
12
|
+
export const roleBoundAccounts= (data?: any) => {
|
|
13
|
+
return request.post("/api/permission/accountRole/roleBoundAccounts.json", { ...data })
|
|
14
|
+
}
|
|
15
|
+
//角色下解绑账号
|
|
16
|
+
export const roleUnboundAccounts= (data?: any) => {
|
|
17
|
+
return request.post("/api/permission/accountRole/roleUnboundAccounts.json", { ...data })
|
|
18
|
+
}
|
|
19
|
+
//根据编码查询角色
|
|
20
|
+
export const getRole= (data?: any) => {
|
|
21
|
+
return request.post("/api/permission/role/getRole.json", { ...data })
|
|
22
|
+
}
|
|
@@ -1,50 +1,195 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import useTableHooks from "../../hooks/useTableHooks"
|
|
3
|
+
|
|
2
4
|
import PageContainer from '../PageContainer';
|
|
3
5
|
import QueryFilter from '../QueryFilter';
|
|
4
6
|
import ProTable from '../ProTable';
|
|
5
7
|
import Pagination from '../Pagination';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
} from '
|
|
9
|
-
import { Button, Divider, Modal, Descriptions, Space, } from 'antd';
|
|
8
|
+
import { get } from 'lodash';
|
|
9
|
+
import { ProFormText, } from '@ant-design/pro-components';
|
|
10
|
+
import { Button, Divider, Modal, Descriptions, Space, message } from 'antd';
|
|
10
11
|
import EditAccountDrawer from './EditAccountDrawer/index'
|
|
11
|
-
|
|
12
|
+
import { timeFormatter, getUrlParams } from '../../utils';
|
|
13
|
+
import {
|
|
14
|
+
pageBoundAccounts,
|
|
15
|
+
roleBoundAccounts,
|
|
16
|
+
roleUnboundAccounts,
|
|
17
|
+
getRole,
|
|
18
|
+
queryByKeyword
|
|
19
|
+
} from './api'
|
|
12
20
|
import "./index.scss"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
21
|
+
|
|
22
|
+
export default function RoleInfo(){
|
|
23
|
+
const searchFormRef: any = useRef()
|
|
24
|
+
const [roleCode, setRoleCode] = useState('')
|
|
25
|
+
const [roleInfo, setRoleInfo]: any = useState({})
|
|
26
|
+
const [editAccountOpen, setEditAccountOpen] = useState(false);
|
|
27
|
+
|
|
28
|
+
const columns: any = [
|
|
29
|
+
{
|
|
30
|
+
title: '名称',
|
|
31
|
+
dataIndex: 'name',
|
|
32
|
+
key: 'name',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: '账号',
|
|
36
|
+
dataIndex: 'account',
|
|
37
|
+
key: 'account',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: '工号',
|
|
41
|
+
dataIndex: 'jobNumber',
|
|
42
|
+
key: 'jobNumber',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: '手机号',
|
|
46
|
+
dataIndex: 'mobile',
|
|
47
|
+
key: 'mobile',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: '邮箱',
|
|
51
|
+
dataIndex: 'email',
|
|
52
|
+
key: 'email',
|
|
53
|
+
copyable: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: '是否企业管理员',
|
|
57
|
+
dataIndex: 'isAdmin',
|
|
58
|
+
key: 'isAdmin',
|
|
59
|
+
render: (cell: any) => {
|
|
60
|
+
if (cell) {
|
|
61
|
+
return '是'
|
|
62
|
+
} else {
|
|
63
|
+
return '否'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: '创建时间',
|
|
69
|
+
dataIndex: 'gmtCreate',
|
|
70
|
+
key: 'gmtCreate',
|
|
71
|
+
render: (cell: any) => {
|
|
72
|
+
return timeFormatter(cell)
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: '修改时间',
|
|
77
|
+
dataIndex: 'gmtModified',
|
|
78
|
+
key: 'gmtModified',
|
|
79
|
+
render: (cell: any) => {
|
|
80
|
+
return timeFormatter(cell)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: '操作',
|
|
85
|
+
width: 80,
|
|
86
|
+
fixed: "right",
|
|
87
|
+
render: (rowdata: any,) => <Space>
|
|
88
|
+
<a onClick={() => {
|
|
89
|
+
Modal.confirm({
|
|
90
|
+
title: "确认解绑吗?",
|
|
91
|
+
content: '',
|
|
92
|
+
onOk: () => {
|
|
93
|
+
roleUnboundAccountsFunc(rowdata.id)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
}}>解绑</a>
|
|
98
|
+
</Space>
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
initGetData('init', true)
|
|
104
|
+
}, [])
|
|
105
|
+
|
|
106
|
+
//初始化请求数据
|
|
107
|
+
const initGetData = (type: string, msgType: any) => {
|
|
108
|
+
let roleCode = getUrlParams('roleCode')
|
|
109
|
+
setRoleCode(roleCode)
|
|
110
|
+
if (roleCode) {
|
|
111
|
+
getRoleFunc({ roleCode })
|
|
112
|
+
execute({ "roleCode": roleCode })
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const getRoleFunc = (data: any) => {
|
|
116
|
+
setRoleInfo({})
|
|
117
|
+
getRole({
|
|
118
|
+
...data,
|
|
119
|
+
}).then((res: any) => {
|
|
120
|
+
setRoleInfo(res || {})
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
const roleUnboundAccountsFunc = (account: any) => {
|
|
124
|
+
roleUnboundAccounts({
|
|
125
|
+
"accountIds": [account],
|
|
126
|
+
"roleCode": roleCode
|
|
127
|
+
}).then((res: any) => {
|
|
128
|
+
message.success('解绑成功')
|
|
129
|
+
execute({ "roleCode": roleCode })
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const readDataList = ({
|
|
134
|
+
innerPageNo,
|
|
135
|
+
innerPageSize,
|
|
136
|
+
...otherOptions
|
|
137
|
+
}: any) => {
|
|
138
|
+
return pageBoundAccounts({
|
|
139
|
+
currentPage: innerPageNo,
|
|
140
|
+
pageSize: innerPageSize,
|
|
141
|
+
...searchFormRef.current,
|
|
142
|
+
...otherOptions
|
|
143
|
+
}).then((res: any) => {
|
|
144
|
+
let records = get(res, "records", [])
|
|
145
|
+
let total = get(res, "total", 0)
|
|
146
|
+
return {
|
|
147
|
+
dataList: records,
|
|
148
|
+
totalCount: total
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
const { execute, dataList, isLoading, pagination } = useTableHooks({
|
|
153
|
+
asyncFunction: readDataList
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
const handleRoload = () => {
|
|
157
|
+
execute({ "roleCode": roleCode })
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const getQueryBoundRolesFunc = async () => {
|
|
161
|
+
setEditAccountOpen(true)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const roleBoundAccountsFunc = ({ accountIds }: any) => {
|
|
165
|
+
return roleBoundAccounts({
|
|
166
|
+
"accountIds": accountIds,
|
|
167
|
+
"roleCode": roleCode
|
|
168
|
+
}).then((res: any) => {
|
|
169
|
+
message.success(`添加账号成功`)
|
|
170
|
+
execute({ "roleCode": roleCode })
|
|
171
|
+
setEditAccountOpen(false)
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
//搜索关键字
|
|
175
|
+
const queryByKeywordFunc = ({ keyword }: any) => {
|
|
176
|
+
return queryByKeyword({
|
|
177
|
+
keyword
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const handleOnReset: any = async (values: any) => {
|
|
182
|
+
searchFormRef.current = { ...values }
|
|
183
|
+
execute({
|
|
184
|
+
innerPageNo: 1,
|
|
185
|
+
"roleCode": roleCode
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const handleOnFinish: any = async (values: any) => {
|
|
190
|
+
searchFormRef.current = { ...values }
|
|
191
|
+
execute({ "roleCode": roleCode })
|
|
192
|
+
}
|
|
48
193
|
return(
|
|
49
194
|
<PageContainer>
|
|
50
195
|
<Divider orientation="left">{roleInfo?.roleName || "-"}</Divider>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { get } from "lodash"
|
|
3
|
+
|
|
4
|
+
function useTableHooks({
|
|
5
|
+
asyncFunction
|
|
6
|
+
}: any) {
|
|
7
|
+
const [isLoading, setIsLoading] = useState<any>(false)
|
|
8
|
+
const [pageNo, setPageNo] = useState(1)
|
|
9
|
+
const [pageSize, setPageSize] = useState(10)
|
|
10
|
+
const [total, setTotal] = useState(0)
|
|
11
|
+
const [dataList, setDataList] = useState([])
|
|
12
|
+
|
|
13
|
+
const execute: any = async (options: any) => {
|
|
14
|
+
const { innerPageNo = pageNo, innerPageSize = pageSize, ...otherOptions } = options || {}
|
|
15
|
+
|
|
16
|
+
setPageNo(innerPageNo);
|
|
17
|
+
setPageSize(innerPageSize);
|
|
18
|
+
setIsLoading(true);
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const res = await asyncFunction({
|
|
22
|
+
innerPageNo,
|
|
23
|
+
innerPageSize,
|
|
24
|
+
...otherOptions
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
setIsLoading(false)
|
|
28
|
+
|
|
29
|
+
const list: any = get(res, "dataList", [])
|
|
30
|
+
const totalCount: any = get(res, "totalCount", 0)
|
|
31
|
+
|
|
32
|
+
setTotal(totalCount)
|
|
33
|
+
setDataList(list)
|
|
34
|
+
|
|
35
|
+
} catch {
|
|
36
|
+
setIsLoading(false)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const pagination = {
|
|
41
|
+
current: pageNo,
|
|
42
|
+
pageSize,
|
|
43
|
+
total,
|
|
44
|
+
onChange: (innerPageNo: number, innerPageSize: number) => {
|
|
45
|
+
execute({
|
|
46
|
+
innerPageNo,
|
|
47
|
+
innerPageSize
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
execute,
|
|
54
|
+
pagination,
|
|
55
|
+
isLoading,
|
|
56
|
+
dataList,
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default useTableHooks
|
package/src/index.tsx
CHANGED
|
@@ -7,7 +7,8 @@ import Account from './components/account'
|
|
|
7
7
|
import AccountInfo from './components/accountInfo'
|
|
8
8
|
import Role from './components/role'
|
|
9
9
|
import RoleInfo from './components/roleInfo'
|
|
10
|
-
|
|
10
|
+
import request from './apiRequest/config'
|
|
11
|
+
import iotRequest from './apiRequest/iotConfig'
|
|
11
12
|
|
|
12
13
|
export {
|
|
13
14
|
LiosLayout,
|
|
@@ -19,5 +20,7 @@ export {
|
|
|
19
20
|
Account,
|
|
20
21
|
AccountInfo,
|
|
21
22
|
Role,
|
|
22
|
-
RoleInfo
|
|
23
|
+
RoleInfo,
|
|
24
|
+
request,
|
|
25
|
+
iotRequest
|
|
23
26
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import dayjs from "dayjs"
|
|
2
|
+
//获取url上的参数
|
|
3
|
+
export const getUrlParams = (id: string) => {
|
|
4
|
+
let params = new URLSearchParams(location.search);
|
|
5
|
+
return params.get(id) || ""
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const downloadFile = (url: string, name: string, suffix?: string) => {
|
|
9
|
+
if (!url || !name) return
|
|
10
|
+
const link = document.createElement('a');
|
|
11
|
+
link.target = '_blank'
|
|
12
|
+
link.style.display = 'none';
|
|
13
|
+
fetch(url, {
|
|
14
|
+
method: 'post',
|
|
15
|
+
}).then(res => res.blob()).then((blob) => {
|
|
16
|
+
link.href = URL.createObjectURL(blob);
|
|
17
|
+
link.download = name + "." + (suffix || 'xlsx');
|
|
18
|
+
document.body.appendChild(link);
|
|
19
|
+
link.click();
|
|
20
|
+
link.remove();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const timeFormatter = (timestamp: number, format?: string) => {
|
|
25
|
+
if (isNaN(Number(timestamp))) {
|
|
26
|
+
return "-"
|
|
27
|
+
}
|
|
28
|
+
return dayjs(timestamp).format(format || "YYYY-MM-DD HH:mm:ss")
|
|
29
|
+
}
|
package/lib/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var r="object"==typeof exports?t(require("react")):t(e.React);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(self,(e=>(()=>{"use strict";var t={787:t=>{t.exports=e}},r={};var o={};return function e(o){var f=r[o];if(void 0!==f)return f.exports;var p=r[o]={exports:{}};return t[o](p,p.exports,e),p.exports}(787),o.default})()));
|
package/lib/index.min.css
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
body{margin:0}.lios-header{height:48px;background:white;z-index:1;box-shadow:1px 0px 5px #ccc;position:relative;display:flex;justify-content:flex-start;align-items:center}.lios-header .background{width:800px;height:100%;position:absolute;top:0;right:0;overflow:hidden}.lios-header .background .background-img{width:800px;position:absolute;top:-65px}.lios-header .background .background-mask{position:absolute;left:0;top:0;width:100%;height:100%;background:linear-gradient(to right, #fff, rgba(255,255,255,0))}.lios-header .lios-header-fill{flex:1}.lios-header .lios-logo{left:48px;top:0;width:255px;position:absolute;z-index:1;display:inline-flex;align-items:center}.lios-header .lios-logo .img{color:#1677ff;font-size:20px;line-height:48px;font-family:Lucida Calligraphy, cursive, serif, sans-serif;margin-right:12px}.lios-header .lios-logo .interval{color:rgba(0,0,0,0.1);width:1px;height:12px;background-color:rgba(0,0,0,0.1);margin:8px}.lios-header .lios-logo .app-list .app-list-current{font-size:12px;height:24px;line-height:24px;padding:0 12px;border-radius:6px;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';cursor:pointer;transition:all 0.3s;color:rgba(0,0,0,0.88);font-weight:400}.lios-header .lios-logo .app-list .app-list-current:hover{background:rgba(0,0,0,0.1)}.lios-header .lios-header-actions{display:flex;justify-content:flex-start;align-items:center;height:100%;max-width:300px;z-index:2}.lios-header .lios-header-actions .actions-item{height:36px;border-radius:6px;transition:all .3s;cursor:pointer;margin:0 4px;padding:0 12px;display:flex;justify-content:center;align-items:center}.lios-header .lios-header-actions .actions-item:hover{background:rgba(255,255,255,0.15)}.lios-header .lios-header-user{height:40px;display:flex;justify-content:flex-start;align-items:center;z-index:2;transition:all .3s;padding:0 12px;margin:0 12px;border-radius:6px;cursor:pointer}.lios-header .lios-header-user:hover{background:rgba(255,255,255,0.15)}.lios-header .lios-header-user .author{width:36px;height:36px;border-radius:50%;background:rgba(255,255,255,0.3);margin-right:12px}.lios-header .lios-header-user .name{color:white}.lios-main{display:flex;height:100%}.lios-side{max-width:255px;height:calc(100vh - 48px);background:white;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding-top:12px}.lios-content{width:100%;height:calc(100vh - 48px);overflow-y:auto;padding:16px 16px 5px;display:flex;flex-direction:column}.lios-user-card{min-width:182px;max-width:262px}.lios-user-card .user-info{display:flex;margin-bottom:12px}.lios-user-card .user-info .author{width:72px;height:72px;border-radius:50%;background:rgba(255,255,255,0.3);margin-right:12px}.lios-user-card .user-info .user-info-right{flex:1}.lios-user-card .user-info .name{display:inline-block;margin-top:18px}.lios-user-card .user-info .role-list{font-size:12px;line-height:16px;margin-top:4px}.lios-user-card .user-info .role-list .role-item{background:rgba(204,204,204,0.55);padding:2px 8px;border-radius:8px;display:inline-block;margin-right:4px;margin-bottom:4px}.lios-user-card .lios-tenant{margin-bottom:12px}.lios-user-card .lios-tenant .tenant-label{font-size:12px;color:rgba(0,0,0,0.65)}.lios-user-card .lios-tenant .tenant-switch{display:flex}.lios-user-card .lios-tenant .tenant-switch .tenant-value{flex:1;font-size:14px;color:rgba(0,0,0,0.85)}.lios-user-card .lios-tenant .tenant-switch .tenant-icon{width:40px;text-align:center;color:rgba(0,0,0,0.45);display:flex;justify-content:center;align-items:center}.lios-user-card .lios-tenant .tenant-switch .tenant-icon:hover{cursor:pointer;color:rgba(0,0,0,0.85)}.lios-user-card .lios-logout{cursor:pointer;display:flex;justify-content:center;align-items:center;color:rgba(0,0,0,0.45);border-radius:4px;transition:background .3s;padding:4px}.lios-user-card .lios-logout:hover{background:rgba(0,0,0,0.08)}.lios-user-card .lios-logout .logout-icon{width:16px;height:16px;margin-right:8px}.app-list-other .product-list-item{display:flex;justify-content:flex-start;align-items:center;margin:8px 0;padding:6px 12px;cursor:pointer;border-radius:4px;transition:all .3s;color:rgba(0,0,0,0.65)}.app-list-other .product-list-item:hover{background:rgba(22,119,255,0.08);color:rgba(22,119,255,0.8)}.app-list-other .product-list-item img{width:32px;height:32px;margin-right:12px}.app-list-other .current-product{color:#1677FF !important}
|
|
2
|
-
|