Explorar o código

查体杂音类型selecteds改到标签数据中

zhouna %!s(int64=5) %!d(string=hai) anos
pai
achega
acbc13773b

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

@@ -44,7 +44,7 @@ class CheckBody extends Component{
     return false;
   }
   getLabels(){
-    const {data,showArr,saveText,selecteds,importLabel,setHighter} = this.props;
+    const {data,showArr,saveText,importLabel,setHighter} = this.props;
     let arr = [],list=[];
     const {boxMark,showAll} = this.state;
     const moreNum =data.length-[...data].reverse().findIndex((it)=>it.showInCheck)-1;//被隐藏的位置
@@ -62,7 +62,7 @@ class CheckBody extends Component{
       arr = list.map((it,i)=>{
         const preIsExt = list[i-1]&&list[i-1].specFlag===4?true:false;//前一个标签是否为体征标签
         const afterIsExt = list[i+1]&&list[i+1].specFlag===4?true:false;//后一个标签是否为体征标签
-        return chooseType({item:it,preIsExt,afterIsExt,boxMark,i,showArr,saveText,selecteds,importLabel,setHighter});
+        return chooseType({item:it,preIsExt,afterIsExt,boxMark,i,showArr,saveText,importLabel,setHighter});
       });
     }
     showMoreBtn&&arr.push(more);      //是否显示收起展开按钮

+ 1 - 1
src/components/SpreadDrop/index.jsx

@@ -15,7 +15,7 @@ import $ from 'jquery';
  * placeholder:灰显文字
  * ikey:当前标签的index
  * copyType:选中后是否复制本身(仅展开类型使用)
- * selecteds:选中选项(仅展开类型使用)
+ * data.selecteds:选中选项(仅展开类型使用)
  * show:是否显示下拉
  * order:成文顺序,0点选顺序,1从上到下从左到右
  * isImports:是否高亮显示(仅查体中使用)

+ 0 - 1
src/containers/CheckBody.js

@@ -22,7 +22,6 @@ function mapStateToProps(state){
     focusTextIndex:checkBody.focusIndex,    //聚焦的自由文本标签index
     span:checkBody.span,
     searchInEnd:checkBody.searchInEnd,      //是否在搜索末尾插入结果
-    selecteds:checkBody.selecteds,       //普通多选选中状态
     importLabel:checkBody.importLabel,    //需高亮的标签id
   }
 }

+ 1 - 0
src/containers/SpreadDrop.js

@@ -358,6 +358,7 @@ function checkBodyCheck(dispatch,store,params){
   let existsName = getNames(exists,order);
   let withsName = getNames(withs);
   let labelInx = getLabelIndex(ikey);
+  delete params.mainData;     //该数据不用保存到state,删除避免死循环
   dispatch({
     type:SETCHECKBOX,
     // data:{labelInx,ikey,exclusion,excluName,nones,exists,existsName,noneIds,noneOn,nowOn,withOn,withs,withsName}

+ 2 - 2
src/containers/eleType.js

@@ -139,7 +139,7 @@ function multLabels(params){
 //多选标签展开型
 function multCheckLabels(params,tagType){
   const data = params.item;
-  const {i,boxMark,showArr,selecteds,importLabel,setHighter} = params;
+  const {i,boxMark,showArr,importLabel,setHighter} = params;
   let isHigh=importLabel&&importLabel.includes(data.id);
   const showInx = boxMark+"-"+i+'-0';
   return <SpreadDrop data={data.questionMapping}
@@ -150,7 +150,7 @@ function multCheckLabels(params,tagType){
                      value={data.value}
                      copyType={data.copyType}
                      isExtBlue={data.specFlag===4?true:false}
-                     selecteds={selecteds ?selecteds[i]:[]}
+                     selecteds={data.selecteds}
                      show={showArr&&showArr[showInx]}
                      order={data.textGenerate}
                      isImports={isHigh}

+ 9 - 24
src/store/actions/checkBody.js

@@ -37,16 +37,16 @@ export const confirm = (state,action) =>{
   const items = [...exists||[],...withs||[]];
   if((!exists||!withs||items.length==0)&&!nones&&!exclusion){       //取消无殊的选中,空白提交
     arr[ikey].value = '';
+    arr[ikey].selecteds = [];
     res.saveText[ikey] = '';
-    res.selecteds.splice(ikey,1);
     res.update=Math.random();
     return res;
   }
   //选中互斥项
   if(exclusion){
     arr[ikey].value = excluName;
+    arr[ikey].selecteds = action.data;
     res.saveText[ikey] = excluName;
-    res.selecteds[ikey] = action.data;
     res.update=Math.random();
     return res;
   }
@@ -60,7 +60,7 @@ export const confirm = (state,action) =>{
   if(items.length==0&&nones){
     arr[ikey-1].value = newPreText;
     res.saveText[ikey-1] = newPreText;
-    res.selecteds[ikey] = null;       //无殊选中状态遗留bug修改
+    //res.selecteds[ikey] = null;       //无殊选中状态遗留bug修改
     res.update=Math.random();
     return res;
   }
@@ -93,7 +93,7 @@ export function setCheckBoxValue(state,action) {
     showText = showText.substr(0,showText.length-1);
   }
   res.data[labelInx].value = showText;
-  res.selecteds[labelInx] = action.data;
+  res.data[labelInx].selecteds = action.data;
   res.saveText = checkFullfillText(res.data).saveText;
   res.update = Math.random();
   return res;
@@ -131,13 +131,9 @@ export function insertLabelData(state,action){
     if(searchInEnd){
       res.data.splice(index,1,pText,...spreadLabels,text);
       res.saveText = checkFullfillText(res.data).saveText;
-      //res.saveText.splice(index,1,newText,'','');
-      res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null),null);
     }else{
       res.data.splice(index,1,text,...spreadLabels,pText);
       res.saveText = checkFullfillText(res.data).saveText;
-      //res.saveText.splice(index,1,'','',newText);
-      res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null),null);
     }
 
   }else{
@@ -145,11 +141,9 @@ export function insertLabelData(state,action){
     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 = [];    //选中清空搜索内容(即关闭搜索弹窗)
@@ -206,9 +200,8 @@ export const changeLabelVal = (state,action)=>{//双击标签输入改变值
     }
   }else{//删除完标签内容则删除该标签
     const num = nextIsDot?2:1;
-    handleLocalDelTag('4',index,res.data[index],res.selecteds[index]);
+    handleLocalDelTag('4',index,res.data[index]);
     res.data.splice(index,num);
-    res.selecteds.splice(index,num);//杂音类样式选中状态对应
     res.saveText = checkFullfillText(res.data).saveText;
   }
   res.update = Math.random();
@@ -225,7 +218,6 @@ export function clearCheckBody(state,action){  //清空
   res.preData = [];
   res.saveText = action.saveText;
   res.isEmpty = action.isEmpty;
-  res.selecteds = action.selecteds?action.selecteds:[];
   if(action.flg){res.showAll = true}
   return res;
 }
@@ -242,13 +234,11 @@ export function backspaceText(state,action){
       // data[delIndex].value = text;
     }else if(data[inx].tagType==8){
       data.splice(delIndex,1);
-      res.selecteds.splice(delIndex,1);      //杂音类样式选中状态对应
       res.saveText.splice(delIndex,1);
     }else{
-      handleLocalDelTag(4,inx,data[inx],res.selecteds[inx]);
+      handleLocalDelTag(4,inx,data[inx]);
       const n = action.text.length>0&&(config.punctuationReg.test(action.text))?1:2;
       data.splice(inx,n);
-      res.selecteds.splice(inx,n);
       res.saveText.splice(inx,n);
     }
   }else if(flag == 'del'){
@@ -257,12 +247,10 @@ export function backspaceText(state,action){
       
     }else if(data[inx] && data[inx].tagType==8){
       data.splice(delIndex,1);
-      res.selecteds.splice(delIndex,1);      //杂音类样式选中状态对应
       res.saveText.splice(delIndex,1);
     }else{
-      handleLocalDelTag(4,delIndex,data[inx],res.selecteds[inx]);
+      handleLocalDelTag(4,delIndex,data[inx]);
       data.splice(delIndex,2);
-      res.selecteds.splice(delIndex,2);  
       res.saveText.splice(delIndex,2);
     }
   }
@@ -280,6 +268,7 @@ export function multipleComfirn(state,action){
     let item = data[ikey].questionMapping;
     let arr=[];
     item[index].value = seleData;
+    item[index].selecteds[ikey] = {[index]:action.data};
     item.map((it)=>{
       if(it.value){
         arr.push(it.labelPrefix+it.value+it.labelSuffix);
@@ -287,12 +276,11 @@ export function multipleComfirn(state,action){
     });
     res.saveText[ikey] = arr.join("");
     res.update = Math.random();
-    res.selecteds[ikey] = {[index]:action.data};
     return res;
   }
   data[ikey].value = seleData;
+  data[ikey].selecteds = action.data;
   res.saveText[ikey] = seleData;
-  res.selecteds[ikey] = action.data;
   res.update = Math.random();
   return res;
 }
@@ -324,9 +312,7 @@ export function setImportCheckbodyLabel(state,action) {
 export function recoveTag(state,action) {
   let res = Object.assign({},state);
   let arr = [...res.data];
-  let slts = [...res.selecteds];
   arr.splice(action.index,0,action.data);
-  slts.splice(action.index,0,action.select);
   const dataArr = checkFullfillText(arr);
   let nextLabel = dataArr.newArr[(+action.index)+1];
   //展开收起状态
@@ -335,7 +321,6 @@ export function recoveTag(state,action) {
   }
   res.data = dataArr.newArr;
   res.saveText = dataArr.saveText;
-  res.selecteds = slts;
   shiftLocalDelTag();
   res.update = Math.random();
   return res;

+ 1 - 1
src/store/reducers/checkBody.js

@@ -13,7 +13,7 @@ const initState = {
                 data:[block],
                 saveText:[],    //saveText为生成的纯文本
                 searchData:[],
-                selecteds:[],
+                //selecteds:[],
                 focusIndex:'',
                 isEmpty:true,      //是否为空白,需要请求数据
                 showSearchBox:false,

+ 1 - 10
src/utils/tools.js

@@ -1314,26 +1314,17 @@ function resetTagtype(data){
 }
 
 //记录最近3次被删除的标签
-function handleLocalDelTag(mark,index,tag,select){
+function handleLocalDelTag(mark,index,tag){
   const deledTag =  localStorage.getItem('deletedTags')?JSON.parse(localStorage.getItem('deletedTags')):[];
   deledTag.unshift(Object.assign({},tag,{delIndex:mark+'-'+index}));
   deledTag.length = deledTag.length>config.recoverTagNum?config.recoverTagNum:deledTag.length;
   localStorage.setItem('deletedTags',JSON.stringify(deledTag));
-  if(select){     //记录被删除的杂音类型标签选中内容数据
-    const deledSlt =  localStorage.getItem('deletedSelects')?JSON.parse(localStorage.getItem('deletedSelects')):[];
-    deledSlt.unshift(Object.assign({},select));
-    deledSlt.length = deledSlt.length>config.recoverTagNum?config.recoverTagNum:deledSlt.length;
-    localStorage.setItem('deletedSelects',JSON.stringify(deledSlt));
-  }
 }
 
 //删除被恢复的标签
 function shiftLocalDelTag(){
   const deledTags = localStorage.getItem('deletedTags')?JSON.parse(localStorage.getItem('deletedTags')):[];
-  const deledSelects = localStorage.getItem('deletedSelects')?JSON.parse(localStorage.getItem('deletedSelects')):[];
   deledTags.shift();
-  deledSelects.shift();
-  localStorage.setItem('deletedSelects',JSON.stringify(deledSelects));
   localStorage.setItem('deletedTags',JSON.stringify(deledTags));
 }
 //弹窗显示问题