Преглед на файлове

查体组合中多选事件处理

zhouna преди 6 години
родител
ревизия
5bada51ef4

+ 17 - 1
src/components/MultSpread/index.jsx

@@ -4,6 +4,7 @@ import RadioDrop from "@containers/RadioDrop";
 import NumberDrop from "@containers/NumberDrop";
 import RadioInpDrop from "@containers/RadioInpDrop";
 import InlineTag from '@containers/InlineTag';
+import Multiple from '@containers/Multiple';
 import addIcon from '@images/addItem.png';
 import style from "./index.less";
 import tools from '@utils/tools';
@@ -40,7 +41,7 @@ class MultSpread extends Component{
     return classNames(isSelected,hasAdd);
   }
   getLabels(){
-    const {data,ikey,showArr,copyId,boxMark} = this.props;
+    const {data,ikey,showArr,copyId,selecteds,boxMark} = this.props;
     const {editable}= this.state;
     let show = false;
     let inx = '';
@@ -62,6 +63,21 @@ class MultSpread extends Component{
                             id={it.id}
                             patId = {copyId}
                             hideTag={true}></RadioDrop>;
+        case +it.controlType===2:
+          const dataList = it.questionDetailList&&it.questionDetailList.length>0?it.questionDetailList:it.questionMapping;
+          return <Multiple data={dataList}
+                           ikey={inx}
+                           placeholder={it.name}
+                           value={it.value}
+                           copyType={it.copyType}
+                           selecteds={selecteds ?selecteds[i]:[]}
+                           show={showArr&&showArr[inx]}
+                           order={it.textGenerate}
+                           type={boxMark}
+                           textPrefix={it.labelPrefix}
+                           textSuffix={it.labelSuffix}
+                           id={it.id}
+                           hideTag={true}></Multiple>;
         case +it.controlType===5://带单位数字键盘
         return <NumberUnitDrop prefix={it.labelPrefix}
                                suffix={it.labelSuffix}

+ 5 - 4
src/components/Multiple/index.jsx

@@ -40,15 +40,16 @@ class Multiple extends react.Component{
   }
 
   getClass(){
-    if(this.props.show){
+    const {show,value,hideTag} = this.props;
+    if(show){
       $(this.$div.current).addClass(style['borderd']);
     }else{
       $(this.$div.current).removeClass(style['borderd']);
     }
-    if(this.props.value){
-      return style['selected-tag'];
+    if(value){
+      return hideTag?style['hide-tag']:style['selected-tag'];
     }
-    return style['tag'];
+    return hideTag?'':style['tag'];
   }
 
   getListClass(){

+ 5 - 0
src/components/Multiple/index.less

@@ -16,6 +16,11 @@
   border-bottom: 1px @border-color solid;
   line-height: 22px;
 }
+.hide-tag{
+  padding: 0;
+  color: @text-color;
+  line-height: 22px;
+}
 .list{
   .pop;
   padding: 0 0 10px;

+ 1 - 1
src/containers/Multiple.js

@@ -50,7 +50,7 @@ function handleCheckBody(dispatch,params){
   const index = getLabelIndex(ikey);
   dispatch({
     type:CHECKBODY_MUL,
-    data:{seleData,seleId,ikey:index}
+    data:{seleData,seleId,ikey:index,fullIkey:ikey}
   })
 }
 

+ 2 - 1
src/containers/eleType.js

@@ -98,7 +98,7 @@ export function singleRadio(params){
 //多标签组合型
 function multLabels(params){
   const data = params.item;
-  const {i,boxMark,showArr,saveText} = params;
+  const {i,boxMark,showArr,saveText,selecteds} = params;
   return <MultSpread data={data.questionMapping}
                      showAdd = {+data.showAdd===1}
                      copyId={data.id}
@@ -107,6 +107,7 @@ function multLabels(params){
                      update={Math.random()}
                      boxMark={boxMark}
                      ikey={boxMark+i}
+                     selecteds={selecteds&&selecteds[i]}
                      saveText={saveText}
                      name={data.name||data.tagName}
                      textPrefix={data.prefix}

+ 17 - 2
src/store/actions/checkBody.js

@@ -408,8 +408,23 @@ export function backspaceText(state,action){
 // 单列多选
 export function multipleComfirn(state,action){
   let res = Object.assign({},state);
-  const {ikey,seleData} = action.data;
-  let data = res.data;
+  const {ikey,seleData,fullIkey} = action.data;
+  let data = res.data;//console.log(action,data[ikey])
+  let index = fullIkey.substr(fullIkey.length-1,1);
+  if(data[ikey].tagType==3){    //在组合项中
+    let item = data[ikey].questionMapping;
+    let arr=[];
+    item[index].value = seleData;
+    item.map((it)=>{
+      if(it.value){
+        arr.push(it.labelPrefix+it.value+it.labelSuffix);
+      }
+    });
+    res.saveText[ikey] = arr.join("");
+    res.update = Math.random();
+    res.selecteds[ikey] = {[index]:action.data};
+    return res;
+  }
   data[ikey].value = seleData;
   res.saveText[ikey] = seleData;
   res.selecteds[ikey] = action.data;