index.jsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import DiagnosticItem from '@containers/DiagnosticItem'
  4. import { SearchOption } from '@commonComp';
  5. import ScrollArea from 'react-scrollbar';
  6. import $ from 'jquery';
  7. class DiagResultSearch extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. };
  12. this.getSearchList = this.getSearchList.bind(this)
  13. }
  14. componentWillReceiveProps(nextProps) {
  15. }
  16. componentDidMount() {
  17. const that = this
  18. $(document).click(function (e) {
  19. var diagSearch = $('#diagSearch')[0];
  20. var addDiag = $('#addDiag')[0];
  21. var confirm = $('#confirm')[0];
  22. if (diagSearch) {
  23. if (!confirm&&!that.isBar) {//onMousedown的目标为滚动条时,删除弹窗不关闭
  24. if (e.target != diagSearch && e.target != addDiag && e.target.parentNode != addDiag && !$.contains(diagSearch, e.target)) {
  25. that.props.hideSearch();
  26. that.props.setHighter(48)
  27. }
  28. }
  29. }
  30. });
  31. document.addEventListener('mousedown',function(e){
  32. //onMousedown的目标为滚动条时,标签填写单不关闭
  33. if(e.target.className=='scrollbar'){
  34. that.isBar = true;
  35. }else{
  36. that.isBar = false;
  37. }
  38. });
  39. }
  40. getSearchList(searchResult) {
  41. return <div className={style['search-result']}>
  42. {
  43. searchResult && searchResult.map((item) => {
  44. return (<div key={item.id} className={style['search-result-item']}>
  45. <DiagnosticItem setHighter={this.props.setHighter} title={true} item={item} clearInput={this.clearInput} type='search'/>
  46. </div>)
  47. })
  48. }
  49. </div>
  50. }
  51. render() {
  52. const { show, searchResult, refreshScroller, handleChangeValue,pageTop,windowHeight } = this.props;
  53. const contStyle={
  54. opacity:'0.4',
  55. right:'0',
  56. top:'1px',
  57. zIndex:'15',
  58. width:'14px',
  59. background:'#f1f1f1'};
  60. const barStyle={background:'#777',width:'100%'};
  61. return (
  62. show && <div id='diagSearch' className={style['search-box']}>
  63. <SearchOption handleChangeValue={handleChangeValue} refreshScroller={refreshScroller} pageTop={pageTop} windowHeight={windowHeight} height={180} visible={true}>
  64. <ScrollArea speed={0.8}
  65. horizontal={false}
  66. stopScrollPropagation={searchResult.length>6?true:false}
  67. style={{height:'257px'}}
  68. className={style["area"]}
  69. verticalContainerStyle={contStyle}
  70. verticalScrollbarStyle={barStyle}
  71. contentClassName="content">
  72. {this.getSearchList(searchResult)}
  73. </ScrollArea>
  74. </SearchOption>
  75. </div>
  76. )
  77. }
  78. }
  79. export default DiagResultSearch;