فهرست منبع

医学知识和量表搜索暂无搜索结果只有搜索之后显示(1585)

zhangxc 6 سال پیش
والد
کامیت
3e02c20d3e
2فایلهای تغییر یافته به همراه22 افزوده شده و 8 حذف شده
  1. 11 4
      src/components/MedicalInfo/index.jsx
  2. 11 4
      src/components/ScaleSearch/index.jsx

+ 11 - 4
src/components/MedicalInfo/index.jsx

@@ -9,7 +9,8 @@ class MedicalInfo extends Component {
         this.$inp = React.createRef();
         this.$cont = React.createRef();
         this.state={
-          val:''
+          val:'',
+          hasSearch: false
         };
         this.search = this.search.bind(this);
         this.handleChange = this.handleChange.bind(this);
@@ -28,6 +29,11 @@ class MedicalInfo extends Component {
             });
     }
     search(){
+      if(this.state.hasSearch === false) {
+        this.setState({
+          hasSearch: true
+        })
+      }
       const {handleChangeValue} = this.props;
       const val = this.$inp.current.value;
       handleChangeValue&&handleChangeValue(val);
@@ -46,7 +52,8 @@ class MedicalInfo extends Component {
       const {clearResult} = this.props;
       this.$inp.current.value = '';
       this.setState({
-        val:''
+        val:'',
+        hasSearch: false
       });
       clearResult&&clearResult();
   }
@@ -62,7 +69,7 @@ class MedicalInfo extends Component {
   }
     render() {
         const {searchResult} = this.props;
-        const {val} = this.state;
+        const {val, hasSearch} = this.state;
         return (
             <div className={style['search-cont']} ref={this.$cont}>
               <div className={style['search-box']}>
@@ -78,7 +85,7 @@ class MedicalInfo extends Component {
                     <ul>
                       {this.getSearchList()}
                     </ul>
-              </div>:<p className={style['no-data']}>暂无搜索结果!</p>}
+              </div>:hasSearch&&<p className={style['no-data']}>暂无搜索结果!</p>}
              </div>
 
 

+ 11 - 4
src/components/ScaleSearch/index.jsx

@@ -9,7 +9,8 @@ class ScaleSearch extends Component {
     this.$inp = React.createRef();
     this.$cont = React.createRef();
     this.state={
-      val:''
+      val:'',
+      hasSearch: false
     };
     this.search = this.search.bind(this);
     this.handleChange = this.handleChange.bind(this);
@@ -43,6 +44,11 @@ class ScaleSearch extends Component {
     });
   }
   search(){
+    if(this.state.hasSearch === false){
+      this.setState({
+        hasSearch: true
+      })
+    }
     const {handleChangeValue} = this.props;
     const val = this.$inp.current.value;
     handleChangeValue&&handleChangeValue(val);
@@ -61,7 +67,8 @@ class ScaleSearch extends Component {
     const {clearResult} = this.props;
     this.$inp.current.value = '';
     this.setState({
-      val:''
+      val:'',
+      hasSearch: false
     });
     clearResult&&clearResult();
   }
@@ -77,7 +84,7 @@ class ScaleSearch extends Component {
   }
   render() {
     const {searchResult} = this.props;
-    const {val} = this.state;
+    const {val, hasSearch} = this.state;
     return (
         <div className={style['search-cont']} ref={this.$cont}>
           <div className={style['search-box']}>
@@ -93,7 +100,7 @@ class ScaleSearch extends Component {
             <ul>
               {this.getSearchList()}
             </ul>
-          </div>:<p className={style['no-data']}>暂无搜索结果!</p>}
+          </div>:hasSearch && <p className={style['no-data']}>暂无搜索结果!</p>}
         </div>
     )