EmpCombo.js
1.8 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
54
55
56
57
58
59
60
import React,{PropTypes} from 'react';
import ReactDOM from 'react-dom';
import {connect} from 'react-redux';
import cx from 'classnames';
import s from './form.scss';
import {Select } from 'antd';
const Option = Select.Option;
import {fiterEmployeesStatu} from '../../../utils/hrUtil';
class EmpCombo extends React.Component {
constructor(props) {
super(props);
this.searchOption=this.searchOption.bind(this);
}
static propTypes = {
employees:PropTypes.array,
defaultValue:PropTypes.string
}
static defaultProps={
defaultValue:'',
onChange:(value)=>{
}
}
searchOption(inputValue, option){
const {name,pinyin,pinyinfl}=option.props;
if(name.indexOf(inputValue)!=-1||
pinyin.indexOf(inputValue)!=-1||
pinyinfl.indexOf(inputValue)!=-1){
return true;
}else{
return false;
}
}
render(){
console.log(this.props);
const {employees,defaultValue}=this.props;
const _employees=fiterEmployeesStatu(employees);
return(
<Select showSearch defaultValue={defaultValue} value={this.props.value}
placeholder={this.props.placeholder||"请选择人员"} notFoundContent="无法找到"
filterOption={this.searchOption} onChange={this.props.onChange}>
{_employees.map((employee,i)=>{
return <Option key={i} value={employee.uuid} {...employee} >{employee.name}</Option>
})}
</Select>
)
}
}
const mapStateToProps = (state) => {
const {hrSetting:{employees}}=state;
return {
employees
};
}
export default connect(mapStateToProps)(EmpCombo);