index.jsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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, isShowNoDataInfo) {
  41. // console.log(searchResult,'searchResult');
  42. // console.log(isShowNoDataInfo,'isShowNoDataInfo');
  43. if (isShowNoDataInfo === true && searchResult.length === 0 ){
  44. return <div className={style['search-result-noItem']}>暂无筛选项</div>
  45. }
  46. return <div className={style['search-result']} style={{'min-height':'120px',width:'412px',overflow:'auto'}}>
  47. {
  48. searchResult.length !== 0 && searchResult.map((item,idx) => {
  49. return (<div key={idx} className={style['search-result-item']}>
  50. <DiagnosticItem setHighter={this.props.setHighter} title={true} item={item} clearInput={this.clearInput} type='search'/>
  51. </div>)
  52. })
  53. }
  54. </div>
  55. }
  56. render() {
  57. const { show, searchResult, refreshScroller, handleChangeValue, pageTop, windowHeight, isShowNoDataInfo } = this.props;
  58. const contStyle={
  59. opacity:'0.4',
  60. right:'0',
  61. top:'1px',
  62. zIndex:'15',
  63. width:'14px',
  64. background:'#f1f1f1'};
  65. const barStyle={background:'#777',width:'100%'};
  66. return (
  67. show && <div id='diagSearch' className={style['search-box']}>
  68. <SearchOption handleChangeValue={handleChangeValue} refreshScroller={refreshScroller} pageTop={pageTop} windowHeight={windowHeight} height={180} visible={true}>
  69. {this.getSearchList(searchResult, isShowNoDataInfo)}
  70. </SearchOption>
  71. </div>
  72. )
  73. }
  74. }
  75. export default DiagResultSearch;