mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-27 18:53:43 +00:00
user detail
This commit is contained in:
+3
-3
@@ -60,7 +60,7 @@ export default {
|
||||
},
|
||||
*'delete' ({ payload }, { call, put }) {
|
||||
const data = yield call(remove, { id: payload })
|
||||
if (data && data.success) {
|
||||
if (data.success) {
|
||||
yield put({ type: 'requery' })
|
||||
} else {
|
||||
throw data
|
||||
@@ -69,7 +69,7 @@ export default {
|
||||
*create ({ payload }, { call, put }) {
|
||||
yield put({ type: 'hideModal' })
|
||||
const data = yield call(create, payload)
|
||||
if (data && data.success) {
|
||||
if (data.success) {
|
||||
yield put({ type: 'requery' })
|
||||
} else {
|
||||
throw data
|
||||
@@ -80,7 +80,7 @@ export default {
|
||||
const id = yield select(({ user }) => user.currentItem.id)
|
||||
const newUser = { ...payload, id }
|
||||
const data = yield call(update, newUser)
|
||||
if (data && data.success) {
|
||||
if (data.success) {
|
||||
yield put({ type: 'requery' })
|
||||
} else {
|
||||
throw data
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import pathToRegexp from 'path-to-regexp'
|
||||
import { query } from '../../services/user'
|
||||
|
||||
export default {
|
||||
|
||||
namespace: 'userDetail',
|
||||
|
||||
state: {
|
||||
data: {},
|
||||
},
|
||||
|
||||
subscriptions: {
|
||||
setup ({ dispatch, history }) {
|
||||
history.listen(() => {
|
||||
const match = pathToRegexp('/user/:id').exec(location.pathname)
|
||||
if (match) {
|
||||
dispatch({ type: 'query', payload: { id: match[1] } })
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query ({
|
||||
payload,
|
||||
}, { call, put }) {
|
||||
const data = yield call(query, payload)
|
||||
const { success, message, status, ...other } = data
|
||||
if (success) {
|
||||
yield put({
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
data: other,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
throw data
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
reducers: {
|
||||
querySuccess (state, { payload }) {
|
||||
const { data } = payload
|
||||
return {
|
||||
...state,
|
||||
data,
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -37,6 +37,14 @@ const Routers = function ({ history, app }) {
|
||||
cb(null, require('./routes/user/'))
|
||||
}, 'user')
|
||||
},
|
||||
}, {
|
||||
path: 'user/:id',
|
||||
getComponent (nextState, cb) {
|
||||
require.ensure([], require => {
|
||||
registerModel(app, require('./models/user/detail'))
|
||||
cb(null, require('./routes/user/detail/'))
|
||||
}, 'user-detail')
|
||||
},
|
||||
}, {
|
||||
path: 'login',
|
||||
getComponent (nextState, cb) {
|
||||
|
||||
@@ -105,7 +105,8 @@ const modal = ({
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '不能为空',
|
||||
message: '请填写正确手机号',
|
||||
pattern: /^1[34578]\d{9}$/,
|
||||
},
|
||||
],
|
||||
})(<Input />)}
|
||||
@@ -116,7 +117,8 @@ const modal = ({
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '不能为空',
|
||||
message: '请填写正确邮箱',
|
||||
pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/,
|
||||
},
|
||||
],
|
||||
})(<Input />)}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'dva'
|
||||
import styles from './index.less'
|
||||
|
||||
const Detail = ({ userDetail }) => {
|
||||
const { data } = userDetail
|
||||
const content = []
|
||||
for (let key in data) {
|
||||
if ({}.hasOwnProperty.call(data, key)) {
|
||||
content.push(<div key={key} className={styles.item}>
|
||||
<div>{key}</div>
|
||||
<div>{String(data[key])}</div>
|
||||
</div>)
|
||||
}
|
||||
}
|
||||
return (<div className="content-inner">
|
||||
<div className={styles.content}>
|
||||
{content}
|
||||
</div>
|
||||
</div>)
|
||||
}
|
||||
|
||||
Detail.propTypes = {
|
||||
userDetail: PropTypes.object,
|
||||
loading: PropTypes.bool,
|
||||
}
|
||||
|
||||
export default connect(({ userDetail, loading }) => ({ userDetail, loading: loading.models.userDetail }))(Detail)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
.content {
|
||||
line-height: 2.4;
|
||||
font-size: 14px;
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
|
||||
& > div {
|
||||
&:first-child {
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import UserList from './UserList'
|
||||
import UserFilter from './UserFilter'
|
||||
import UserModal from './UserModal'
|
||||
|
||||
function Users ({ location, dispatch, user, loading }) {
|
||||
const User = ({ location, dispatch, user, loading }) => {
|
||||
const { list, pagination, currentItem, modalVisible, modalType, isMotion } = user
|
||||
const { field, keyword } = location.query
|
||||
|
||||
@@ -101,11 +101,11 @@ function Users ({ location, dispatch, user, loading }) {
|
||||
)
|
||||
}
|
||||
|
||||
Users.propTypes = {
|
||||
User.propTypes = {
|
||||
user: PropTypes.object,
|
||||
location: PropTypes.object,
|
||||
dispatch: PropTypes.func,
|
||||
loading: PropTypes.bool,
|
||||
}
|
||||
|
||||
export default connect(({ user, loading }) => ({ user, loading: loading.models.user }))(Users)
|
||||
export default connect(({ user, loading }) => ({ user, loading: loading.models.user }))(User)
|
||||
|
||||
Reference in New Issue
Block a user