Browse Source

选中删除后可还原

zhouna 5 years ago
parent
commit
7ab218df19
4 changed files with 24 additions and 12 deletions
  1. 2 3
      src/containers/OperationContainer.js
  2. 12 5
      src/store/actions/checkBody.js
  3. 5 1
      src/utils/tools.js
  4. 5 3
      src/utils/utils.js

+ 2 - 3
src/containers/OperationContainer.js

@@ -83,16 +83,15 @@ function mapDispatchToProps(dispatch) {
                '4':RECOVER_TAG_CHECK
             };
             const deledTags = localStorage.getItem('deletedTags')?JSON.parse(localStorage.getItem('deletedTags')):[];
-            const deledSelects = localStorage.getItem('deletedSelects')?JSON.parse(localStorage.getItem('deletedSelects')):[];
             if(deledTags.length===0){
               Notify.info('暂无标签可还原');
               return ;
             }
             const arr = deledTags[0].delIndex.split("-");
+            const item = deledTags[0];
             dispatch({
               type:maps[arr[0]],
-              data:deledTags[0],
-              select:deledSelects[0],
+              data:item.tagType?item:item.tags,
               index:arr[1]
             });
           dispatch({

+ 12 - 5
src/store/actions/checkBody.js

@@ -318,12 +318,19 @@ export function setImportCheckbodyLabel(state,action) {
 export function recoveTag(state,action) {
   let res = Object.assign({},state);
   let arr = [...res.data];
-  arr.splice(action.index,0,action.data);
+  const isArr= !action.data.tagType;
+  if(!isArr){
+    arr.splice(action.index,0,action.data);
+  }else{
+    arr.splice(action.index,0,...action.data);
+  }
   const dataArr = checkFullfillText(arr);
-  let nextLabel = dataArr.newArr[(+action.index)+1];
-  //展开收起状态
-  if(nextLabel.tagType==8){
-    nextLabel.showInCheck=action.data.showInCheck;
+  if(!isArr){
+    let nextLabel = dataArr.newArr[(+action.index)+1];
+    //展开收起状态
+    if(nextLabel.tagType==8){
+      nextLabel.showInCheck=action.data.showInCheck;
+    }
   }
   res.data = dataArr.newArr;
   res.saveText = dataArr.saveText;

+ 5 - 1
src/utils/tools.js

@@ -1303,7 +1303,11 @@ function resetTagtype(data){
 //记录最近3次被删除的标签
 function handleLocalDelTag(mark,index,tag){
   const deledTag =  localStorage.getItem('deletedTags')?JSON.parse(localStorage.getItem('deletedTags')):[];
-  deledTag.unshift(Object.assign({},tag,{delIndex:mark+'-'+index}));
+  if(tag.tagType){
+    deledTag.unshift(Object.assign({},tag,{delIndex:mark+'-'+index}));
+  }else{
+    deledTag.unshift({tags:tag,delIndex:mark+'-'+index});
+  }
   deledTag.length = deledTag.length>config.recoverTagNum?config.recoverTagNum:deledTag.length;
   localStorage.setItem('deletedTags',JSON.stringify(deledTag));
 }

+ 5 - 3
src/utils/utils.js

@@ -1,5 +1,5 @@
 import config from '@config/index.js';
-import {getLabelIndex,checkFullfillText,fullfillText,shiftLocalDelTag,getEMRParams,storageLocal} from './tools';
+import {getLabelIndex,checkFullfillText,fullfillText,shiftLocalDelTag,getEMRParams,storageLocal,handleLocalDelTag} from './tools';
 import { json } from "./ajax";
 /**
  * 各类标签统一的处理函数
@@ -248,11 +248,13 @@ export function deleteSelectedLabels(state,action){
     n=Math.abs(end-start)+2;
   }
   if(start>end){      //从后往前选中
-    arr.splice(end,n);
+    const temp = arr.splice(end,n);
+    handleLocalDelTag(boxMark,end,temp);
   }else if(start===end){
     return res;
   }else{
-    arr.splice(start,n);
+    const temp = arr.splice(start,n);
+    handleLocalDelTag(boxMark,start,temp);
   }
   const newObj = boxMark=='4'?checkFullfillText(arr):fullfillText(arr);
   res.data = newObj.newArr;