|
@@ -3,13 +3,15 @@ import style from './index.less';
|
|
|
import close from './img/close.png'
|
|
|
import search from './img/search.png'
|
|
|
import DiagnosticItem from '@containers/DiagnosticItem'
|
|
|
+import config from '@config/index';
|
|
|
import $ from 'jquery';
|
|
|
class DiagResultSearch extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
showClose: false,
|
|
|
- focus: true
|
|
|
+ focus: true,
|
|
|
+ timer:null
|
|
|
};
|
|
|
this.searchInput = React.createRef();
|
|
|
this.handleInput = this.handleInput.bind(this);
|
|
@@ -54,10 +56,17 @@ class DiagResultSearch extends Component {
|
|
|
handleInput(value) {
|
|
|
const { setSearchValue, getSearchResult } = this.props;
|
|
|
value.length > 0 ? this.setState({showClose: true}) : this.setState({showClose: false});
|
|
|
- if(value.trim() == ''){
|
|
|
- return getSearchResult('');
|
|
|
- }
|
|
|
- getSearchResult(value.trim());
|
|
|
+ clearTimeout(this.state.timer);
|
|
|
+ let timer = setTimeout(()=>{
|
|
|
+ clearTimeout(this.state.timer);
|
|
|
+ if(value.trim() == ''){
|
|
|
+ return getSearchResult('');
|
|
|
+ }
|
|
|
+ getSearchResult(value.trim());
|
|
|
+ },config.delayTime);
|
|
|
+ this.setState({
|
|
|
+ timer
|
|
|
+ });
|
|
|
}
|
|
|
clearInput() {
|
|
|
const { setSearchValue, getSearchResult } = this.props;
|