Skip to content

Commit

Permalink
修复了带关键字搜索时分页跳转bug;新增了页面刷新后,首次请求数据可以同时带关键字搜索与页码过滤功能
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpan committed Jan 20, 2017
1 parent 26fba23 commit 91b86a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/ui/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/components/users/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions src/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit 91b86a3

Please sign in to comment.