Skip to content

Commit

Permalink
add:userMotion
Browse files Browse the repository at this point in the history
  • Loading branch information
zuiidea committed Feb 9, 2017
1 parent 803d8ac commit 4def8c5
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"eslint-plugin-react": "^5.1.1",
"glob": "^7.0.5",
"mockjs": "^1.0.1-beta3",
"rc-tween-one": "^1.0.0",
"redbox-react": "^1.2.10",
"robe-ajax": "^1.0.0",
"watchjs": "^0.0.0"
Expand Down
8 changes: 8 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export default function ({history, app}) {
cb(null, require('./routes/users'))
})
}
}, {
path: 'usersMotion',
name: 'usersMotion',
getComponent (nextState, cb) {
require.ensure([], require => {
cb(null, require('./routes/usersMotion'))
})
}
}, {
path: 'ui/ico',
name: 'ui/ico',
Expand Down
109 changes: 109 additions & 0 deletions src/routes/usersMotion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React, { PropTypes } from 'react'
import { routerRedux } from 'dva/router'
import { connect } from 'dva'
import UserList from '../components/users/list'
import UserSearch from '../components/users/search'
import UserModal from '../components/users/modal'

function Users ({ location, dispatch, users }) {
const { loading, list, pagination, currentItem, modalVisible, modalType } = users
const { field, keyword } = location.query

const userModalProps = {
item: modalType === 'create' ? {} : currentItem,
type: modalType,
visible: modalVisible,
onOk (data) {
dispatch({
type: `users/${modalType}`,
payload: data
})
},
onCancel () {
dispatch({
type: 'users/hideModal'
})
}
}

const userListProps = {
dataSource: list,
loading,
pagination: pagination,
onPageChange (page) {
const query = location.query
dispatch(routerRedux.push({
pathname: '/users',
query: {
...query,
page: page.current,
pageSize: page.pageSize
}
}))
},
onDeleteItem (id) {
dispatch({
type: 'users/delete',
payload: id
})
},
onEditItem (item) {
dispatch({
type: 'users/showModal',
payload: {
modalType: 'update',
currentItem: item
}
})
}
}

const userSearchProps = {
field,
keyword,
onSearch (fieldsValue) {
!!fieldsValue.keyword.length ?
dispatch(routerRedux.push({
pathname: '/users',
query: {
field: fieldsValue.field,
keyword: fieldsValue.keyword
}
})) :
dispatch(routerRedux.push({
pathname: '/users'
}))
},
onAdd () {
dispatch({
type: 'users/showModal',
payload: {
modalType: 'create'
}
})
}
}

const UserModalGen = () =>
<UserModal {...userModalProps} />

return (
<div className='content-inner'>
<UserSearch {...userSearchProps} />
<UserList {...userListProps} />
<UserModalGen />
</div>
)
}

Users.propTypes = {
users: PropTypes.object,
location: PropTypes.object,
dispatch: PropTypes.func
}

function mapStateToProps ({ users }) {
return { users }
}

export default connect(mapStateToProps)(Users)
5 changes: 5 additions & 0 deletions src/utils/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ module.exports = [
name: '用户管理',
icon: 'user'
},
{
key: 'usersMotion',
name: '用户管理-动效',
icon: 'user'
},
{
key: 'ui',
name: 'UI组件',
Expand Down

0 comments on commit 4def8c5

Please sign in to comment.