cfel-base-components 0.0.24 → 1.0.0
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/README.md +1 -1
- package/config/webpack.base.js +11 -2
- package/demo/src/index.html +0 -26
- package/demo/src/index.jsx +11 -27
- package/demo/src/index.module.less +3 -0
- package/demo/src/index.scss +2 -59
- package/package.json +4 -5
- package/src/components/base-component/PageContainer/index.module.less +13 -0
- package/src/components/base-component/PageContainer/index.tsx +28 -0
- package/src/components/base-component/Pagination/index.tsx +22 -0
- package/src/components/base-component/ProTable/index.tsx +29 -0
- package/src/components/base-component/QueryFilter/index.tsx +24 -0
- package/src/components/layout/index.scss +1 -1
- package/src/components/universal-pages/account/index.tsx +54 -0
- package/src/components/universal-pages/accountInfo/index.tsx +98 -0
- package/src/components/universal-pages/role/index.tsx +53 -0
- package/src/components/{roleInfo → universal-pages/roleInfo}/EditAccountDrawer/index.tsx +0 -1
- package/src/components/universal-pages/roleInfo/index.scss +3 -0
- package/src/components/universal-pages/roleInfo/index.tsx +94 -0
- package/src/index.d.ts +8 -1
- package/src/index.tsx +10 -17
- package/.vscode/settings.json +0 -3
- package/src/.umi/core/helmet.ts +0 -10
- package/src/.umi/core/helmetContext.ts +0 -4
- package/src/apiRequest/config.ts +0 -71
- package/src/apiRequest/hosts.ts +0 -6
- package/src/apiRequest/iotConfig.ts +0 -71
- package/src/components/PageContainer/index.scss +0 -13
- package/src/components/PageContainer/index.tsx +0 -22
- package/src/components/Pagination/index.tsx +0 -20
- package/src/components/ProTable/index.tsx +0 -22
- package/src/components/QueryFilter/index.tsx +0 -20
- package/src/components/account/api.ts +0 -11
- package/src/components/account/index.tsx +0 -169
- package/src/components/accountInfo/api.ts +0 -26
- package/src/components/accountInfo/index.tsx +0 -229
- package/src/components/button/index.tsx +0 -16
- package/src/components/role/api.ts +0 -9
- package/src/components/role/index.scss +0 -0
- package/src/components/role/index.tsx +0 -141
- package/src/components/roleInfo/api.ts +0 -22
- package/src/components/roleInfo/index.scss +0 -3
- package/src/components/roleInfo/index.tsx +0 -239
- package/src/components/widthAutoLabelProps/index.tsx +0 -54
- package/src/hooks/useTableHooks.ts +0 -60
- package/src/utils/index.ts +0 -29
- /package/src/components/{Pagination/index.scss → base-component/Pagination/index.module.less} +0 -0
- /package/src/components/{ProTable/index.scss → base-component/ProTable/index.module.less} +0 -0
- /package/src/components/{QueryFilter/index.scss → base-component/QueryFilter/index.module.less} +0 -0
- /package/src/components/{account → universal-pages/account}/index.scss +0 -0
- /package/src/components/{accountInfo → universal-pages/accountInfo}/EditAccountDrawer/index.tsx +0 -0
- /package/src/components/{accountInfo → universal-pages/accountInfo}/index.scss +0 -0
- /package/src/components/{button → universal-pages/role}/index.scss +0 -0
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import useTableHooks from "../../hooks/useTableHooks"
|
|
3
|
-
import Pagecontainer from '../PageContainer';
|
|
4
|
-
import ProTable from '../ProTable';
|
|
5
|
-
import Pagination from '../Pagination';
|
|
6
|
-
import { get } from 'lodash';
|
|
7
|
-
import { Modal, Button, Divider, Descriptions, Space, message, Avatar } from 'antd';
|
|
8
|
-
import { UserOutlined } from '@ant-design/icons';
|
|
9
|
-
import EditAccountDrawer from './EditAccountDrawer/index'
|
|
10
|
-
import { timeFormatter, getUrlParams } from '../../utils';
|
|
11
|
-
import {
|
|
12
|
-
getAccount,
|
|
13
|
-
pageBoundRoles,
|
|
14
|
-
queryBoundRoles,
|
|
15
|
-
rolelistRole,
|
|
16
|
-
accountBoundRoles,
|
|
17
|
-
accountUnboundRoles
|
|
18
|
-
} from './api'
|
|
19
|
-
import "./index.scss"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
177
|
-
return (
|
|
178
|
-
<Pagecontainer>
|
|
179
|
-
<Divider orientation="left">
|
|
180
|
-
<Avatar
|
|
181
|
-
style={{ backgroundColor: '#1677ff', marginRight: '8px' }}
|
|
182
|
-
draggable={false}
|
|
183
|
-
icon={<UserOutlined />}
|
|
184
|
-
src={!!accountInfo.avatar ? accountInfo.avatar : undefined}
|
|
185
|
-
/>
|
|
186
|
-
{accountInfo?.name || ''}
|
|
187
|
-
</Divider>
|
|
188
|
-
<Descriptions className='basicInfoWrap'>
|
|
189
|
-
<Descriptions.Item label="账号">{accountInfo?.account || ''}</Descriptions.Item>
|
|
190
|
-
<Descriptions.Item label="员工工号">{accountInfo?.jobNumber || ''}</Descriptions.Item>
|
|
191
|
-
<Descriptions.Item label="名称">{accountInfo?.name || ''}</Descriptions.Item>
|
|
192
|
-
<Descriptions.Item label="手机号">{accountInfo?.mobile || ''}</Descriptions.Item>
|
|
193
|
-
<Descriptions.Item label="邮箱">{accountInfo?.email || ''}</Descriptions.Item>
|
|
194
|
-
<Descriptions.Item label="是否企业管理员">{accountInfo?.isAdmin ? '是' : '否'}</Descriptions.Item>
|
|
195
|
-
<Descriptions.Item label="创建时间">{timeFormatter(accountInfo?.gmtCreate)}</Descriptions.Item>
|
|
196
|
-
<Descriptions.Item label="修改时间">{timeFormatter(accountInfo?.gmtModified)}</Descriptions.Item>
|
|
197
|
-
</Descriptions>
|
|
198
|
-
|
|
199
|
-
<ProTable
|
|
200
|
-
headerTitle={"绑定的角色"}
|
|
201
|
-
dataSource={dataList}
|
|
202
|
-
loading={isLoading}
|
|
203
|
-
columns={columns}
|
|
204
|
-
rowKey="id"
|
|
205
|
-
options={{
|
|
206
|
-
reload: handleRoload
|
|
207
|
-
}}
|
|
208
|
-
toolBarRender={() => {
|
|
209
|
-
return [
|
|
210
|
-
<Button type="primary" onClick={(() => {
|
|
211
|
-
getQueryBoundRolesFunc()
|
|
212
|
-
})}>绑定</Button>
|
|
213
|
-
];
|
|
214
|
-
}}
|
|
215
|
-
/>
|
|
216
|
-
<Pagination {...pagination} />
|
|
217
|
-
|
|
218
|
-
<EditAccountDrawer
|
|
219
|
-
open={editAccountOpen} // 状态
|
|
220
|
-
editOpenStatus={setEditAccountOpen} //修改弹框显隐事件
|
|
221
|
-
rolelistRoleData={rolelistRoleData} //总角色
|
|
222
|
-
roleCheckData={roleCheckData} //当前角色选中数据
|
|
223
|
-
isBoundRolesFunc={isBoundRolesFunc}
|
|
224
|
-
></EditAccountDrawer>
|
|
225
|
-
</Pagecontainer>
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
import "./index.scss"
|
|
3
|
-
interface WidthAutoLabelProps {
|
|
4
|
-
children: string; // 要绘制的文本
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 文本宽度自适应标签组件
|
|
9
|
-
* @param props
|
|
10
|
-
* @constructor
|
|
11
|
-
*/
|
|
12
|
-
const Button = (props: WidthAutoLabelProps) => {
|
|
13
|
-
return <div className='aaa-button'>123</div>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default Button;
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
File without changes
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
import useTableHooks from "../../hooks/useTableHooks"
|
|
3
|
-
|
|
4
|
-
import PageContainer from '../PageContainer';
|
|
5
|
-
import QueryFilter from '../QueryFilter';
|
|
6
|
-
import ProTable from '../ProTable';
|
|
7
|
-
import Pagination from '../Pagination';
|
|
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
|
-
|
|
15
|
-
import "./index.scss"
|
|
16
|
-
export interface RoleProps {
|
|
17
|
-
historyAction: any;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default function Role({
|
|
21
|
-
historyAction
|
|
22
|
-
}:RoleProps) {
|
|
23
|
-
const searchFormRef: any = useRef()
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
init()
|
|
27
|
-
execute()
|
|
28
|
-
}, [])
|
|
29
|
-
|
|
30
|
-
const init = () => {
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const columns: any = [
|
|
34
|
-
{
|
|
35
|
-
title: '角色名称',
|
|
36
|
-
dataIndex: 'roleName',
|
|
37
|
-
key: 'roleName',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
title: '角色编码',
|
|
41
|
-
dataIndex: 'roleCode',
|
|
42
|
-
key: 'roleCode',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
title: '角色描述',
|
|
46
|
-
dataIndex: 'description',
|
|
47
|
-
key: 'description',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
title: '创建时间',
|
|
51
|
-
dataIndex: 'gmtCreate',
|
|
52
|
-
key: 'gmtCreate',
|
|
53
|
-
render: (cell: any) => {
|
|
54
|
-
return timeFormatter(cell)
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
title: '更新时间',
|
|
59
|
-
dataIndex: 'gmtModified',
|
|
60
|
-
key: 'gmtModified',
|
|
61
|
-
render: (cell: any) => {
|
|
62
|
-
return timeFormatter(cell)
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
title: '操作',
|
|
67
|
-
width: 80,
|
|
68
|
-
fixed: "right",
|
|
69
|
-
render: (rowdata: any,) => <Space>
|
|
70
|
-
<a onClick={() => {
|
|
71
|
-
historyAction?.push({
|
|
72
|
-
pathname: `/role-info`,
|
|
73
|
-
search: `?roleCode=${rowdata.roleCode}`,
|
|
74
|
-
});
|
|
75
|
-
}}>赋予账号</a>
|
|
76
|
-
</Space>
|
|
77
|
-
},
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
const handleOnReset: any = async (values: any) => {
|
|
81
|
-
searchFormRef.current = { ...values }
|
|
82
|
-
execute({
|
|
83
|
-
innerPageNo: 1,
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const handleOnFinish: any = async (values: any) => {
|
|
88
|
-
searchFormRef.current = { ...values }
|
|
89
|
-
execute()
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const readDataList = ({
|
|
93
|
-
innerPageNo,
|
|
94
|
-
innerPageSize,
|
|
95
|
-
}: any) => {
|
|
96
|
-
return pageRequest({
|
|
97
|
-
currentPage: innerPageNo,
|
|
98
|
-
pageSize: innerPageSize,
|
|
99
|
-
...searchFormRef.current
|
|
100
|
-
}).then((res: any) => {
|
|
101
|
-
let records = get(res, "records", [])
|
|
102
|
-
let total = get(res, "total", 0)
|
|
103
|
-
return {
|
|
104
|
-
dataList: records,
|
|
105
|
-
totalCount: total
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const { execute, dataList, isLoading, pagination } = useTableHooks({
|
|
111
|
-
asyncFunction: readDataList
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
const handleRoload = () => {
|
|
115
|
-
execute()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<PageContainer >
|
|
120
|
-
<QueryFilter
|
|
121
|
-
onReset={handleOnReset}
|
|
122
|
-
onFinish={handleOnFinish}
|
|
123
|
-
>
|
|
124
|
-
<ProFormText name="roleName" label="角色名称" />
|
|
125
|
-
</QueryFilter>
|
|
126
|
-
|
|
127
|
-
<ProTable
|
|
128
|
-
headerTitle={"角色列表"}
|
|
129
|
-
dataSource={dataList}
|
|
130
|
-
loading={isLoading}
|
|
131
|
-
columns={columns}
|
|
132
|
-
rowKey="id"
|
|
133
|
-
options={{
|
|
134
|
-
reload: handleRoload
|
|
135
|
-
}}
|
|
136
|
-
/>
|
|
137
|
-
<Pagination {...pagination} />
|
|
138
|
-
|
|
139
|
-
</PageContainer >
|
|
140
|
-
)
|
|
141
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
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,239 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import useTableHooks from "../../hooks/useTableHooks"
|
|
3
|
-
|
|
4
|
-
import PageContainer from '../PageContainer';
|
|
5
|
-
import QueryFilter from '../QueryFilter';
|
|
6
|
-
import ProTable from '../ProTable';
|
|
7
|
-
import Pagination from '../Pagination';
|
|
8
|
-
import { get } from 'lodash';
|
|
9
|
-
import { ProFormText, } from '@ant-design/pro-components';
|
|
10
|
-
import { Button, Divider, Modal, Descriptions, Space, message } from 'antd';
|
|
11
|
-
import EditAccountDrawer from './EditAccountDrawer/index'
|
|
12
|
-
import { timeFormatter, getUrlParams } from '../../utils';
|
|
13
|
-
import {
|
|
14
|
-
pageBoundAccounts,
|
|
15
|
-
roleBoundAccounts,
|
|
16
|
-
roleUnboundAccounts,
|
|
17
|
-
getRole,
|
|
18
|
-
queryByKeyword
|
|
19
|
-
} from './api'
|
|
20
|
-
import "./index.scss"
|
|
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
|
-
}
|
|
193
|
-
return(
|
|
194
|
-
<PageContainer>
|
|
195
|
-
<Divider orientation="left">{roleInfo?.roleName || "-"}</Divider>
|
|
196
|
-
<Descriptions className="basicInfoWrap">
|
|
197
|
-
<Descriptions.Item label="角色名称">{roleInfo?.roleName || ''}</Descriptions.Item>
|
|
198
|
-
<Descriptions.Item label="角色编码">{roleInfo?.roleCode || ''}</Descriptions.Item>
|
|
199
|
-
<Descriptions.Item label="角色描述">{roleInfo?.description || ''}</Descriptions.Item>
|
|
200
|
-
<Descriptions.Item label="创建时间">{timeFormatter(roleInfo?.gmtCreate) || ''}</Descriptions.Item>
|
|
201
|
-
<Descriptions.Item label="更新时间">{timeFormatter(roleInfo?.gmtModified) || ''}</Descriptions.Item>
|
|
202
|
-
</Descriptions>
|
|
203
|
-
|
|
204
|
-
<QueryFilter
|
|
205
|
-
onReset={handleOnReset}
|
|
206
|
-
onFinish={handleOnFinish}
|
|
207
|
-
>
|
|
208
|
-
<ProFormText name="keyword" label="关键词" />
|
|
209
|
-
</QueryFilter>
|
|
210
|
-
|
|
211
|
-
<ProTable
|
|
212
|
-
headerTitle={"角色下绑定的账号"}
|
|
213
|
-
dataSource={dataList}
|
|
214
|
-
loading={isLoading}
|
|
215
|
-
columns={columns}
|
|
216
|
-
rowKey="id"
|
|
217
|
-
options={{
|
|
218
|
-
reload: handleRoload
|
|
219
|
-
}}
|
|
220
|
-
toolBarRender={() => {
|
|
221
|
-
return [
|
|
222
|
-
<Button type="primary" onClick={(() => {
|
|
223
|
-
getQueryBoundRolesFunc()
|
|
224
|
-
})}>添加账号</Button>
|
|
225
|
-
];
|
|
226
|
-
}}
|
|
227
|
-
/>
|
|
228
|
-
|
|
229
|
-
<Pagination {...pagination} />
|
|
230
|
-
<EditAccountDrawer
|
|
231
|
-
open={editAccountOpen} // 状态
|
|
232
|
-
editOpenStatus={setEditAccountOpen} //修改弹框显隐事件
|
|
233
|
-
roleBoundAccountsFunc={roleBoundAccountsFunc}
|
|
234
|
-
queryByKeywordFunc={queryByKeywordFunc} //搜索事件
|
|
235
|
-
></EditAccountDrawer>
|
|
236
|
-
|
|
237
|
-
</PageContainer>
|
|
238
|
-
)
|
|
239
|
-
};
|