Browse Source

杂音类型伴,有时内容可单选,无都多选

zhouna 6 years ago
parent
commit
731f09d335
1 changed files with 10 additions and 3 deletions
  1. 10 3
      src/components/SpreadDrop/index.jsx

+ 10 - 3
src/components/SpreadDrop/index.jsx

@@ -224,14 +224,21 @@ class SpreadDrop extends Component{
       return;
       return;
     }
     }
     //操作单选项
     //操作单选项
-    if(selected){
+    if(!noneOn&&selected){
       const tIndex= exists.findIndex((it)=>it.questionId===item.questionId);
       const tIndex= exists.findIndex((it)=>it.questionId===item.questionId);
+      const bIndex= withs.findIndex((it)=>it.questionId===item.questionId);
       if(tIndex!=-1){
       if(tIndex!=-1){
         exists.splice(tIndex,1,item);
         exists.splice(tIndex,1,item);
         this.setState({
         this.setState({
           exists,
           exists,
         })
         })
       }
       }
+      if(bIndex!=-1){
+        withs.splice(tIndex,1,item);
+        this.setState({
+          withs,
+        })
+      }
       return;
       return;
     }
     }
     if(exclusion!==''){     //互斥项被选中,其他不可操作
     if(exclusion!==''){     //互斥项被选中,其他不可操作
@@ -287,7 +294,7 @@ class SpreadDrop extends Component{
         nones += name+'、';
         nones += name+'、';
         noneIds.push(id);
         noneIds.push(id);
       }else if(nowOn=='with'){
       }else if(nowOn=='with'){
-        withs.push({id:id,name:name});
+        withs.push({id:id,name:name,questionId:item.questionId});
       }else{
       }else{
         exists.push({id:id,name:name,listIndex,questionId:item.questionId});
         exists.push({id:id,name:name,listIndex,questionId:item.questionId});
       }
       }
@@ -421,7 +428,7 @@ class ListItem extends Component{
         return exists.findIndex((i)=>i.questionId===it.id)!==-1||noneIds.includes(it.id)||withs.findIndex((i)=>i.questionId===it.id)!==-1;
         return exists.findIndex((i)=>i.questionId===it.id)!==-1||noneIds.includes(it.id)||withs.findIndex((i)=>i.questionId===it.id)!==-1;
       });*/
       });*/
       if(selected&&selected.id!=item.id){     //该列已有选中项,传回已选中的id,name取消选中
       if(selected&&selected.id!=item.id){     //该列已有选中项,传回已选中的id,name取消选中
-        handleClick&&handleClick(item,isExclu,joint,index,{id:selected.id,name:selected.name});
+        handleClick&&handleClick(item,isExclu,joint,index,{id:selected.id,name:selected.name,questionId:selected.questionId});
       }else{
       }else{
         handleClick&&handleClick(item,isExclu,joint,index);
         handleClick&&handleClick(item,isExclu,joint,index);
       }
       }