瀏覽代碼

单选、多选、时间单位组件双击编辑删除完内容时删除该标签

liucf 6 年之前
父節點
當前提交
6a1725db7f

+ 7 - 1
src/containers/NumberUnitDrop.js

@@ -3,7 +3,7 @@ import {connect} from 'react-redux';
 import NumberUnitDrop from "@components/NumberUnitDrop";
 import {SETNUMBER,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
 import {SETNUMBER4,CHANGECHECKTEXTLABEL} from '@types/checkBody.js';
-import {SETDROPSHOW,CLICKCOUNT,HIDE,RESET,HIDEDROP} from '@types/homePage.js';
+import {SETDROPSHOW,CLICKCOUNT,HIDE,RESET,HIDEDROP,ISREAD} from '@types/homePage.js';
 import {NUMBER_SELECT,CHANGE_LABELVAL} from '@store/types/mainSuit.js';
 import {getLabelIndex} from '@common/js/func.js';
 import {CURRENT_NUMBER,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
@@ -124,6 +124,12 @@ function mapDispatchToProps(dispatch,store){
           clearTimeout(timer);
         }
       },config.delayPushTime);
+      if(!params.text.trim()){
+        dispatch({
+          type:ISREAD
+        })
+      }
+      
     },
     handleDbclick(obj){
       dispatch({

+ 4 - 1
src/containers/RadioDrop.js

@@ -3,7 +3,7 @@ import {connect} from 'react-redux';
 import RadioDrop from "@components/RadioDrop";
 import {SETRADIO,CLEARSELECTED,CONFIRMSELECTED,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
 import {SETSELECTED4,CHANGECHECKTEXTLABEL} from '@types/checkBody';
-import {SETDROPSHOW,HIDE,RESET,HIDEDROP,CLICKCOUNT} from '@types/homePage.js';
+import {SETDROPSHOW,HIDE,RESET,HIDEDROP,CLICKCOUNT,ISREAD} from '@types/homePage.js';
 import {RADIO_SELECT,CHANGE_LABELVAL} from '@store/types/mainSuit.js';
 import {CURRENT_RADIO,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
 import {Notify} from '@commonComp';
@@ -128,6 +128,9 @@ function mapDispatchToProps(dispatch,store){
         data:{changeVal:params.changeVal,ikey:ikey}
       });
       dispatch(billing);
+      dispatch({
+        type:ISREAD
+      })
     },
     handleShow(obj) {
       dispatch({

+ 3 - 0
src/containers/SpreadDrop.js

@@ -331,6 +331,9 @@ function handleLabel(dispatch,params){
     default:
   }
   dispatch(billing);
+  dispatch({
+    type:ISREAD
+  })
 }
 
 function mapDispatchToProps(dispatch,store){

+ 10 - 4
src/store/actions/checkBody.js

@@ -163,10 +163,16 @@ export const changeLabelVal = (state,action)=>{//双击标签输入改变值
   const newVal = action.data.changeVal;     //下拉修改的内容
   const totalVal = action.data.totalVal;    //包含前后缀修改的内容
   let item = res.data[index];
-  if(item){
-    item.value = newVal;
-  }
-  res.saveText[index] = totalVal;
+  if(newVal.trim()){
+    if(item){
+      item.value = newVal;
+      res.saveText[index] = totalVal;
+    }
+  }else{//删除完标签内容则删除该标签
+    res.data.splice(index,1);
+    res.saveText = fullfillText(res.data).saveText;
+  } 
+  
   res.update = Math.random();
   return res;
 }

+ 29 - 17
src/store/actions/currentIll.js

@@ -277,19 +277,26 @@ export function setNumberValue(state,action){
   let labelInx = getLabelIndex(index);
   const subInx = index.substr(index.length-1);
   let item = res.data[labelInx];
-  if(+item.tagType===1){
-    item.value = param.text;
-    res.saveText[labelInx] = param.text?item.labelPrefix+param.text+item.labelSuffix:'';
-  }else{
-    item.questionMapping[subInx].value = param.text;
-    let hasValue = false;
-    const sub = item.questionMapping.map((it)=>{
-      if(it.value){     //至少有一个子值才黑显
-        hasValue = true;
-      }
-      return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
-    });
-    res.saveText[labelInx] = hasValue?sub.join(''):'';
+  if(param.text.trim()){
+    if(+item.tagType===1){
+      item.value = param.text;
+      res.saveText[labelInx] = param.text?item.labelPrefix+param.text+item.labelSuffix:'';
+    }else{
+      item.questionMapping[subInx].value = param.text;
+      let hasValue = false;
+      const sub = item.questionMapping.map((it)=>{
+        if(it.value){     //至少有一个子值才黑显
+          hasValue = true;
+        }
+        return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
+      });
+      // res.saveText[labelInx] = sub.join(',');
+      res.saveText[labelInx] = hasValue?sub.join(''):'';
+      item.value = sub.join('');
+    }
+  }else{//删除完标签内容则删除该标签
+    res.data.splice(labelInx,1);
+    res.saveText = fullfillText(res.data).saveText;
   }
   res.update = Math.random();
   return res;
@@ -352,10 +359,15 @@ export const changeLabelVal = (state,action)=>{
   const index = action.data.ikey;
   const newVal = action.data.changeVal;
   let item = res.data[index];
-  if(item){
-    item.value = newVal;
-  }
-  res.saveText[index] = newVal;
+  if(newVal.trim()){
+    if(item){
+      item.value = newVal;
+      res.saveText[index] = newVal;
+    }
+  }else{//删除完标签内容则删除该标签
+    res.data.splice(index,1);
+    res.saveText = fullfillText(res.data).saveText;
+  } 
   res.update = Math.random();
   return res;
 }

+ 29 - 19
src/store/actions/mainSuit.js

@@ -280,21 +280,26 @@ export function setNumberValue(state,action){
   let labelInx = getLabelIndex(index);
   const subInx = index.substr(index.length-1);
   let item = res.data[labelInx];
-  if(+item.tagType===1){
-    item.value = param.text;
-    res.saveText[labelInx] = param.text?item.labelPrefix+param.text+item.labelSuffix:'';
-  }else{
-    item.questionMapping[subInx].value = param.text;
-    let hasValue = false;
-    const sub = item.questionMapping.map((it)=>{
-      if(it.value){     //至少有一个子值才黑显
-        hasValue = true;
-      }
-      return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
-    });
-    // res.saveText[labelInx] = sub.join(',');
-    res.saveText[labelInx] = hasValue?sub.join(''):'';
-    item.value = sub.join('');
+  if(param.text.trim()){
+    if(+item.tagType===1){
+      item.value = param.text;
+      res.saveText[labelInx] = param.text?item.labelPrefix+param.text+item.labelSuffix:'';
+    }else{
+      item.questionMapping[subInx].value = param.text;
+      let hasValue = false;
+      const sub = item.questionMapping.map((it)=>{
+        if(it.value){     //至少有一个子值才黑显
+          hasValue = true;
+        }
+        return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
+      });
+      // res.saveText[labelInx] = sub.join(',');
+      res.saveText[labelInx] = hasValue?sub.join(''):'';
+      item.value = sub.join('');
+    }
+  }else{//删除完标签内容则删除该标签
+    res.data.splice(labelInx,1);
+    res.saveText = fullfillText(res.data).saveText;
   }
   res.update = Math.random();
   return res;
@@ -354,10 +359,15 @@ export const changeLabelVal = (state,action)=>{
   const index = action.data.ikey;
   const newVal = action.data.changeVal;
   let item = res.data[index];
-  if(item){
-    item.value = newVal;
-  }
-  res.saveText[index] = newVal;
+  if(newVal.trim()){
+    if(item){
+      item.value = newVal;
+      res.saveText[index] = newVal;
+    }
+  }else{//删除完标签内容则删除该标签
+    res.data.splice(index,1);
+    res.saveText = fullfillText(res.data).saveText;
+  }  
   res.update = Math.random();
   return res;
 }

+ 9 - 4
src/store/actions/otherHistory.js

@@ -201,10 +201,15 @@ export function changeTextLabel(state,action) {
   const index = action.data.ikey;
   const newVal = action.data.changeVal;
   let item = res.data[index];
-  if(item){
-    item.value = newVal;
-  }
-  res.saveText[index] = newVal;
+  if(newVal.trim()){
+    if(item){
+      item.value = newVal;
+      res.saveText[index] = newVal;
+    }
+  }else{//删除完标签内容则删除该标签
+    res.data.splice(index,1);
+    res.saveText = fullfillText(res.data).saveText;
+  } 
   res.update = Math.random();
   return res;
 }