Pārlūkot izejas kodu

知识搜索无结果显示优化1585

zhouna 6 gadi atpakaļ
vecāks
revīzija
291de1d633

+ 8 - 5
src/components/MedicalInfo/index.jsx

@@ -10,7 +10,8 @@ class MedicalInfo extends Component {
         this.$cont = React.createRef();
         this.state={
           val:'',
-          hasSearch: false
+          hasSearch: false,
+          msg:''
         };
         this.search = this.search.bind(this);
         this.handleChange = this.handleChange.bind(this);
@@ -31,7 +32,8 @@ class MedicalInfo extends Component {
     search(){
       if(this.state.hasSearch === false) {
         this.setState({
-          hasSearch: true
+          hasSearch: true,
+          msg:'暂无搜索结果!'
         })
       }
       const {handleChangeValue} = this.props;
@@ -53,7 +55,8 @@ class MedicalInfo extends Component {
       this.$inp.current.value = '';
       this.setState({
         val:'',
-        hasSearch: false
+        hasSearch: false,
+        msg:''
       });
       clearResult&&clearResult();
   }
@@ -74,7 +77,7 @@ class MedicalInfo extends Component {
   }
     render() {
         const {searchResult} = this.props;
-        const {val, hasSearch} = this.state;
+        const {val, hasSearch,msg} = this.state;
         return (
             <div className={style['search-cont']} ref={this.$cont}>
               <div className={style['search-box']}>
@@ -90,7 +93,7 @@ class MedicalInfo extends Component {
                     <ul>
                       {this.getSearchList()}
                     </ul>
-              </div>:<p className={style['no-data']}>{hasSearch?'搜索中...':'暂无搜索结果!'}</p>}
+              </div>:<p className={style['no-data']}>{hasSearch?'搜索中...':msg}</p>}
              </div>
 
 

+ 8 - 5
src/components/ScaleSearch/index.jsx

@@ -10,7 +10,8 @@ class ScaleSearch extends Component {
     this.$cont = React.createRef();
     this.state={
       val:'',
-      hasSearch: false
+      hasSearch: false,
+      msg:''
     };
     this.search = this.search.bind(this);
     this.handleChange = this.handleChange.bind(this);
@@ -46,7 +47,8 @@ class ScaleSearch extends Component {
   search(){
     if(this.state.hasSearch === false){
       this.setState({
-        hasSearch: true
+        hasSearch: true,
+        msg:'暂无搜索结果!'
       })
     }
     const {handleChangeValue} = this.props;
@@ -68,7 +70,8 @@ class ScaleSearch extends Component {
     this.$inp.current.value = '';
     this.setState({
       val:'',
-      hasSearch: false
+      hasSearch: false,
+      msg:''
     });
     clearResult&&clearResult();
   }
@@ -89,7 +92,7 @@ class ScaleSearch extends Component {
   }
   render() {
     const {searchResult} = this.props;
-    const {val, hasSearch} = this.state;
+    const {val, hasSearch,msg} = this.state;
     return (
         <div className={style['search-cont']} ref={this.$cont}>
           <div className={style['search-box']}>
@@ -105,7 +108,7 @@ class ScaleSearch extends Component {
             <ul>
               {this.getSearchList()}
             </ul>
-          </div>:<p className={style['no-data']}>{hasSearch?'搜索中...':'暂无搜索结果!'}</p>}
+          </div>:<p className={style['no-data']}>{hasSearch?'搜索中...':msg}</p>}
         </div>
     )