Преглед изворни кода

知识搜索清空按钮清空搜索结果

zhouna пре 6 година
родитељ
комит
1b1316f8f6

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

@@ -43,10 +43,12 @@ class MedicalInfo extends Component {
       }
   }
   clear(){
-    this.$inp.current.value = '';
-    this.setState({
-      val:''
-    });
+      const {clearResult} = this.props;
+      this.$inp.current.value = '';
+      this.setState({
+        val:''
+      });
+      clearResult&&clearResult();
   }
   componentDidMount(){
     const height = getWindowInnerHeight()-170;

+ 2 - 0
src/components/ScaleSearch/index.jsx

@@ -58,10 +58,12 @@ class ScaleSearch extends Component {
     }
   }
   clear(){
+    const {clearResult} = this.props;
     this.$inp.current.value = '';
     this.setState({
       val:''
     });
+    clearResult&&clearResult();
   }
   componentDidMount(){
     const height = getWindowInnerHeight()-170;

+ 6 - 0
src/containers/MedicalInfoContainer.js

@@ -3,6 +3,7 @@ import { connect } from 'react-redux';
 import { getSearchList } from '@store/async-actions/medicalInfo';
 import MedicalInfo from '@components/MedicalInfo';
 import {getAllConceptDetail} from '../store/async-actions/pushMessage';
+import {CLEAR_INFO_SEARCH_LIST} from '@types/medicalInfo';
 
 function mapStateToProps(state) {
     return{
@@ -17,6 +18,11 @@ function mapDispatchToProps(dispatch) {
         },
         getAllConceptDetail(item) {
             dispatch(getAllConceptDetail(item))
+        },
+        clearResult(){
+              dispatch({
+                type:CLEAR_INFO_SEARCH_LIST
+              })
         }
     }
 }

+ 6 - 0
src/containers/ScaleSearchContainer.js

@@ -4,6 +4,7 @@ import { getSearchList } from '@store/async-actions/scaleSearch';
 import ScaleSearch from '@components/ScaleSearch';
 import {getScaleInfo} from '../store/async-actions/pushMessage';
 import {SHOW_TABLE_LIST} from '@store/types/pushMessage';
+import {CLEAR_SCALE_SEARCH_LIST} from '@types/scaleSearch';
 
 function mapStateToProps(state) {
     const {pushMessage} = state;
@@ -31,6 +32,11 @@ function mapDispatchToProps(dispatch) {
             item:Object.assign({},item)
           });
         },
+        clearResult(){
+            dispatch({
+              type:CLEAR_SCALE_SEARCH_LIST
+            })
+        }
     }
 }
 const ScaleSearchContainer = connect(

+ 5 - 1
src/store/reducers/medicalInfo.js

@@ -1,4 +1,4 @@
-import { SET_SEARCH_VALUE, GET_SEARCH_RESULT } from '../types/medicalInfo'; 
+import { SET_SEARCH_VALUE, GET_SEARCH_RESULT ,CLEAR_INFO_SEARCH_LIST} from '../types/medicalInfo';
 import { setSearchValue, getSearchResult } from '../actions/medicalInfo'; 
 
 const initState = {
@@ -7,11 +7,15 @@ const initState = {
 }
 
 export default function (state=initState, action) {
+  const res = Object.assign({},state);
     switch(action.type) {
         case SET_SEARCH_VALUE: 
             return setSearchValue(state, action);
         case GET_SEARCH_RESULT: 
             return getSearchResult(state, action);
+        case CLEAR_INFO_SEARCH_LIST:
+            res.searchResult=[];
+            return res;
         default: 
             return state;
     }

+ 4 - 1
src/store/reducers/scaleSearch.js

@@ -1,4 +1,4 @@
-import { GET_SCALE_SEARCH_RESULT } from '../types/scaleSearch.js';
+import { GET_SCALE_SEARCH_RESULT,CLEAR_SCALE_SEARCH_LIST } from '../types/scaleSearch.js';
 
 const initState = {
     searchResult: []
@@ -10,6 +10,9 @@ export default function (state=initState, action) {
         case GET_SCALE_SEARCH_RESULT:
             res.searchResult = action.data;
             return res;
+        case CLEAR_SCALE_SEARCH_LIST:
+            res.searchResult=[];
+            return res;
         default: 
             return res;
     }

+ 2 - 1
src/store/types/medicalInfo.js

@@ -1,2 +1,3 @@
 export const SET_SEARCH_VALUE = 'SET_SEARCH_VALUE';
-export const GET_SEARCH_RESULT = Symbol('GET_SEARCH_RESULT');
+export const GET_SEARCH_RESULT = Symbol('GET_SEARCH_RESULT');
+export const CLEAR_INFO_SEARCH_LIST = 'CLEAR_INFO_SEARCH_LIST';

+ 2 - 1
src/store/types/scaleSearch.js

@@ -1 +1,2 @@
-export const GET_SCALE_SEARCH_RESULT = 'GET_SCALE_SEARCH_RESULT';
+export const GET_SCALE_SEARCH_RESULT = 'GET_SCALE_SEARCH_RESULT';
+export const CLEAR_SCALE_SEARCH_LIST = 'CLEAR_SCALE_SEARCH_LIST';