Browse Source

其他史有伴无排序

zhouna 6 years ago
parent
commit
b876b6b8dc
2 changed files with 20 additions and 15 deletions
  1. 5 3
      src/containers/OtherHistory.js
  2. 15 12
      src/store/actions/otherHistory.js

+ 5 - 3
src/containers/OtherHistory.js

@@ -2,12 +2,11 @@ import React from 'react';
 import {connect} from 'react-redux';
 import OtherHistory from "../components/OtherHistory";
 import {SETSELECTED,CLEARSELECTED,CONFIRMSELECTED,SELECTOTHERSEARCHDATA,SETDATA,SETTEXTMODEVALUE,OTHEREDICLEAR} from '@types/otherHistory';
-import {HIDE,RESET} from '@store/types/homePage.js';
+import {HIDE,RESET,ISREAD} from '@store/types/homePage.js';
 import {getModule} from '@store/async-actions/fetchModules.js';
 import {billing} from '@store/async-actions/pushMessage';
 import {fullfillText} from '@common/js/func';
 import {didPushParamChange} from '@utils/tools.js';
-import {ISREAD} from "../store/types/homePage";
 
 function mapStateToProps(state){
   const {otherHistory,homePage,typeConfig,mainSuit} = state;
@@ -67,7 +66,10 @@ function mapDispatchToProps(dispatch,store){
             data: res.data.data,
             span,
             isReplace:false
-          })
+          });
+          dispatch({
+            type:ISREAD
+          });
         }
       });
     },

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

@@ -6,7 +6,8 @@ export const confirm = (state,action) =>{
   let res = Object.assign({},state);
   let arr = res.data;
   const {nones,exists,withs,ikey,exclusion,excluName,copyType} = action.data;
-  if((!exists||!withs||[...exists,...withs].length==0)&&!nones&&!exclusion){       //取消无殊的选中,空白提交
+  const items = [...exists||[],...withs||[]];
+  if((!exists||!withs||items.length==0)&&!nones&&!exclusion){       //取消无殊的选中,空白提交
     arr[ikey].value = '';
     res.saveText[ikey] = '';
     res.selecteds.splice(ikey,1);
@@ -26,25 +27,27 @@ export const confirm = (state,action) =>{
     arr.splice(ikey,1);
   }
   if(arr[ikey].value)  arr[ikey].value= '';
-  let newPreText = (arr[ikey-1].value||arr[ikey-1].name||'')+nones;//console.log(arr[ikey-1],newPreText)
-  if([...exists,...withs].length==0&&nones){
+  let preText = arr[ikey-1].value!==undefined?arr[ikey-1].value:arr[ikey-1].name||'';
+  let newPreText =preText +nones;//console.log(arr[ikey-1],newPreText)
+  if(items.length==0&&nones){
     arr[ikey-1].value = newPreText;
     res.saveText[ikey-1] = newPreText;
     res.update=Math.random();
     return res;
   }
-  //有,无,伴随配
-    arr.splice(ikey-1,1);
-    let flabel = [...exists,...withs][0];         //要插入的第一个标签
-    let text = newPreText;
-    //要插入的第一个标签为自由文本,则和前一个文本标签文字合并
+  //有,伴,无随配
+    //arr.splice(ikey-1,1);
+    let flabel = items[items.length-1];         //要插入的最后一个标签
+    let labelText = flabel.value!==undefined?flabel.value:flabel.name;
+    let text = labelText;
+    //要插入的最后一个标签为自由文本,则和后面的文本标签文字合并
     if(flabel.tagType==8){
-      flabel.value = newPreText+(flabel.value||flabel.name);
+      flabel.value = labelText+nones;
       text = flabel.value;
     }
-    arr.splice(ikey-1,0,...exists,...withs);
-    arr[ikey-1].value = text;
-    res.saveText[ikey-1] = text;
+    arr.splice(ikey,0,...exists,...withs);
+    //arr[ikey-1].value = text;
+    res.saveText[ikey+items.length] = text;
     res.update=Math.random();         //用于触发组件更新(data变化了因在对象中无法被组件检测到)
     return res;
 };