浏览代码

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

zhouna 6 年之前
父节点
当前提交
731f09d335
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. 10 3
      src/components/SpreadDrop/index.jsx

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

@@ -224,14 +224,21 @@ class SpreadDrop extends Component{
       return;
     }
     //操作单选项
-    if(selected){
+    if(!noneOn&&selected){
       const tIndex= exists.findIndex((it)=>it.questionId===item.questionId);
+      const bIndex= withs.findIndex((it)=>it.questionId===item.questionId);
       if(tIndex!=-1){
         exists.splice(tIndex,1,item);
         this.setState({
           exists,
         })
       }
+      if(bIndex!=-1){
+        withs.splice(tIndex,1,item);
+        this.setState({
+          withs,
+        })
+      }
       return;
     }
     if(exclusion!==''){     //互斥项被选中,其他不可操作
@@ -287,7 +294,7 @@ class SpreadDrop extends Component{
         nones += name+'、';
         noneIds.push(id);
       }else if(nowOn=='with'){
-        withs.push({id:id,name:name});
+        withs.push({id:id,name:name,questionId:item.questionId});
       }else{
         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;
       });*/
       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{
         handleClick&&handleClick(item,isExclu,joint,index);
       }