Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d4d90baa
authored
May 12, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更方便地编辑用户额度
parent
391f0404
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
9 deletions
+47
-9
web/src/pages/User/EditUser.js
+47
-9
No files found.
web/src/pages/User/EditUser.js
View file @
d4d90baa
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
useNavigate
}
from
'react-router-dom'
;
import
{
API
,
isMobile
,
showError
,
showSuccess
}
from
'../../helpers'
;
import
{
renderQuotaWithPrompt
}
from
'../../helpers/render'
;
import
{
renderQuota
,
renderQuota
WithPrompt
}
from
'../../helpers/render'
;
import
Title
from
'@douyinfe/semi-ui/lib/es/typography/title'
;
import
{
Button
,
Divider
,
Input
,
Modal
,
Select
,
SideSheet
,
Space
,
...
...
@@ -17,6 +18,8 @@ import {
const
EditUser
=
(
props
)
=>
{
const
userId
=
props
.
editingUser
.
id
;
const
[
loading
,
setLoading
]
=
useState
(
true
);
const
[
addQuotaModalOpen
,
setIsModalOpen
]
=
useState
(
false
);
const
[
addQuotaLocal
,
setAddQuotaLocal
]
=
useState
(
0
);
const
[
inputs
,
setInputs
]
=
useState
({
username
:
''
,
display_name
:
''
,
...
...
@@ -107,6 +110,16 @@ const EditUser = (props) => {
setLoading
(
false
);
};
const
addLocalQuota
=
()
=>
{
let
newQuota
=
parseInt
(
quota
)
+
addQuotaLocal
;
setInputs
((
inputs
)
=>
({
...
inputs
,
quota
:
newQuota
}));
};
const
openAddQuotaModal
=
()
=>
{
setAddQuotaLocal
(
0
);
setIsModalOpen
(
true
);
};
return
(
<>
<
SideSheet
...
...
@@ -192,14 +205,17 @@ const EditUser = (props) => {
<
div
style
=
{{
marginTop
:
20
}}
>
<
Typography
.
Text
>
{
`剩余额度
${
renderQuotaWithPrompt
(
quota
)}
`
}
<
/Typography.Text
>
<
/div
>
<
Input
name
=
'quota'
placeholder
=
{
'请输入新的剩余额度'
}
onChange
=
{(
value
)
=>
handleInputChange
(
'quota'
,
value
)}
value
=
{
quota
}
type
=
{
'number'
}
autoComplete
=
'new-password'
/>
<
Space
>
<
Input
name
=
'quota'
placeholder
=
{
'请输入新的剩余额度'
}
onChange
=
{(
value
)
=>
handleInputChange
(
'quota'
,
value
)}
value
=
{
quota
}
type
=
{
'number'
}
autoComplete
=
'new-password'
/>
<
Button
onClick
=
{
openAddQuotaModal
}
>
添加额度
<
/Button
>
<
/Space
>
<
/
>
)}
<
Divider
style
=
{{
marginTop
:
20
}}
>
以下信息不可修改
<
/Divider
>
...
...
@@ -245,6 +261,28 @@ const EditUser = (props) => {
/>
<
/Spin
>
<
/SideSheet
>
<
Modal
centered
=
{
true
}
visible
=
{
addQuotaModalOpen
}
onOk
=
{()
=>
{
addLocalQuota
();
setIsModalOpen
(
false
);
}}
onCancel
=
{()
=>
setIsModalOpen
(
false
)}
closable
=
{
null
}
>
<
div
style
=
{{
marginTop
:
20
}}
>
<
Typography
.
Text
>
{
`新额度
${
renderQuota
(
quota
)}
+
${
renderQuota
(
addQuotaLocal
)}
=
${
renderQuota
(
quota
+
addQuotaLocal
)}
`
}
<
/Typography.Text
>
<
/div
>
<
Input
name
=
'addQuotaLocal'
placeholder
=
{
'需要添加的额度'
}
onChange
=
{(
value
)
=>
setAddQuotaLocal
(
parseInt
(
value
))}
value
=
{
addQuotaLocal
}
type
=
{
'number'
}
autoComplete
=
'new-password'
/>
<
/Modal
>
<
/
>
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment