Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
admin-localhome
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
localhome
admin-localhome
Commits
91708ca1
Commit
91708ca1
authored
Feb 22, 2018
by
chencheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11. Handle user create
parent
6044e2fc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
1 deletion
+29
-1
Users.css
src/pages/users/components/Users.css
+4
-0
Users.js
src/pages/users/components/Users.js
+13
-1
users.js
src/pages/users/models/users.js
+5
-0
users.js
src/pages/users/services/users.js
+7
-0
No files found.
src/pages/users/components/Users.css
View file @
91708ca1
...
@@ -5,3 +5,7 @@
...
@@ -5,3 +5,7 @@
.operation
a
{
.operation
a
{
margin
:
0
.5em
;
margin
:
0
.5em
;
}
}
.create
{
margin
:
1.5em
0
;
}
src/pages/users/components/Users.js
View file @
91708ca1
import
{
connect
}
from
'dva'
;
import
{
connect
}
from
'dva'
;
import
{
Table
,
Pagination
,
Popconfirm
}
from
'antd'
;
import
{
Table
,
Pagination
,
Popconfirm
,
Button
}
from
'antd'
;
import
{
routerRedux
}
from
'dva/router'
;
import
{
routerRedux
}
from
'dva/router'
;
import
styles
from
'./Users.css'
;
import
styles
from
'./Users.css'
;
import
{
PAGE_SIZE
}
from
'../constants'
;
import
{
PAGE_SIZE
}
from
'../constants'
;
...
@@ -27,6 +27,13 @@ function Users({ dispatch, list: dataSource, loading, total, page: current }) {
...
@@ -27,6 +27,13 @@ function Users({ dispatch, list: dataSource, loading, total, page: current }) {
});
});
}
}
function
createHandler
(
values
)
{
dispatch
({
type
:
'users/create'
,
payload
:
values
,
});
}
const
columns
=
[
const
columns
=
[
{
{
title
:
'Name'
,
title
:
'Name'
,
...
@@ -63,6 +70,11 @@ function Users({ dispatch, list: dataSource, loading, total, page: current }) {
...
@@ -63,6 +70,11 @@ function Users({ dispatch, list: dataSource, loading, total, page: current }) {
return
(
return
(
<
div
className
=
{
styles
.
normal
}
>
<
div
className
=
{
styles
.
normal
}
>
<
div
>
<
div
>
<
div
className
=
{
styles
.
create
}
>
<
UserModal
record
=
{{}}
onOk
=
{
createHandler
}
>
<
Button
type
=
"primary"
>
Create
User
<
/Button
>
<
/UserModal
>
<
/div
>
<
Table
<
Table
loading
=
{
loading
}
loading
=
{
loading
}
columns
=
{
columns
}
columns
=
{
columns
}
...
...
src/pages/users/models/users.js
View file @
91708ca1
...
@@ -34,6 +34,11 @@ export default {
...
@@ -34,6 +34,11 @@ export default {
const
page
=
yield
select
(
state
=>
state
.
users
.
page
);
const
page
=
yield
select
(
state
=>
state
.
users
.
page
);
yield
put
({
type
:
'fetch'
,
payload
:
{
page
}
});
yield
put
({
type
:
'fetch'
,
payload
:
{
page
}
});
},
},
*
create
({
payload
:
values
},
{
call
,
put
,
select
})
{
yield
call
(
usersService
.
create
,
values
);
const
page
=
yield
select
(
state
=>
state
.
users
.
page
);
yield
put
({
type
:
'fetch'
,
payload
:
{
page
}
});
},
},
},
subscriptions
:
{
subscriptions
:
{
setup
({
dispatch
,
history
})
{
setup
({
dispatch
,
history
})
{
...
...
src/pages/users/services/users.js
View file @
91708ca1
...
@@ -17,3 +17,10 @@ export function patch(id, values) {
...
@@ -17,3 +17,10 @@ export function patch(id, values) {
body
:
JSON
.
stringify
(
values
),
body
:
JSON
.
stringify
(
values
),
});
});
}
}
export
function
create
(
values
)
{
return
request
(
'/api/users'
,
{
method
:
'POST'
,
body
:
JSON
.
stringify
(
values
),
});
}
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