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,132 +1,316 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from 'antd';
|
|
5
|
-
export default function index({
|
|
6
|
-
ModalOpen, //弹框状态
|
|
7
|
-
editOpenStatus, //关闭弹框
|
|
8
|
-
editingData, //编辑数据
|
|
9
|
-
actionFunc, //新增事件
|
|
10
|
-
}: any) {
|
|
11
|
-
const [form] = Form.useForm();
|
|
12
|
-
|
|
2
|
+
import { Button, Modal, Form, Input, Radio, Space, message, Alert } from 'antd'
|
|
3
|
+
let timeChange: any
|
|
13
4
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
export default function Index({
|
|
6
|
+
ModalOpen, //弹框状态
|
|
7
|
+
editOpenStatus, //关闭弹框
|
|
8
|
+
editingData, //编辑数据
|
|
9
|
+
actionFunc, //新增事件
|
|
10
|
+
accountGetAccountPasswordFunc //复制
|
|
11
|
+
}: any) {
|
|
12
|
+
const [form] = Form.useForm()
|
|
13
|
+
const [passwordType, setPasswordType] = useState('server')
|
|
14
|
+
const [loading, setLoading] = useState(false)
|
|
15
|
+
const [disabledType, setDisabledType] = useState(true)
|
|
16
|
+
const [secondNum, setSecondNum]: any = useState(null) //秒数
|
|
17
|
+
const [showText, setShowText] = useState('')
|
|
18
|
+
const formDom = [
|
|
19
|
+
{ title: '名称', key: 'name', type: 'string', required: true, maxLength: 15, showCount: true },
|
|
20
|
+
{
|
|
21
|
+
title: '账号',
|
|
22
|
+
key: 'account',
|
|
23
|
+
type: 'account',
|
|
24
|
+
required: true,
|
|
25
|
+
maxLength: 12,
|
|
26
|
+
showCount: true
|
|
27
|
+
},
|
|
28
|
+
{ title: '密码', key: 'passwordType', type: 'psw', required: true },
|
|
29
|
+
{ title: ' ', key: 'password', type: 'pswDiy', required: true },
|
|
30
|
+
{ title: '手机号', key: 'mobile', type: 'mobileint', required: false },
|
|
31
|
+
{ title: '邮箱', key: 'email', type: 'emailstring', required: false }
|
|
32
|
+
]
|
|
33
|
+
const editFormDom = [
|
|
34
|
+
{ title: '名称', key: 'name', type: 'rString', required: false },
|
|
35
|
+
{ title: '账号', key: 'account', type: 'rAccountString', required: false },
|
|
36
|
+
{ title: '密码', key: 'passwordType', type: 'rPswString', required: false },
|
|
37
|
+
{ title: '手机号', key: 'mobile', type: 'rString', required: false },
|
|
38
|
+
{ title: '邮箱', key: 'email', type: 'rString', required: false }
|
|
39
|
+
]
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
clearInterval(timeChange)
|
|
42
|
+
return () => {
|
|
43
|
+
clearInterval(timeChange)
|
|
44
|
+
}
|
|
45
|
+
}, [])
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!editingData) return
|
|
48
|
+
init()
|
|
49
|
+
}, [editingData])
|
|
50
|
+
const init = () => {
|
|
51
|
+
setLoading(false)
|
|
52
|
+
setDisabledType(true)
|
|
53
|
+
setShowText('关闭(4s)')
|
|
54
|
+
timeChange = setInterval(
|
|
55
|
+
() =>
|
|
56
|
+
setSecondNum((t: any) => {
|
|
57
|
+
let num = t
|
|
58
|
+
console.log(t, 't')
|
|
59
|
+
return --num
|
|
60
|
+
}),
|
|
61
|
+
1000
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
console.log(secondNum, 'secondNum')
|
|
66
|
+
if (secondNum > 0 && secondNum <= 3) {
|
|
67
|
+
setShowText(`关闭(${secondNum}s)`)
|
|
68
|
+
} else {
|
|
69
|
+
clearInterval(timeChange)
|
|
70
|
+
setSecondNum(4)
|
|
71
|
+
setDisabledType(false)
|
|
72
|
+
setShowText('关闭')
|
|
73
|
+
}
|
|
74
|
+
}, [secondNum])
|
|
21
75
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
76
|
+
const showCom = ({ title, key, type, required, maxLength, showCount }: any) => {
|
|
77
|
+
let dom: any = null
|
|
78
|
+
switch (type) {
|
|
79
|
+
case 'rString':
|
|
80
|
+
dom = <Form.Item label={title}>{editingData[key]}</Form.Item>
|
|
81
|
+
break
|
|
82
|
+
case 'rAccountString':
|
|
83
|
+
dom = (
|
|
84
|
+
<Form.Item label={title}>
|
|
85
|
+
{editingData[key]}{' '}
|
|
86
|
+
<a
|
|
87
|
+
onClick={() => {
|
|
88
|
+
message.success('复制成功')
|
|
89
|
+
navigator.clipboard.writeText(editingData[key])
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
复制
|
|
93
|
+
</a>
|
|
94
|
+
</Form.Item>
|
|
95
|
+
)
|
|
96
|
+
break
|
|
29
97
|
|
|
98
|
+
case 'rPswString':
|
|
99
|
+
dom = (
|
|
100
|
+
<Form.Item label={title}>
|
|
101
|
+
<span>
|
|
102
|
+
********** <a onClick={() => copy()}>复制</a>
|
|
103
|
+
</span>
|
|
104
|
+
</Form.Item>
|
|
105
|
+
)
|
|
106
|
+
break
|
|
107
|
+
case 'string':
|
|
108
|
+
dom = (
|
|
109
|
+
<Form.Item label={title} name={key} rules={[{ required: required, message: '请输入' }]}>
|
|
110
|
+
<Input placeholder='请输入' maxLength={maxLength} showCount={showCount} />
|
|
111
|
+
</Form.Item>
|
|
112
|
+
)
|
|
113
|
+
break
|
|
30
114
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
115
|
+
case 'account':
|
|
116
|
+
dom = (
|
|
117
|
+
<Form.Item
|
|
118
|
+
label={title}
|
|
119
|
+
name={key}
|
|
120
|
+
rules={[
|
|
121
|
+
{ required: required, message: '请输入' },
|
|
122
|
+
{ pattern: /^[a-zA-Z0-9]+$/, message: '只能输入英文、数字' }
|
|
123
|
+
]}
|
|
124
|
+
extra=''
|
|
125
|
+
>
|
|
126
|
+
<Input
|
|
127
|
+
placeholder='请输入英文字符或数字'
|
|
128
|
+
addonAfter={`@${(window as any)?.g_config?.tenant?.id}.oncfel.com`}
|
|
129
|
+
maxLength={maxLength}
|
|
130
|
+
showCount={showCount}
|
|
131
|
+
/>
|
|
132
|
+
</Form.Item>
|
|
133
|
+
)
|
|
134
|
+
break
|
|
135
|
+
case 'psw':
|
|
136
|
+
dom = (
|
|
137
|
+
<Form.Item label={title} name={key} rules={[{ required: required, message: '请输入' }]}>
|
|
138
|
+
<Radio.Group>
|
|
139
|
+
<Space
|
|
140
|
+
direction='vertical'
|
|
141
|
+
onChange={(e: any) => {
|
|
142
|
+
setPasswordType(e.target.value)
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
<Radio value='server'>生成随机密码(安全性高)</Radio>
|
|
146
|
+
<Radio value='diy'>自定义密码</Radio>
|
|
147
|
+
</Space>
|
|
148
|
+
</Radio.Group>
|
|
149
|
+
</Form.Item>
|
|
150
|
+
)
|
|
151
|
+
break
|
|
152
|
+
case 'pswDiy':
|
|
153
|
+
dom = passwordType === 'diy' && (
|
|
154
|
+
<Form.Item
|
|
155
|
+
label={null}
|
|
156
|
+
name={key}
|
|
157
|
+
rules={[
|
|
158
|
+
{ required: required, message: '请输入' },
|
|
159
|
+
{
|
|
160
|
+
pattern: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_+{}|]{8,32}$/,
|
|
161
|
+
message: '请输入正确的密码'
|
|
162
|
+
}
|
|
163
|
+
]}
|
|
164
|
+
extra='密码要求至少包含英文字母和数字,字符数8-32位'
|
|
165
|
+
>
|
|
166
|
+
<Input placeholder='请输入' />
|
|
167
|
+
</Form.Item>
|
|
168
|
+
)
|
|
169
|
+
break
|
|
170
|
+
case 'emailstring':
|
|
171
|
+
dom = (
|
|
172
|
+
<Form.Item
|
|
173
|
+
label={title}
|
|
174
|
+
name={key}
|
|
175
|
+
rules={[
|
|
176
|
+
{ required: required, message: '请输入' },
|
|
177
|
+
{
|
|
178
|
+
pattern:
|
|
179
|
+
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
180
|
+
message: '请输入正确的邮箱'
|
|
181
|
+
}
|
|
182
|
+
]}
|
|
183
|
+
>
|
|
184
|
+
<Input placeholder='请输入' />
|
|
185
|
+
</Form.Item>
|
|
186
|
+
)
|
|
187
|
+
break
|
|
188
|
+
case 'mobileint':
|
|
189
|
+
dom = (
|
|
190
|
+
<Form.Item
|
|
191
|
+
label={title}
|
|
192
|
+
name={key}
|
|
193
|
+
rules={[
|
|
194
|
+
{ required: required, message: '请输入' },
|
|
195
|
+
{ pattern: /1[0-9]{10}$/, message: '请输入正确的电话号码' }
|
|
196
|
+
]}
|
|
197
|
+
>
|
|
198
|
+
<Input placeholder='请输入' />
|
|
199
|
+
</Form.Item>
|
|
200
|
+
)
|
|
201
|
+
break
|
|
202
|
+
default:
|
|
203
|
+
break
|
|
73
204
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
205
|
+
return dom
|
|
206
|
+
}
|
|
207
|
+
const copy = () => {
|
|
208
|
+
accountGetAccountPasswordFunc({
|
|
209
|
+
id: editingData?.id
|
|
210
|
+
}).then((res: any) => {
|
|
211
|
+
message.success('复制成功')
|
|
212
|
+
navigator.clipboard.writeText(res)
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
const closeModel = () => {
|
|
216
|
+
form.resetFields()
|
|
217
|
+
editOpenStatus(false)
|
|
218
|
+
}
|
|
219
|
+
const generateRandomString = (minLength = 8, maxLength = 32) => {
|
|
220
|
+
const length = Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength
|
|
221
|
+
const possibleChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
222
|
+
let result = ''
|
|
223
|
+
for (let i = 0; i < length; i++) {
|
|
224
|
+
result += possibleChars.charAt(Math.floor(Math.random() * possibleChars.length))
|
|
78
225
|
}
|
|
226
|
+
return result
|
|
227
|
+
}
|
|
79
228
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
229
|
+
const modelSubmit = () => {
|
|
230
|
+
form.validateFields().then(value => {
|
|
231
|
+
setLoading(true)
|
|
232
|
+
value.account = `${value.account}@${(window as any)?.g_config?.tenant?.id}.oncfel.com`
|
|
233
|
+
if (value.passwordType === 'server') {
|
|
234
|
+
value.password = generateRandomString()
|
|
235
|
+
}
|
|
236
|
+
delete value.passwordType
|
|
237
|
+
actionFunc(value, 'add').then(() => setLoading(false))
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
return (
|
|
241
|
+
<Modal
|
|
242
|
+
title={editingData ? '查看' : '新增账号'}
|
|
243
|
+
destroyOnClose={true}
|
|
244
|
+
open={ModalOpen}
|
|
245
|
+
closable={false}
|
|
246
|
+
footer={
|
|
247
|
+
editingData
|
|
248
|
+
? [
|
|
249
|
+
<Button
|
|
250
|
+
disabled={disabledType}
|
|
251
|
+
key='refresh'
|
|
252
|
+
type='primary'
|
|
253
|
+
onClick={() => {
|
|
254
|
+
closeModel()
|
|
255
|
+
}}
|
|
256
|
+
>
|
|
257
|
+
{showText}
|
|
258
|
+
</Button>
|
|
259
|
+
]
|
|
260
|
+
: [
|
|
261
|
+
<Button
|
|
262
|
+
key='refresh'
|
|
263
|
+
onClick={() => {
|
|
264
|
+
closeModel()
|
|
265
|
+
}}
|
|
266
|
+
>
|
|
267
|
+
取消
|
|
268
|
+
</Button>,
|
|
269
|
+
<Button
|
|
270
|
+
key='submit'
|
|
271
|
+
type='primary'
|
|
272
|
+
loading={loading}
|
|
273
|
+
onClick={() => {
|
|
274
|
+
modelSubmit()
|
|
275
|
+
}}
|
|
276
|
+
>
|
|
277
|
+
确定
|
|
278
|
+
</Button>
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
>
|
|
282
|
+
{editingData && (
|
|
283
|
+
<Alert
|
|
284
|
+
description='新账号初始密码仅可在创建时可复制,请及时保存'
|
|
285
|
+
type='info'
|
|
286
|
+
showIcon
|
|
287
|
+
style={{ marginBottom: '20px' }}
|
|
288
|
+
/>
|
|
289
|
+
)}
|
|
290
|
+
|
|
291
|
+
<Form
|
|
292
|
+
form={form}
|
|
293
|
+
layout={editingData ? 'horizontal' : 'vertical'}
|
|
294
|
+
initialValues={{
|
|
295
|
+
remember: true,
|
|
296
|
+
passwordType: 'server'
|
|
297
|
+
}}
|
|
298
|
+
autoComplete='off'
|
|
299
|
+
>
|
|
300
|
+
{editingData ? (
|
|
301
|
+
<>
|
|
302
|
+
{editFormDom.map((item: any, index: number) => {
|
|
303
|
+
return <div key={index}>{showCom(item)}</div>
|
|
304
|
+
})}
|
|
305
|
+
</>
|
|
306
|
+
) : (
|
|
307
|
+
<>
|
|
308
|
+
{formDom.map((item: any, index: number) => {
|
|
309
|
+
return <div key={index}>{showCom(item)}</div>
|
|
310
|
+
})}
|
|
311
|
+
</>
|
|
312
|
+
)}
|
|
313
|
+
</Form>
|
|
314
|
+
</Modal>
|
|
315
|
+
)
|
|
132
316
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Button, Modal, Form, Input, Radio, Space, message } from 'antd'
|
|
3
|
+
|
|
4
|
+
export default function Index({
|
|
5
|
+
ModalOpen, //弹框状态
|
|
6
|
+
editOpenStatus, //关闭弹框
|
|
7
|
+
editingData, //编辑数据
|
|
8
|
+
actionFunc //新增事件
|
|
9
|
+
}: any) {
|
|
10
|
+
const [form] = Form.useForm()
|
|
11
|
+
const formDom = [
|
|
12
|
+
{ title: '名称', key: 'name', type: 'string', required: true, maxLength: 15, showCount: true }
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!ModalOpen) return
|
|
17
|
+
if (editingData) {
|
|
18
|
+
console.log(editingData, 'editingData')
|
|
19
|
+
form.setFieldsValue({
|
|
20
|
+
...editingData
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
}, [ModalOpen])
|
|
24
|
+
|
|
25
|
+
const showCom = ({ title, key, type, required, maxLength, showCount }: any) => {
|
|
26
|
+
let dom: any = null
|
|
27
|
+
switch (type) {
|
|
28
|
+
case 'string':
|
|
29
|
+
dom = (
|
|
30
|
+
<Form.Item label={title} name={key} rules={[{ required: required, message: '请输入' }]}>
|
|
31
|
+
<Input placeholder='请输入' maxLength={maxLength} showCount={showCount} />
|
|
32
|
+
</Form.Item>
|
|
33
|
+
)
|
|
34
|
+
break
|
|
35
|
+
}
|
|
36
|
+
return dom
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const closeModel = () => {
|
|
40
|
+
form.resetFields()
|
|
41
|
+
editOpenStatus(false)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const modelSubmit = () => {
|
|
45
|
+
form.validateFields().then(value => {
|
|
46
|
+
actionFunc({
|
|
47
|
+
id: editingData?.id,
|
|
48
|
+
name: value?.name,
|
|
49
|
+
account: editingData?.account
|
|
50
|
+
}).then(() => {
|
|
51
|
+
form.resetFields()
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
return (
|
|
56
|
+
<Modal
|
|
57
|
+
title={'修改名称'}
|
|
58
|
+
destroyOnClose={true}
|
|
59
|
+
open={ModalOpen}
|
|
60
|
+
onCancel={() => {
|
|
61
|
+
closeModel()
|
|
62
|
+
}}
|
|
63
|
+
footer={[
|
|
64
|
+
<Button
|
|
65
|
+
key='refresh'
|
|
66
|
+
onClick={() => {
|
|
67
|
+
closeModel()
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
取消
|
|
71
|
+
</Button>,
|
|
72
|
+
<Button
|
|
73
|
+
key='submit'
|
|
74
|
+
type='primary'
|
|
75
|
+
onClick={() => {
|
|
76
|
+
modelSubmit()
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
确定
|
|
80
|
+
</Button>
|
|
81
|
+
]}
|
|
82
|
+
>
|
|
83
|
+
<Form
|
|
84
|
+
form={form}
|
|
85
|
+
layout={'vertical'}
|
|
86
|
+
initialValues={{
|
|
87
|
+
remember: true
|
|
88
|
+
}}
|
|
89
|
+
autoComplete='off'
|
|
90
|
+
>
|
|
91
|
+
{formDom.map((item: any, index: number) => {
|
|
92
|
+
return <div key={index}>{showCom(item)}</div>
|
|
93
|
+
})}
|
|
94
|
+
</Form>
|
|
95
|
+
</Modal>
|
|
96
|
+
)
|
|
97
|
+
}
|