浏览代码

其他史搜索选中位置bug修改

zhouna 6 年之前
父节点
当前提交
9572b216a7
共有 2 个文件被更改,包括 17 次插入6 次删除
  1. 2 2
      src/common/components/EditableSpan/index.jsx
  2. 15 4
      src/store/actions/otherHistory.js

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

@@ -83,8 +83,8 @@ class EditableSpan extends Component{
       let temp = '';
       let search='';
       clearTimeout(that.state.timer);
-      temp = newText.replace(searchPre.replace(/(^\s*)|(\s*$)|(^\,*)|(\,*$)/g,''),'');
-      search = temp.replace(/(^\s*)|(\s*$)|(^\,*)|(\,*$)/g,'');
+      temp = newText.replace(searchPre,'');
+      search = temp.replace(/[(^\s*)|(\s*$)|(^\,*)|(\,*$)]/g,'');
       //console.log(labelVal,'旧:',searchPre,'新:',newText,'搜索:',search);
       handleSearch&&handleSearch({text:search,boxMark,mainIds});
       //搜索后保持现在的值,继续输入时要用于对比

+ 15 - 4
src/store/actions/otherHistory.js

@@ -187,12 +187,23 @@ export function insertLabelData(state,action){
   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,'','');
+    if(toEnd){
+      res.data.splice(index,1,pText,spreadLabels,text);
+      res.saveText.splice(index,1,newText,'','');
+    }else{
+      res.data.splice(index,1,spreadLabels,pText,text);
+      res.saveText.splice(index,1,'',newText,'');
+    }
   }else{
     span.current.innerText = ' ';
-    res.data.splice(index+1,0,spreadLabels,text);
-    res.saveText.splice(index+1,0,'','');
+    if(toEnd){
+      res.data.splice(index+1,0,spreadLabels,text);
+      res.saveText.splice(index+1,0,'','');
+    }else{
+      res.data.splice(index,0,text,spreadLabels);
+      res.saveText.splice(index,0,'','');
+    }
+
   }
   res.searchData = [];    //选中清空搜索内容(即关闭搜索弹窗)
   res.update = Math.random();