LookupPicker.js
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React,{PropTypes} from 'react';
import Select from 'react-select';
import 'react-select/dist/react-select.css';
import cx from 'classnames';
import s from './FormRender.scss';
class LookupPicker extends React.Component {
constructor (props, context) {
super(props, context);
this.changeDropdown=this.changeDropdown.bind(this);
}
static propTypes={
onChange: PropTypes.func,
choices:PropTypes.array,
value:PropTypes.oneOfType([
PropTypes.string,
PropTypes.array
]),
placeholder:PropTypes.string,
name:PropTypes.string,
multi:PropTypes.bool,
error:PropTypes.bool,
disabled:PropTypes.bool,
labelKey:PropTypes.string,
valueKey:PropTypes.string
}
changeDropdown(value,values){
this.props.onChange(value,values);
}
render(){
return(
<Select
className={this.props.error?s.has_error:''}
name={this.props.name}
value={this.props.value}
noResultsText='没找到'
multi={this.props.multi}
disabled={this.props.disabled}
placeholder={this.props.placeholder}
options={this.props.choices}
labelKey={this.props.labelKey}
valueKey={this.props.valueKey}
onChange={this.changeDropdown} onFocus={this.props.onFocus}/>
)
}
}
export default LookupPicker;