cfel-base-components 2.5.12 → 2.5.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/.vscode/settings.json +3 -0
- package/demo/src/index.html +4 -3
- package/package.json +1 -1
- package/src/.umi/core/helmet.ts +10 -0
- package/src/.umi/core/helmetContext.ts +4 -0
- package/src/apiRequest/config.ts +2 -2
- package/src/components/layout/index.tsx +14 -4
- package/src/components/layout/user-card/index.scss +31 -8
- package/src/components/layout/user-card/index.tsx +79 -91
- package/src/components/universal-pages/cpcAccount/AddModal/index.tsx +307 -123
- package/src/components/universal-pages/cpcAccount/EditNameModal/index.tsx +97 -0
- package/src/components/universal-pages/cpcAccount/ResetModal/index.tsx +240 -0
- package/src/components/universal-pages/cpcAccount/api.ts +35 -15
- package/src/components/universal-pages/cpcAccount/index.tsx +149 -97
- package/src/components/universal-pages/cpcAccountInfo/index.tsx +3 -1
- package/src/components/universal-pages/cpcRole/AddModal/index.tsx +1 -1
- package/src/components/universal-pages/cpcRole/index.tsx +101 -99
- package/src/components/universal-pages/cpcRoleInfo/index.tsx +16 -29
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
-
import useTableHooks from "../../../hooks/useTableHooks"
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
3
2
|
|
|
4
3
|
import PageContainer from '../../base-component/PageContainer';
|
|
5
4
|
import QueryFilter from '../../base-component/QueryFilter';
|
|
6
5
|
import ProTable from '../../base-component/ProTable';
|
|
7
6
|
import Pagination from '../../base-component/Pagination';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import useTableHooks from "../../../hooks/useTableHooks"
|
|
8
|
+
|
|
9
|
+
import { timeFormatter, getUrlParams } from '../../../utils';
|
|
10
|
+
import { get } from 'lodash'
|
|
11
|
+
import { Space, Button, message, Modal, Popover } from 'antd'
|
|
12
|
+
import { pageRequest, create, remove, update } from './api'
|
|
13
|
+
|
|
14
|
+
import { ProFormText } from '@ant-design/pro-components'
|
|
15
15
|
|
|
16
|
-
import { ProFormText, } from '@ant-design/pro-components';
|
|
17
|
-
import { timeFormatter } from '../../../utils';
|
|
18
16
|
import AddModal from './AddModal'
|
|
19
|
-
import
|
|
17
|
+
import './index.scss'
|
|
20
18
|
export interface RoleProps {
|
|
21
|
-
historyAction: any
|
|
19
|
+
historyAction: any
|
|
22
20
|
}
|
|
23
|
-
export default function Role({
|
|
24
|
-
historyAction
|
|
25
|
-
}: RoleProps) {
|
|
21
|
+
export default function Role({ historyAction }: RoleProps) {
|
|
26
22
|
const searchFormRef: any = useRef()
|
|
27
23
|
|
|
28
24
|
const [ModalOpen, setModalOpen] = useState(false)
|
|
29
|
-
const [editingData, setEditingData] = useState(null)
|
|
25
|
+
const [editingData, setEditingData] = useState(null) //编辑数据
|
|
30
26
|
useEffect(() => {
|
|
31
27
|
init()
|
|
32
28
|
execute()
|
|
33
29
|
}, [])
|
|
34
30
|
|
|
35
|
-
const init = () => {
|
|
36
|
-
}
|
|
31
|
+
const init = () => {}
|
|
37
32
|
|
|
38
33
|
const columns: any = [
|
|
39
34
|
{
|
|
@@ -43,37 +38,37 @@ export default function Role({
|
|
|
43
38
|
render: (text: any, data: any) => {
|
|
44
39
|
return (
|
|
45
40
|
<span
|
|
46
|
-
style={{ cursor:
|
|
41
|
+
style={{ cursor: 'pointer', color: '#1677ff' }}
|
|
47
42
|
onClick={() => {
|
|
48
43
|
historyAction?.push({
|
|
49
44
|
pathname: `/role-info`,
|
|
50
|
-
search: `?roleCode=${data.roleCode}
|
|
51
|
-
})
|
|
45
|
+
search: `?roleCode=${data.roleCode}`
|
|
46
|
+
})
|
|
52
47
|
}}
|
|
53
48
|
>
|
|
54
49
|
{data?.roleName}
|
|
55
50
|
</span>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
51
|
+
)
|
|
52
|
+
}
|
|
58
53
|
},
|
|
59
54
|
{
|
|
60
55
|
title: '角色编码',
|
|
61
56
|
dataIndex: 'roleCode',
|
|
62
|
-
key: 'roleCode'
|
|
57
|
+
key: 'roleCode'
|
|
63
58
|
},
|
|
64
59
|
{
|
|
65
|
-
title:
|
|
66
|
-
dataIndex:
|
|
67
|
-
key:
|
|
60
|
+
title: '来源',
|
|
61
|
+
dataIndex: 'source',
|
|
62
|
+
key: 'source',
|
|
68
63
|
render: (cell: any) => {
|
|
69
|
-
if (cell
|
|
70
|
-
return
|
|
71
|
-
} else if (cell
|
|
72
|
-
return
|
|
73
|
-
} else{
|
|
74
|
-
return
|
|
64
|
+
if (cell === 'system') {
|
|
65
|
+
return '系统创建'
|
|
66
|
+
} else if (cell === 'user') {
|
|
67
|
+
return '用户自建'
|
|
68
|
+
} else {
|
|
69
|
+
return '未知'
|
|
75
70
|
}
|
|
76
|
-
}
|
|
71
|
+
}
|
|
77
72
|
},
|
|
78
73
|
{
|
|
79
74
|
title: '角色描述',
|
|
@@ -115,41 +110,53 @@ export default function Role({
|
|
|
115
110
|
{
|
|
116
111
|
title: '操作',
|
|
117
112
|
width: 180,
|
|
118
|
-
fixed:
|
|
119
|
-
render: (rowdata: any
|
|
120
|
-
|
|
121
|
-
rowdata.source !==
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
113
|
+
fixed: 'right',
|
|
114
|
+
render: (rowdata: any) => (
|
|
115
|
+
<Space>
|
|
116
|
+
{rowdata.source !== 'system' && (
|
|
117
|
+
<a
|
|
118
|
+
onClick={() => {
|
|
119
|
+
setEditingData(rowdata)
|
|
120
|
+
setModalOpen(true)
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
编辑
|
|
124
|
+
</a>
|
|
125
|
+
)}
|
|
126
|
+
<a
|
|
127
|
+
onClick={() => {
|
|
128
|
+
historyAction?.push({
|
|
129
|
+
pathname: `/role-info`,
|
|
130
|
+
search: `?roleCode=${rowdata.roleCode}`
|
|
131
|
+
})
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
配置
|
|
135
|
+
</a>
|
|
136
|
+
{rowdata.source !== 'system' && (
|
|
137
|
+
<a
|
|
138
|
+
onClick={() => {
|
|
139
|
+
Modal.confirm({
|
|
140
|
+
title: `确认删除${rowdata?.roleName}吗?`,
|
|
141
|
+
content: '',
|
|
142
|
+
onOk: () => {
|
|
143
|
+
DeleteFunc(rowdata?.roleCode)
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
删除
|
|
149
|
+
</a>
|
|
150
|
+
)}
|
|
151
|
+
</Space>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
]
|
|
148
155
|
|
|
149
156
|
const handleOnReset: any = async (values: any) => {
|
|
150
157
|
searchFormRef.current = { ...values }
|
|
151
158
|
execute({
|
|
152
|
-
innerPageNo: 1
|
|
159
|
+
innerPageNo: 1
|
|
153
160
|
})
|
|
154
161
|
}
|
|
155
162
|
|
|
@@ -158,17 +165,14 @@ export default function Role({
|
|
|
158
165
|
execute()
|
|
159
166
|
}
|
|
160
167
|
|
|
161
|
-
const readDataList = ({
|
|
162
|
-
innerPageNo,
|
|
163
|
-
innerPageSize,
|
|
164
|
-
}: any) => {
|
|
168
|
+
const readDataList = ({ innerPageNo, innerPageSize }: any) => {
|
|
165
169
|
return pageRequest({
|
|
166
170
|
currentPage: innerPageNo,
|
|
167
171
|
pageSize: innerPageSize,
|
|
168
172
|
...searchFormRef.current
|
|
169
173
|
}).then((res: any) => {
|
|
170
|
-
let records = get(res,
|
|
171
|
-
let total = get(res,
|
|
174
|
+
let records = get(res, 'records', [])
|
|
175
|
+
let total = get(res, 'total', 0)
|
|
172
176
|
return {
|
|
173
177
|
...res,
|
|
174
178
|
dataList: records,
|
|
@@ -191,63 +195,61 @@ export default function Role({
|
|
|
191
195
|
}
|
|
192
196
|
|
|
193
197
|
const actionFunc = (data: any, type: string) => {
|
|
194
|
-
return
|
|
195
|
-
message.success(`${type
|
|
198
|
+
return (type === 'add' ? create : update)({ ...data }).then((res: any) => {
|
|
199
|
+
message.success(`${type === 'add' ? '新增' : '更新'}成功`)
|
|
196
200
|
setModalOpen(false)
|
|
197
201
|
setEditingData(null)
|
|
198
202
|
execute()
|
|
199
203
|
})
|
|
200
204
|
}
|
|
201
|
-
const DeleteFunc = (roleCode:any)=>{
|
|
205
|
+
const DeleteFunc = (roleCode: any) => {
|
|
202
206
|
remove({
|
|
203
|
-
roleCode
|
|
207
|
+
roleCode
|
|
204
208
|
}).then((res: any) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
+
message.success('删除成功')
|
|
210
|
+
execute()
|
|
211
|
+
})
|
|
212
|
+
}
|
|
209
213
|
return (
|
|
210
|
-
<PageContainer
|
|
211
|
-
<QueryFilter
|
|
212
|
-
|
|
213
|
-
onFinish={handleOnFinish}
|
|
214
|
-
>
|
|
215
|
-
<ProFormText name="roleName" label="角色名称" />
|
|
214
|
+
<PageContainer>
|
|
215
|
+
<QueryFilter onReset={handleOnReset} onFinish={handleOnFinish}>
|
|
216
|
+
<ProFormText name='roleName' label='角色名称' />
|
|
216
217
|
</QueryFilter>
|
|
217
218
|
|
|
218
219
|
<ProTable
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
columnsState={{
|
|
221
|
+
persistenceKey: 'base_cpcRole',
|
|
222
|
+
persistenceType: 'localStorage'
|
|
223
|
+
}}
|
|
223
224
|
toolBarRender={() => {
|
|
224
225
|
return [
|
|
225
226
|
<Button
|
|
226
|
-
|
|
227
|
+
key='add'
|
|
228
|
+
type='primary'
|
|
227
229
|
onClick={() => {
|
|
228
230
|
setModalOpen(true)
|
|
229
231
|
}}
|
|
230
232
|
>
|
|
231
233
|
新增角色
|
|
232
|
-
</Button
|
|
233
|
-
]
|
|
234
|
+
</Button>
|
|
235
|
+
]
|
|
234
236
|
}}
|
|
235
|
-
headerTitle={
|
|
237
|
+
headerTitle={'角色列表'}
|
|
236
238
|
dataSource={dataList}
|
|
237
239
|
loading={isLoading}
|
|
238
240
|
columns={columns}
|
|
239
|
-
rowKey=
|
|
241
|
+
rowKey='id'
|
|
240
242
|
options={{
|
|
241
243
|
reload: handleRoload
|
|
242
244
|
}}
|
|
243
245
|
/>
|
|
244
|
-
<Pagination
|
|
246
|
+
<Pagination {...pagination} />
|
|
245
247
|
<AddModal
|
|
246
248
|
ModalOpen={ModalOpen}
|
|
247
249
|
editOpenStatus={setModalOpenFunc} //修改状态事件
|
|
248
250
|
editingData={editingData} //当前数据
|
|
249
|
-
actionFunc={actionFunc}//事件
|
|
251
|
+
actionFunc={actionFunc} //事件
|
|
250
252
|
/>
|
|
251
|
-
</PageContainer
|
|
253
|
+
</PageContainer>
|
|
252
254
|
)
|
|
253
|
-
}
|
|
255
|
+
}
|
|
@@ -86,22 +86,7 @@ export default function RoleInfo({
|
|
|
86
86
|
dataIndex: 'account',
|
|
87
87
|
key: 'account'
|
|
88
88
|
},
|
|
89
|
-
|
|
90
|
-
title: '工号',
|
|
91
|
-
dataIndex: 'jobNumber',
|
|
92
|
-
key: 'jobNumber'
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title: '手机号',
|
|
96
|
-
dataIndex: 'mobile',
|
|
97
|
-
key: 'mobile'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
title: '邮箱',
|
|
101
|
-
dataIndex: 'email',
|
|
102
|
-
key: 'email',
|
|
103
|
-
copyable: true
|
|
104
|
-
},
|
|
89
|
+
|
|
105
90
|
{
|
|
106
91
|
title: '是否主账号',
|
|
107
92
|
dataIndex: 'isAdmin',
|
|
@@ -136,20 +121,22 @@ export default function RoleInfo({
|
|
|
136
121
|
fixed: 'right',
|
|
137
122
|
render: (rowdata: any) => (
|
|
138
123
|
<Space>
|
|
124
|
+
{rowdata?.isAdmin && roleInfo?.roleCode === 'admin' ? null : (
|
|
139
125
|
<a
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
126
|
+
onClick={() => {
|
|
127
|
+
Modal.confirm({
|
|
128
|
+
title: '确认解绑吗?',
|
|
129
|
+
content: '',
|
|
130
|
+
onOk: () => {
|
|
131
|
+
roleUnboundAccountsFunc(rowdata.id)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
解绑
|
|
137
|
+
</a>
|
|
138
|
+
)}
|
|
139
|
+
</Space>
|
|
153
140
|
)
|
|
154
141
|
}
|
|
155
142
|
]
|