This commit is contained in:
zuiidea
2017-01-07 21:30:48 +08:00
parent 0e7c34a8d4
commit bb1b7e9d4b
+22 -16
View File
@@ -2,27 +2,33 @@ import React from 'react'
import styles from './search.less'
import { Input, Select, Button, Icon } from 'antd'
const Search = (props) => {
const handleSearch = () => {
class Search extends React.Component {
state = {
clearVisible: false
}
handleSearch = () => {
// console.log(this.refs.searchInput)
}
const handleInputChange = () => {
handleInputChange = (e) => {
console.log(e.target.value)
}
handleClearInput = () => {
}
const handleClearInput = () => {
render () {
const {size, select, selectOptions, selectProps, onSearch} = this.props
const {clearVisible} = this.state
return (
<Input.Group compact size={size} className={styles.search} >
{select && <Select size={size} {...selectProps}>
{selectOptions.map((item, key) => <Select.Option value={item.value} key={key}>{item.name || item.value}</Select.Option>)}
</Select>}
<Input size={size} onChange={this.handleInputChange} />
<Button size={size} type='primary' onClick={this.handleSearch}>搜索</Button>
{clearVisible && <Icon type='cross' onClick={this.handleClearInput} />}
</Input.Group>
)
}
const {size, select, selectOptions, selectProps, onSearch} = props
return (
<Input.Group compact size={size} className={styles.search} >
{select ? <Select size={size} {...selectProps}>
{selectOptions.map((item, key) => <Select.Option value={item.value} key={key}>{item.name || item.value}</Select.Option>)}
</Select> : ''}
<Input size={size} onChange={handleInputChange} />
<Button size={size} type='primary' onClick={handleSearch}>搜索</Button>
<Icon type='cross' onClick={handleClearInput} />
</Input.Group>
)
}
export default Search