From 4def8c5d70318231299560e73685e4e0ee8de951 Mon Sep 17 00:00:00 2001 From: zuiidea Date: Thu, 9 Feb 2017 22:33:32 +0800 Subject: [PATCH] add:userMotion --- package.json | 1 + src/router.js | 8 +++ src/routes/usersMotion.js | 109 ++++++++++++++++++++++++++++++++++++++ src/utils/menu.js | 5 ++ 4 files changed, 123 insertions(+) create mode 100644 src/routes/usersMotion.js diff --git a/package.json b/package.json index 47eefa5..4b57e93 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/router.js b/src/router.js index 1a6d457..033ab69 100644 --- a/src/router.js +++ b/src/router.js @@ -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', diff --git a/src/routes/usersMotion.js b/src/routes/usersMotion.js new file mode 100644 index 0000000..9823ad1 --- /dev/null +++ b/src/routes/usersMotion.js @@ -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 = () => + + + return ( +
+ + + +
+ ) +} + +Users.propTypes = { + users: PropTypes.object, + location: PropTypes.object, + dispatch: PropTypes.func +} + +function mapStateToProps ({ users }) { + return { users } +} + +export default connect(mapStateToProps)(Users) diff --git a/src/utils/menu.js b/src/utils/menu.js index c00ed96..7c550b4 100644 --- a/src/utils/menu.js +++ b/src/utils/menu.js @@ -9,6 +9,11 @@ module.exports = [ name: '用户管理', icon: 'user' }, + { + key: 'usersMotion', + name: '用户管理-动效', + icon: 'user' + }, { key: 'ui', name: 'UI组件',