浏览代码

其他史查体搜索结果放前后bug修改

zhouna 6 年之前
父节点
当前提交
141ab5430c

+ 3 - 2
src/common/components/EditableSpan/index.jsx

@@ -80,13 +80,14 @@ class EditableSpan extends Component{
     clearTimeout(this.state.timer);
     const timer = setTimeout(function(){
       let newText = e.target.innerText;
-      let temp = '';
+      let temp = '',isEnd=false;
       let search='';
       clearTimeout(that.state.timer);
       temp = newText.replace(searchPre,'');
+      isEnd = !(newText.indexOf(searchPre)>0);
       search = temp.replace(/[(^\s*)|(\s*$)|(^\,*)|(\,*$)]/g,'');
       //console.log(labelVal,'旧:',searchPre,'新:',newText,'搜索:',search);
-      handleSearch&&handleSearch({text:search,boxMark,mainIds});
+      handleSearch&&handleSearch({text:search,isEnd,boxMark,mainIds});
       //搜索后保持现在的值,继续输入时要用于对比
       that.setState({
         searchPre:newText

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

@@ -47,8 +47,8 @@ class CheckBody extends Component{
   }
   handleSearchSelect(obj){
    const {questionId,name} = obj;
-   const {fetchModules,focusTextIndex,span} = this.props;//console.log(focusTextIndex)
-    fetchModules&&fetchModules({id:questionId,index:focusTextIndex,name,span});
+   const {fetchModules,focusTextIndex,span,searchInEnd} = this.props;
+    fetchModules&&fetchModules({id:questionId,index:focusTextIndex,name,span,searchInEnd});
   }
   getData(){
     //第一次聚焦查体时,主诉有数据则调接口,主诉无数据则显示提示;其他时间查体模板数据不调接口

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

@@ -26,8 +26,8 @@ class OtherHistory extends Component{
   }
   handleSearchSelect(obj){
     const {questionId,name} = obj;
-    const {fetchModules,focusTextIndex,span} = this.props;
-    fetchModules&&fetchModules({id:questionId,index:focusTextIndex,name,span});
+    const {fetchModules,focusTextIndex,span,searchInEnd} = this.props;
+    fetchModules&&fetchModules({id:questionId,index:focusTextIndex,name,span,searchInEnd});
   }
   getLabels(){
     const {data,showArr,selecteds,saveText} = this.props;

+ 4 - 2
src/containers/CheckBody.js

@@ -18,6 +18,7 @@ function mapStateToProps(state){
     hasMain,//主诉选中的数据
     focusTextIndex:checkBody.focusIndex,    //聚焦的自由文本标签index
     span:checkBody.span,
+    searchInEnd:checkBody.searchInEnd,      //是否在搜索末尾插入结果
     selecteds:checkBody.selecteds       //普通多选选中状态
   }
 }
@@ -28,7 +29,7 @@ function mapDispatchToProps(dispatch,state){
       dispatch(getInitData());
     },
     fetchModules(param){
-      const {id,name,index,span} = param;
+      const {id,name,index,span,searchInEnd} = param;
       getModule(id).then((res)=>{
         if(res.data.code=='0'){
           dispatch({
@@ -37,7 +38,8 @@ function mapDispatchToProps(dispatch,state){
             name,
             data: res.data.data,
             span,
-            isReplace:false
+            isReplace:false,
+            searchInEnd
           })
           dispatch({
             type:ISREAD

+ 4 - 0
src/containers/EditableSpan.js

@@ -26,6 +26,7 @@ function mainSuitSearch(obj){
         dispatch({
           type:SET_SEARCH,
           data:res.data.data,
+          isEnd:obj.isEnd,      //true为在末尾插入搜索结果否则在前面插入
           inpStr:text //搜索输入的值
         })
       }
@@ -41,6 +42,7 @@ function currentSearch(obj){
         dispatch({
           type:SET_CURRENT_SEARCH,
           data:res.data.data,
+          isEnd:obj.isEnd,      //true为在末尾插入搜索结果否则在前面插入
           inpStr:text
         })
       }
@@ -56,6 +58,7 @@ function checkBodySearch(obj){
         dispatch({
           type:SETSEARCHDATA,
           data:res.data.data,
+          isEnd:obj.isEnd,      //true为在末尾插入搜索结果否则在前面插入
           inpStr:text
         });
       }
@@ -71,6 +74,7 @@ function otherHisSearch(obj) {
         dispatch({
           type:SETOTHERSEARCHDATA,
           data:res.data.data,
+          isEnd:obj.isEnd,      //true为在末尾插入搜索结果否则在前面插入
           inpStr:text
         });
       }

+ 4 - 2
src/containers/OtherHistory.js

@@ -23,6 +23,7 @@ function mapStateToProps(state){
     searchData:otherHistory.searchData,    //延迟搜索结果
     focusTextIndex:otherHistory.focusIndex,    //聚焦的自由文本标签index
     span:otherHistory.span,
+    searchInEnd:otherHistory.searchInEnd,      //是否在搜索末尾插入结果
     selecteds:otherHistory.selecteds,       //普通多选选中状态
     editClear:otherHistory.editClear,       //编辑状态
     isRead:state.homePage.isRead
@@ -56,7 +57,7 @@ function mapDispatchToProps(dispatch,store){
       },500);
     },
     fetchModules(param){
-      const {id,name,index,span} = param;
+      const {id,name,index,span,searchInEnd} = param;
       getModule(id).then((res)=>{
         if(res.data.code=='0'){
           dispatch({
@@ -65,7 +66,8 @@ function mapDispatchToProps(dispatch,store){
             name,
             data: res.data.data,
             span,
-            isReplace:false
+            isReplace:false,
+            searchInEnd
           });
           dispatch({
             type:ISREAD

+ 23 - 10
src/store/actions/checkBody.js

@@ -126,31 +126,44 @@ export function setSearchData(state,action){
   let res = Object.assign({},state);
   res.searchData = action.data;
   res.searchStr = action.inpStr;
+  res.searchInEnd = action.isEnd;
   return res;
 }
 
-//插入标签数据
+//插入标签数据-搜索
 export function insertLabelData(state,action){
   let res = Object.assign({},state);
   const text = Object.assign({},JSON.parse(config.textLabel));
   const searchStr = res.searchStr;
-  const {index,data,isReplace,span}=action;
+  const {index,data,isReplace,span,searchInEnd}=action;
   const showText = res.saveText[index];
   const spreadLabels = data;
-  const toEnd = showText.indexOf(searchStr)>0;    //替换前或后的搜索词(中间不可搜)
-  let reg = toEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);
+  let reg = searchInEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);
   const newText=showText.replace(reg,'')||'';
   if(!isReplace){
     span.current.innerText = newText;
     const pText = Object.assign({},text,{value:newText});
-    res.data.splice(index,1,pText,spreadLabels,text);
-    res.saveText.splice(index,1,newText,'','');
-    res.selecteds.splice(index,1,null,null,null);
+    if(searchInEnd){
+      res.data.splice(index,1,pText,spreadLabels,text);
+      res.saveText.splice(index,1,newText,'','');
+      res.selecteds.splice(index,1,null,null,null);
+    }else{
+      res.data.splice(index,1,text,spreadLabels,pText);
+      res.saveText.splice(index,1,'','',newText);
+      res.selecteds.splice(index,1,null,null,null);
+    }
+
   }else{
     span.current.innerText = ' ';
-    res.data.splice(index+1,0,spreadLabels,text);
-    res.saveText.splice(index+1,0,'','');
-    res.selecteds.splice(index+1,0,null,null);
+    if(searchInEnd){
+      res.data.splice(index+1,0,spreadLabels,text);
+      res.saveText.splice(index+1,0,'','');
+      res.selecteds.splice(index+1,0,null,null);
+    }else{
+      res.data.splice(index,0,text,spreadLabels);
+      res.saveText.splice(index,0,'','');
+      res.selecteds.splice(index,0,null,null);
+    }
   }
   res.searchData = [];    //选中清空搜索内容(即关闭搜索弹窗)
   res.update = Math.random();

+ 6 - 6
src/store/actions/otherHistory.js

@@ -170,24 +170,24 @@ export function setSearchData(state,action){
   let res = Object.assign({},state);
   res.searchData = action.data;
   res.searchStr = action.inpStr;
+  res.searchInEnd = action.isEnd;
   return res;
 }
 
-//插入标签数据
+//插入标签数据-搜索
 export function insertLabelData(state,action){
   let res = Object.assign({},state);
   const text = Object.assign({},JSON.parse(config.textLabel));
   const searchStr = res.searchStr;
-  const {index,data,isReplace,span}=action;
+  const {index,data,isReplace,span,searchInEnd}=action;
   const showText = res.saveText[index];
   const spreadLabels = data;
-  const toEnd = showText.indexOf(searchStr)>0;    //替换前或后的搜索词(中间不可搜)
-  let reg = toEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);
+  let reg = searchInEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);
   const newText=showText.replace(reg,'')||' ';
   if(!isReplace){
     span.current.innerText = newText;
     const pText = Object.assign({},text,{value:newText});
-    if(toEnd){
+    if(searchInEnd){
       res.data.splice(index,1,pText,spreadLabels,text);
       res.saveText.splice(index,1,newText,'','');
     }else{
@@ -196,7 +196,7 @@ export function insertLabelData(state,action){
     }
   }else{
     span.current.innerText = ' ';
-    if(toEnd){
+    if(searchInEnd){
       res.data.splice(index+1,0,spreadLabels,text);
       res.saveText.splice(index+1,0,'','');
     }else{