Jelajahi Sumber

查体组合项中单选带输入事件处理

zhouna 6 tahun lalu
induk
melakukan
d0f2ee6d3f

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

@@ -2,6 +2,7 @@ import React,{Component} from 'react';
 import classNames from 'classnames';
 import RadioDrop from "@containers/RadioDrop";
 import NumberDrop from "@containers/NumberDrop";
+import RadioInpDrop from "@containers/RadioInpDrop";
 import InlineTag from '@containers/InlineTag';
 import addIcon from '@images/addItem.png';
 import style from "./index.less";
@@ -39,7 +40,7 @@ class MultSpread extends Component{
     return classNames(isSelected,hasAdd);
   }
   getLabels(){
-    const {data,ikey,showArr,copyId} = this.props;
+    const {data,ikey,showArr,copyId,boxMark} = this.props;
     const {editable}= this.state;
     let show = false;
     let inx = '';
@@ -90,6 +91,16 @@ class MultSpread extends Component{
                              patId = {copyId}
                              value={it.value}
                              hideTag={true}></NumberDrop>;
+        case +it.controlType===11:
+          return <RadioInpDrop data={it.questionDetailList}
+                             vals={it.vals}
+                             placeholder={it.name}
+                             show={showArr&&showArr[inx]}
+                             value = {it.value}
+                             boxMark={boxMark}
+                             id={it.id}
+                             ikey={inx}
+                             hideTag={true}></RadioInpDrop>;
         default:
           return it.name;
       }

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

@@ -55,7 +55,7 @@ class RadioInpDrop extends Component{
     return style['tag'];
   }
   handleSelect(item){
-    const {handleSelect,ikey,mainSaveText,value,placeholder} = this.props;
+    const {handleSelect,ikey,value,placeholder} = this.props;
     let vals = {}, inx = 0;
     if(!item){
       handleSelect&&handleSelect({ikey});  //清空
@@ -75,7 +75,7 @@ class RadioInpDrop extends Component{
     this.setState({
       texts:vals
     });
-    handleSelect&&handleSelect({ikey,id:item.id,values:vals,mainSaveText});
+    handleSelect&&handleSelect({ikey,id:item.id,values:vals});
   }
   handleShow(e){
     //e.stopPropagation();

+ 1 - 1
src/config/index.js

@@ -43,6 +43,6 @@ export default {
       age:"岁",
     },
     showCheckNum:16,        //查体默认展开非自由文本标签的个数
-    radioOptionPer:'( )',     //单选项输入占位符
+    radioOptionPer:'()',     //单选项输入占位符
     Params
 };

+ 3 - 6
src/containers/RadioInpDrop.js

@@ -14,7 +14,7 @@ import config from '@config/index.js';
 
 function mapStateToProps(state){
   return {
-    mainSaveText:state.mainSuit.saveText,
+    //mainSaveText:state.mainSuit.saveText,
   }
 }
 
@@ -64,11 +64,10 @@ function otherSelect(dispatch,params){
 //查体单选下拉选中事件
 function checkSelect(dispatch,params){
   const {ikey,id,values} = params;
-  let index = getLabelIndex(ikey);
   dispatch({
     type:SET_CK_RADIO_INPUT_VAL,
     data:{
-      ikey:index,
+      ikey,
       id,
       values
     }
@@ -143,9 +142,7 @@ function mapDispatchToProps(dispatch,store){
       });
     },
     handleSaveInp(params){
-      const {boxMark} = params;
-      const index = params.ikey;
-      let ikey = getLabelIndex(index);
+      const {boxMark,ikey} = params;
       dispatch({
         type:InputActions[+boxMark],
         data:{values:params.values,ikey:ikey}

+ 1 - 0
src/containers/eleType.js

@@ -105,6 +105,7 @@ function multLabels(params){
                      fullData = {data}
                      showArr={showArr||{}}
                      update={Math.random()}
+                     boxMark={boxMark}
                      ikey={boxMark+i}
                      saveText={saveText}
                      name={data.name||data.tagName}

+ 29 - 5
src/store/actions/checkBody.js

@@ -138,8 +138,13 @@ export function setRadioValue(state,action){
 export const setRadioInputValue = (state,action)=>{
   const res = Object.assign({},state);
   const {ikey,values,id} = action.data;
-  const item = res.data[ikey];
-  let str='',temp='',obj=res.data[ikey].questionDetailList;
+  let index = getLabelIndex(ikey);
+  let innerInx = ikey.substr(ikey.length-1);
+  let item = res.data[index];
+  if(item.tagType==3){      //在组合项中
+    item = res.data[index].questionMapping[innerInx];
+  }
+  let str='',temp='',obj=item.questionDetailList;
   if(!values){    //清空
     let sld=obj.find((item)=>{
       return item.selected==true;
@@ -147,7 +152,18 @@ export const setRadioInputValue = (state,action)=>{
     sld?sld.selected=false:'';
     item.vals = null;
     item.value = '';
-    res.saveText[ikey] = '';
+    if(res.data[index].tagType==3){
+      let hasValue = false;
+      const sub = res.data[index].questionMapping.map((it)=>{
+        if(it.value){     //至少有一个子值才黑显
+          hasValue = true;
+        }
+        return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
+      });
+      res.saveText[index] = hasValue?sub.join(''):'';
+    }else{
+      res.saveText[index] = '';
+    }
     res.update = Math.random();
     return res;
   }
@@ -171,7 +187,15 @@ export const setRadioInputValue = (state,action)=>{
   }
   item.vals = values;
   item.value = str;
-  res.saveText[ikey] = str;
+  if(res.data[index].tagType==3){
+    let hasValue = false;
+    const sub = res.data[index].questionMapping.map((it)=>{
+      return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
+    });
+    res.saveText[index] = sub.join('');
+  }else {
+    res.saveText[ikey] = str;
+  }
   res.update = Math.random();
   return res;
 }
@@ -232,7 +256,7 @@ export function insertLabelData(state,action){
   let res = Object.assign({},state);
   const text = Object.assign({},JSON.parse(config.textLabel));
   const searchStr = res.searchStr;
-  const {index,data,isReplace,span,searchInEnd}=action;console.log("查体",data);
+  const {index,data,isReplace,span,searchInEnd}=action;
   const showText = res.saveText[index];
   const spreadLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
   let reg = searchInEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);

+ 1 - 0
src/utils/tools.js

@@ -513,6 +513,7 @@ function filterArr(arr){
 function filterDataArr(arrTmp){   //数据处理
     let tmpArr = [];
     tmpArr = arrTmp.map((it,i)=>{     //连续的标点符号保留第一个
+      if(!it)return '';
       if(!it.match(config.punctuationReg)&&!arrTmp[i-1]){        //只有标点符号或者前一个标签无值是(说明本标点灰显,不显示在预览中)
           return '';
       }