ソースを参照

清空搜索条件2755

zhouna 5 年 前
コミット
14f88b0b74

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

@@ -37,7 +37,7 @@ class MedicalInfo extends Component {
         const that = this;
         if(searchResult&&searchResult.length>0){
           setTimeout(function(){
-            that.$ul.current.style.height = getWindowInnerHeight()-278+'px';
+            if(that.$ul.current)that.$ul.current.style.height = getWindowInnerHeight()-278+'px';
           },100);
         }
         return searchResult && searchResult.map((item) => {
@@ -129,10 +129,17 @@ class MedicalInfo extends Component {
       }
     });
   }
-  componentWillReceiveProps(){
+  componentWillReceiveProps(next){
     this.setState({
       hasSearch: false
     });
+    //点清空恢复初始状态
+    if(this.props.clearSearch!==next.clearSearch){
+      this.clear();
+      this.setState({
+        typeChecks:['0']
+      });
+    }
   }
     render() {
         const {searchResult,filterList} = this.props;
@@ -141,8 +148,8 @@ class MedicalInfo extends Component {
             <div className={style['search-cont']} ref={this.$cont}>
               <div className={style['search-box']}>
                 <p className={style['cont']}>
-                  <input placeholder="医学知识搜索" type="text" className={style['input']} ref={this.$inp} onInput={this.handleChange} onKeyUp={this.handleEnter}/>
-                  {val?<img src={delIcon} id='clearMedicalInfoSearch' alt="清空" onClick={this.clear}/>:''}
+                  <input placeholder="医学知识搜索" id='medicalInfoSearch' type="text" className={style['input']} ref={this.$inp} onInput={this.handleChange} onKeyUp={this.handleEnter}/>
+                  {val?<img src={delIcon} alt="清空" onClick={this.clear}/>:''}
                   <button onClick={this.search}>搜索</button>
                 </p>
                 <Filters data ={filterList} checkeds={typeChecks} handleCheck={this.handleTypeCheck}></Filters>

+ 2 - 2
src/components/Operation/index.jsx

@@ -101,8 +101,8 @@ class Operation extends Component {
     let jsonData = getAllDataList(baseList);
     let jsonStr = getAllDataStringList(baseList);
     let flg = isAllPartClear(jsonData,jsonStr,baseList);
-    const tpVal = $("#clearTemplateSearch").prev().val();   //模板是否有搜索条件未清空
-    const mdVal = $("#clearMedicalInfoSearch").prev().val();    //知识是否有搜索条件未清空
+    const tpVal = $("#templateSearch").val();   //模板是否有搜索条件未清空
+    const mdVal = $("#medicalInfoSearch").val();    //知识是否有搜索条件未清空
     if(flg||tpVal||mdVal){
       this.setState({
         type: type,

+ 3 - 1
src/components/PushContainer/index.jsx

@@ -274,7 +274,7 @@ class PushContainer extends Component {
     store.dispatch(changeVisible(false));
   }
   render() {
-    const { activeId, checkItems, visible, showMsg,hasMore,current, items, allCheckShow,allCheckShowAdmin,adminItems,admin,checkItemsAdmin } = this.props;
+    const { activeId, checkItems, visible, showMsg,hasMore,current, items, allCheckShow,allCheckShowAdmin,adminItems,admin,checkItemsAdmin,clearSearch } = this.props;
     return <div className={style["container"]} ref={this.$cont} >
       <Tab tabs={this.state.tabs}
         activeId={activeId}
@@ -285,6 +285,7 @@ class PushContainer extends Component {
           <CaseQuailty></CaseQuailty>
           <TemplateItems
             items={items}
+            clearSearch={clearSearch}
             adminItems={adminItems}
             admin={admin}
             handleAllCheckboxAdmin={this.handleAllCheckboxAdmin}
@@ -341,6 +342,7 @@ const mapStateToProps = (state) => {//console.log(state)
     allCheckedAdmin: state.tabTemplate.allCheckedAdmin,
     allCheckShowAdmin: state.tabTemplate.allCheckShowAdmin,
     checkItemsAdmin: state.tabTemplate.checkItemsAdmin,
+    clearSearch:state.print.clearSearch,
   }
 }
 

+ 10 - 4
src/components/TemplateItems/index.jsx

@@ -113,10 +113,16 @@ class TemplateItems extends React.Component {
         this.$search.current.value = '';
         this.setState({
             val:''
-        })
+        });
         this.$search.current.focus();
+        this.templateSearch();
+    }
+  componentWillReceiveProps(next){
+        //点清空恢复初始状态
+      if(this.props.clearSearch!==next.clearSearch){
+        this.clear();
+      }
     }
-
     render() {
         const { checkItemsAdmin,handleAllCheckboxAdmin,handleMangerTemplateAdmin,allCheckShowAdmin,admin,adminItems,allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore } = this.props;
         const {height} = this.state
@@ -138,7 +144,7 @@ class TemplateItems extends React.Component {
                         <div className={style.wrapperTop}>
                             <div className={style.templateSearch}>
                                 <input placeholder="模板搜索" maxLength="30" ref={this.$search} type="text" onInput={this.handleChange} onPropertyChange={this.handleChange} onKeyUp={this.handleEnter}/>
-                                {this.state.val?<img src={delIcon} id='clearTemplateSearch' alt="清空" onClick={this.clear}/>:''}
+                                {this.state.val?<img src={delIcon} alt="清空" onClick={this.clear}/>:''}
                                 <div className={style.search} onClick={this.templateSearch}>搜索</div>
                             </div>
                             {
@@ -150,7 +156,7 @@ class TemplateItems extends React.Component {
                     items&&!admin ? 
                         <div className={style.wrapperTop}>
                             <div className={style.templateSearch}>
-                                <input placeholder="模板搜索" maxLength="30" ref={this.$search} type="text" onInput={this.handleChange} onPropertyChange={this.handleChange} onKeyUp={this.handleEnter}/>
+                                <input placeholder="模板搜索" id='templateSearch' maxLength="30" ref={this.$search} type="text" onInput={this.handleChange} onPropertyChange={this.handleChange} onKeyUp={this.handleEnter}/>
                                 {this.state.val?<img src={delIcon} alt="清空" onClick={this.clear}/>:''}
                                 <div className={style.search} onClick={this.templateSearch}>搜索</div>
                             </div>

+ 2 - 1
src/containers/MedicalInfoContainer.js

@@ -9,12 +9,13 @@ import {CLEAR_INFO_SEARCH_LIST,SET_FILTER_LIST} from '@types/medicalInfo';
 import {SHOW_TABLE_LIST} from '@store/types/pushMessage';
 
 function mapStateToProps(state) {
-    const {medicalInfo,pushMessage} = state;
+    const {medicalInfo,pushMessage,print} = state;
     return{
         searchResult: medicalInfo.searchResult,
         filterList:medicalInfo.filterList,
         formulaResult: pushMessage.formulaResult,
         scaleInfo: pushMessage.scaleInfo,//量表内容
+        clearSearch:print.clearSearch,
     }
 }
 

+ 0 - 1
src/containers/OperationContainer.js

@@ -117,7 +117,6 @@ function mapDispatchToProps(dispatch) {
               dispatch(billing());
             }
           },200);
-
         }
     };
 }

+ 4 - 4
src/store/actions/print.js

@@ -34,8 +34,8 @@ export const diagShow=(state,action)=>{
   return res;
 };
 
-export const recoverTag = (state,action)=> {
-  const res = Object.assign({}, state);
-  console.log(res);
+export const clearSearchParam=(state,action)=>{
+  const res=Object.assign({},state);
+  res.clearSearch = action.data;
   return res;
-}
+};

+ 6 - 5
src/store/reducers/print.js

@@ -1,11 +1,12 @@
-import { RECOVER_TAG,SHOW_PRINT_PREVIEW, CLOSE_PRINT_PREVIEW, SAVE_MESSAGE, CLOSE_PREVIEW, SHOW_PREVIEW,DIAG_SHOW } from "../types/print";
-import {recoverTag, showPrintPreview, closePrintPreview, saveMessage, showPreview, closePreview,diagShow } from "../actions/print";
+import { SHOW_PRINT_PREVIEW, CLOSE_PRINT_PREVIEW, SAVE_MESSAGE, CLOSE_PREVIEW, SHOW_PREVIEW,DIAG_SHOW,CLEAR_SEARCH_PARAM } from "../types/print";
+import { showPrintPreview, closePrintPreview, saveMessage, showPreview, closePreview,diagShow,clearSearchParam } from "../actions/print";
 
 const initState = {
   visible: false,
   preVisible: false,
   saveMessage: {},
-  diagShow: false
+  diagShow: false,
+  clearSearch:0,
 };
 export default function(state = initState, action) {
   switch (action.type) {
@@ -21,8 +22,8 @@ export default function(state = initState, action) {
       return saveMessage(state, action);
     case DIAG_SHOW:
       return diagShow(state, action);
-    case RECOVER_TAG:
-      return recoverTag(state,action);
+    case CLEAR_SEARCH_PARAM:
+      return clearSearchParam(state,action);
     default:
       return state;
   }

+ 1 - 1
src/store/types/print.js

@@ -4,4 +4,4 @@ export const SAVE_MESSAGE = 'SAVE_MESSAGE';
 export const SHOW_PREVIEW = 'SHOW_PREVIEW';
 export const CLOSE_PREVIEW = 'CLOSE_PREVIEW';
 export const DIAG_SHOW = 'DIAG_SHOW';
-export const RECOVER_TAG = 'RECOVER_TAG';
+export const CLEAR_SEARCH_PARAM='CLEAR_SEARCH_PARAM';

+ 5 - 1
src/utils/tools.js

@@ -16,6 +16,7 @@ import config from '@config/index';
 import up from '@images/up.png';
 import down from '@images/down.png';
 import $ from 'jquery';
+import {CLEAR_SEARCH_PARAM} from "../store/types/print";
 
 
 /***
@@ -166,7 +167,10 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
         store.dispatch(clearAssistData([],'',[]));
         store.dispatch(clearAllLabel([],[],''));
         //右侧搜索条件清空
-        $("#clearTemplateSearch,#clearMedicalInfoSearch,#medicalInfoFilter:first-child").click();
+        store.dispatch({
+          type: CLEAR_SEARCH_PARAM,
+          data: Math.random()
+        });
         //tab跳回辅助信息
         store.dispatch(tabChange('0'));
         store.dispatch({