mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-22 16:03:53 +00:00
Merge pull request #45 from pmg1989/3.0
新增了页面刷新后,首次请求数据可以同时带关键字搜索与页码过滤功能
This commit is contained in:
+4
-4
@@ -26,8 +26,8 @@ module.exports = {
|
||||
if (d[0].password === userItem.password) {
|
||||
const now = new Date()
|
||||
now.setDate(now.getDate() + 1)
|
||||
Cookie.set('user_session', now.getTime())
|
||||
Cookie.set('user_name', userItem.username)
|
||||
Cookie.set('user_session', now.getTime(), { path: '/' })
|
||||
Cookie.set('user_name', userItem.username, { path: '/' })
|
||||
response.message = '登录成功'
|
||||
response.success = true
|
||||
} else {
|
||||
@@ -49,8 +49,8 @@ module.exports = {
|
||||
},
|
||||
|
||||
'POST /api/logout' (req, res) {
|
||||
Cookie.remove('user_session', { path: '' })
|
||||
Cookie.remove('user_name', { path: '' })
|
||||
Cookie.remove('user_session', { path: '/' })
|
||||
Cookie.remove('user_name', { path: '/' })
|
||||
res.json({
|
||||
success: true,
|
||||
message: '退出成功'
|
||||
|
||||
@@ -37,14 +37,14 @@ class Search extends React.Component {
|
||||
this.handleSearch()
|
||||
}
|
||||
render () {
|
||||
const {size, select, selectOptions, selectProps, style} = this.props
|
||||
const {size, select, selectOptions, selectProps, style, keyword} = this.props
|
||||
const {clearVisible} = this.state
|
||||
return (
|
||||
<Input.Group compact size={size} className={styles.search} style={style}>
|
||||
{select && <Select ref='searchSelect' onChange={this.handeleSelectChange} size={size} {...selectProps}>
|
||||
{selectOptions && selectOptions.map((item, key) => <Select.Option value={item.value} key={key}>{item.name || item.value}</Select.Option>)}
|
||||
</Select>}
|
||||
<Input ref='searchInput' size={size} onChange={this.handleInputChange} onPressEnter={this.handleSearch}/>
|
||||
<Input ref='searchInput' size={size} onChange={this.handleInputChange} onPressEnter={this.handleSearch} defaultValue={keyword}/>
|
||||
<Button size={size} type='primary' onClick={this.handleSearch}>搜索</Button>
|
||||
{clearVisible && <Icon type='cross' onClick={this.handleClearInput} />}
|
||||
</Input.Group>
|
||||
|
||||
@@ -20,7 +20,7 @@ const search = ({
|
||||
select: true,
|
||||
selectOptions: [{ value: 'name', name: '姓名' }, { value: 'address', name: '地址' }],
|
||||
selectProps: {
|
||||
defaultValue: 'name'
|
||||
defaultValue: field || 'name'
|
||||
},
|
||||
onSearch: (value) => {
|
||||
onSearch(value)
|
||||
|
||||
@@ -31,9 +31,11 @@ function Users ({ location, dispatch, users }) {
|
||||
loading,
|
||||
pagination: pagination,
|
||||
onPageChange (page) {
|
||||
const query = location.query
|
||||
dispatch(routerRedux.push({
|
||||
pathname: '/users',
|
||||
query: {
|
||||
...query,
|
||||
page: page.current,
|
||||
pageSize: page.pageSize
|
||||
}
|
||||
@@ -60,6 +62,18 @@ function Users ({ location, dispatch, users }) {
|
||||
field,
|
||||
keyword,
|
||||
onSearch (fieldsValue) {
|
||||
!!fieldsValue.keyword.length ?
|
||||
dispatch(routerRedux.push({
|
||||
pathname: '/users',
|
||||
query: {
|
||||
field: fieldsValue.field,
|
||||
keyword: fieldsValue.keyword
|
||||
}
|
||||
})) :
|
||||
dispatch(routerRedux.push({
|
||||
pathname: '/users'
|
||||
}))
|
||||
|
||||
dispatch({
|
||||
type: 'users/query',
|
||||
payload: fieldsValue
|
||||
|
||||
Reference in New Issue
Block a user