Prechádzať zdrojové kódy

单选、数字键盘(包含时间带单位)类型处理函数提取统一处理

zhouna 5 rokov pred
rodič
commit
c3af9105e0

+ 0 - 94
src/store/actions/checkBody.js

@@ -80,100 +80,6 @@ export const confirm = (state,action) =>{
   res.update=Math.random();         //用于触发组件更新(data变化了因在对象中无法被组件检测到)
   return res;
 };
-//查体中数字键盘选中事件
-export function setNumberValue(state,action){
-  let res = Object.assign({},state);
-  const param = action.params;
-  const ikey = param.ikey;
-  let labelInx = getLabelIndex(ikey);
-  // const subInx = ikey.substr(ikey.length-1);
-  const subInx = ikey.split("-")[2];
-  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;
-      }
-      if(it.tagType===8){
-        return it.name;
-      }else{
-        if(!it.value){
-          return '';
-        }
-        return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
-      }
-      
-    });
-    res.saveText[labelInx] = hasValue?sub.join(''):'';
-  }
-  // res.saveText = fullfillText(res.data).saveText;
-  res.update = Math.random();
-  return res;
-}
-
-//查体单选下拉选中
-export function setRadioValue(state,action){
-  let res = Object.assign({},state);
-  const {ikey,id,text} = action;
-  let labelInx = getLabelIndex(ikey);
-  const subInx = ikey.split("-")[2];
-  let item = res.data[labelInx];
-  if(typeof text != 'string'){    //需要展开项--有无治疗类型
-    const len = +item.copyType === 0?1:0;
-    res.data.splice(labelInx,len,text);
-    return res;
-  }
-  if(+item.tagType===1){      //独立单选组件
-    item.value = text;
-    const exist = JSON.parse(localStorage.getItem('radio'+item.id)||null);
-    if(exist){    //选中状态处理
-      exist[0].selected=exist[0].id==id;
-      localStorage.setItem('radio'+item.id,JSON.stringify(exist));
-    }
-    item.questionDetailList.map((its)=>{
-      if(its.id === id){
-        its.selected = true;
-      }else{
-        its.selected = false;
-      }
-    });
-    res.saveText[labelInx] = text;       //单选没有前后缀
-  }else{      //组合组件中的单选组件
-    item.questionMapping[subInx].value = text;
-    let hasValue = false;
-    const sub = item.questionMapping.map((it)=>{
-      //添加选中状态
-      it.questionDetailList.map((its)=>{
-        if(its.id === id){
-          its.selected = true;
-        }else{
-          its.selected = false;
-        }
-      });
-      if(it.value){     //至少有一个子值才黑显
-        hasValue = true;
-      }
-      if(it.tagType===8){
-        return it.name;
-      }else {
-        if(!it.value){
-          return '';
-        }
-        return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
-      }
-      
-    });
-    res.saveText[labelInx] = hasValue?sub.join(''):'';
-  }
-  // res.saveText = fullfillText(res.data).saveText;
-  res.update = Math.random();
-  return res;
-}
 
 //复制标签(如血压)事件
 export function addLabelItem(state,action){

+ 0 - 85
src/store/actions/currentIll.js

@@ -407,91 +407,6 @@ export const setCheckBox = (state,action)=>{
   return res;
 }
 
-
-//数字键盘选中事件
-export function setNumberValue(state,action){
-  let res = Object.assign({},state);
-  const param = action.params;
-  const index = param.ikey;
-  let labelInx = getLabelIndex(index);
-  const subInx = index.split("-")[2];
-  let item = res.data[labelInx];
-  // 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;
-}
-
-//单选下拉选中
-export function setRadioValue(state,action){
-  let res = Object.assign({},state);
-  const {ikey,id,text} = action;
-  let labelInx = getLabelIndex(ikey);
-  const subInx = ikey.split("-")[2];
-  let item = res.data[labelInx];
-  if(+item.tagType===1){
-    item.value = text;
-    res.saveText[labelInx] = item.labelPrefix+text+item.labelSuffix;
-    const exist = JSON.parse(localStorage.getItem('radio'+item.id)||null);
-    if(exist){    //选中状态处理
-      exist[0].selected=exist[0].id==id;
-      localStorage.setItem('radio'+item.id,JSON.stringify(exist));
-    }
-    item.questionDetailList.map((its)=>{
-      if(its.id === id){
-        its.selected = true;
-      }else{
-        its.selected = false;
-      }
-    });
-  }else{
-    item.questionMapping[subInx].value = text;
-    /*if(item.questionMapping[subInx].controlType==1){//例如:有无治疗-未经治疗
-      item.value = text;
-    }else{
-      item.questionMapping[subInx].value = text;
-    }*/
-    let hasValue = false;
-    const sub = item.questionMapping.map((it)=>{
-      //添加选中状态
-      it.questionDetailList.map((its)=>{
-        if(its.id === id){
-          its.selected = true;
-        }else{
-          its.selected = false;
-        }
-      });
-
-      if(it.value){     //至少有一个子值才黑显
-        hasValue = true;
-      }
-      return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
-    });
-    res.saveText[labelInx] = hasValue?sub.join(''):'';
-  }
-  res.update = Math.random();
-  return res;
-}
-
 //双击标签输入改变值
 export const changeLabelVal = (state,action)=>{
   const res = Object.assign({},state);

+ 0 - 87
src/store/actions/mainSuit.js

@@ -571,93 +571,6 @@ if(moduleData && moduleData.length>0){
   return res;
 }
 
-
-
-//数字键盘选中事件
-export function setNumberValue(state,action){
-  let res = Object.assign({},state);
-  const param = action.params;
-  const index = param.ikey;
-  let labelInx = getLabelIndex(index);
-  const subInx = index.split("-")[2];
-  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;
-        }
-        if(it.tagType===8){
-          return it.name;
-        }else{
-          if(!it.value){
-            return '';
-          }
-          return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
-        }
-      });
-      // res.saveText[labelInx] = sub.join(',');
-      res.saveText[labelInx] = hasValue?sub.join(''):'';
-      item.value = sub.join('');
-    }
-  res.update = Math.random();
-  return res;
-}
-
-//单选下拉选中
-export function setRadioValue(state,action){
-  let res = Object.assign({},state);
-  const {ikey,id,text} = action;
-  let labelInx = getLabelIndex(ikey);
-  const subInx = ikey.split("-")[2];
-  let item = res.data[labelInx];
-  if(+item.tagType===1){
-    item.value = text;
-    res.saveText[labelInx] = item.labelPrefix+text+item.labelSuffix;
-    item.questionDetailList.map((its)=>{
-      if(its.id === id){
-        its.selected = true;
-      }else{
-        its.selected = false;
-      }
-    });
-  }else{
-    item.questionMapping[subInx].value = text;
-    let hasValue = false;
-    const sub = item.questionMapping.map((it)=>{
-      //添加选中状态
-      it.questionDetailList.map((its)=>{
-        if(its.id === id){
-          its.selected = true;
-        }else{
-          its.selected = false;
-        }
-      });
-
-      if(it.value){     //至少有一个子值才黑显
-        hasValue = true;
-      }
-      if(it.tagType===8){
-        return it.name;
-      }else{
-        if(!it.value){
-          return '';
-        }
-        return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
-      }
-    });
-    // res.saveText[labelInx] = sub.join(',');
-    res.saveText[labelInx] = hasValue?sub.join(''):'';
-    item.value = sub.join('');
-  }
-  res.update = Math.random();
-  return res;
-}
-
 //双击标签输入改变值
 export const changeLabelVal = (state,action)=>{
   const res = Object.assign({},state);

+ 0 - 74
src/store/actions/otherHistory.js

@@ -51,80 +51,6 @@ export const confirm = (state,action) =>{
   return res;
 };
 
-//单选下拉选中
-export function setRadioValue(state,action){
-  let res = Object.assign({},state);
-  const {ikey,id,text} = action;
-  let labelInx = getLabelIndex(ikey);
-  const subInx = ikey.split("-")[2];
-  let item = res.data[labelInx];
-  if(+item.tagType===1){
-    item.value = text;
-    res.saveText[labelInx] = item.labelPrefix+text+item.labelSuffix;
-    const exist = JSON.parse(localStorage.getItem('radio'+item.id)||null);
-    if(exist){    //选中状态处理
-      exist[0].selected=exist[0].id==id;
-      localStorage.setItem('radio'+item.id,JSON.stringify(exist));
-    }
-    item.questionDetailList.map((its)=>{
-      if(its.id === id){
-        its.selected = true;
-      }else{
-        its.selected = false;
-      }
-    });
-  }else{
-    item.questionMapping[subInx].value = text;
-    let hasValue = false;
-    const sub = item.questionMapping.map((it)=>{
-      //添加选中状态
-      it.questionDetailList.map((its)=>{
-        if(its.id === id){
-          its.selected = true;
-        }else{
-          its.selected = false;
-        }
-      });
-
-      if(it.value){     //至少有一个子值才黑显
-        hasValue = true;
-      }
-      return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
-    });
-    res.saveText[labelInx] = hasValue?sub.join(''):'';
-  }
-  res.update = Math.random();
-  return res;
-}
-
-//数字键盘选中事件
-export function setNumberValue(state,action){
-  let res = Object.assign({},state);
-  const param = action.params;
-  const ikey = param.ikey;
-  const code = param.formulaCode;
-  let labelInx = getLabelIndex(ikey);
-  const subInx = ikey.substr(ikey.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(''):'';
-  }
-  res[code] = param.text;
-  res.update = Math.random();
-  return res;
-}
-
 //自由文本
 export function setCheckText(state,action) {
   let res = Object.assign({},state);

+ 2 - 2
src/store/reducers/checkBody.js

@@ -2,10 +2,10 @@ import {RECOVER_TAG_CHECK,SET,SETNUMBER4,SETSELECTED4,SETCHECKBOX,ADDLABELITEM,S
   SELECTSEARCHDATA,CHANGECHECKTEXTLABEL,CLEARCHECKBODY,CHECK_FOCUS_INDEX,CHECKBODY_CLEAR,
   SETCHECKINPUT,DEL_CHECKBODY,CHANGECHECKTEXTLABEL_NUMBER,CHECKCONFIRMSELECTED,
   CHECKBODY_MUL,DEL_CHECKBODY_LABLE,SET_CK_RADIO_INPUT_VAL,SET_IMPORT_CHECKBODY_LABEL,PRESET} from '../types/checkBody.js';
-import {recoveTag,set,setNumberValue,setRadioValue,setCheckBoxValue,addLabelItem,setCheckText,
+import {recoveTag,set,setCheckBoxValue,addLabelItem,setCheckText,
   setSearchData,insertLabelData,changeLabelVal,clearCheckBody,setInputLabel,backspaceText,
   changeNumLabelVal,confirm,multipleComfirn,delSingleLable,setImportCheckbodyLabel,preSetCheckbody} from '../actions/checkBody.js';
-import {setRadioInputValue} from '@utils/utils';
+import {setRadioInputValue,setRadioValue,setNumberValue} from '@utils/utils';
 import config from '@config/index.js';
 
 const block = Object.assign(JSON.parse(config.textLabel),{full:true});//空白时保留一个自由文本标签

+ 2 - 3
src/store/reducers/currentIll.js

@@ -3,11 +3,10 @@ import {RECOVER_TAG_CURRENT,SET_CURRENT,CURRENT_CONFIRM,INSERT_PROCESS,SET_CURRE
   CURRENT_RADIO,CURRENT_NUMBER,CURRENT_TEXT_LABEL,CLEAR_CURRENT_ILL,SETTEXTMODEVALUE,CURRENT_GET_BIGDATAPUSH,CURRENT_CLEAR,
   SET_CURRENT_SEARCH,SETCURRENTTEXT,CURRENT_FOCUS_INDEX,SELECT_SEARCHDATA,CLEAR_CURRENT_EDIT,CURRENTADDLABELITEM,
   SETCURRENTINPUT,DEL_CURRENT,CURRENT_TEXT_LABEL_NUMBER,REMOVE_CURR_ID,CURRENT_MUL,DEL_CURRENT_LABLE,SET_RADIO_INPUT_VALUE,CURRENT_CHRONIC,SAVE_CURR_FREE} from '../types/currentIll';
-import {recoveTag,confirm,insertProcess,setData,setCheckBox,setRadioValue,setNumberValue,changeLabelVal,clearCurrentIll,
+import {recoveTag,confirm,insertProcess,setData,setCheckBox,changeLabelVal,clearCurrentIll,
   setTextModeValue,setModule,bigDataSymptom,setCheckText,insertLabelData,clearCurrentEdit,addLabelItem,setInputLabel,
   backspaceText,changeNumLabelVal,removeId,multipleComfirn,delSingleLable,fillChronicModule} from '../actions/currentIll';
-
-import {setRadioInputValue} from '@utils/utils';
+import {setRadioInputValue,setRadioValue,setNumberValue} from '@utils/utils';
 
 const initState = {
   moduleData:[],

+ 2 - 2
src/store/reducers/mainSuit.js

@@ -4,10 +4,10 @@ import {RECOVER_TAG_MAIN,COMM_SYMPTOMS,CLEAR_COMSYMPTOMS,SHOW_TAIL,INSERT_MAIN,
   INSERT_SEARCH,MAIN_FOCUS_INDEX,SETTEXTMODEVALUE,SETMAINTEXT,MAINADDLABELITEM,SETMAININPUT,DEL_MAIN,CHANGE_LABELVAL_NUMBER,
   REMOVE_MAIN_ID,MAINSUIT_MUL,DEL_MAIN_LABLE,SET_FEATURE,SET_MS_RADIO_INPUT_VAL,SAVE_CHRONIC,MAIN_REMOVE_SPAN,SET_ADD_SEARCH,CLEAR_ADD_SEARCH} from '../types/mainSuit'
 import {recoveTag,getCommSymptoms,handleTailClick,insertMain,setSearch,getBigSymptom,setMainMoudle,confirm,
-  setNumberValue,setRadioValue,commConfirm,changeLabelVal,saveFreeVal,clearMainSuit,insertSearch,setTextModeValue,setCheckText,
+  commConfirm,changeLabelVal,saveFreeVal,clearMainSuit,insertSearch,setTextModeValue,setCheckText,
   addLabelItem,setInputLabel,backspaceText,changeNumLabelVal,removeId,multipleComfirn,delSingleLable,
   getSymptomFeature} from '../actions/mainSuit'
-import {setRadioInputValue} from '@utils/utils';
+import {setRadioInputValue,setNumberValue,setRadioValue} from '@utils/utils';
 
 const initState = {
   showDrop:false,

+ 2 - 2
src/store/reducers/otherHistory.js

@@ -1,10 +1,10 @@
 import {RECOVER_TAG_OTHER,SETDATA,CONFIRMSELECTED,SETRADIO,SETNUMBER,SETOTHERCHECKBOX,SETOTHERTEXT,SETOTHERSEARCHDATA,
   SELECTOTHERSEARCHDATA,CLEAROTHERHISTORY,CHANGEOTHERTEXTLABEL,SETOTHERINPUT,SETTEXTMODEVALUE,OTHER_FOCUS_INDEX,OTHERHIS_CLEAR,
   OTHERADDLABELITEM,OTHEREDICLEAR,DEL_OTHERHIS,CHANGEOTHERTEXTLABEL_NUMBER,OTHERHIS_MUL,REMOVE_OTHER_ID,DEL_OTHERHIS_LABLE,SET_OT_RADIO_INPUT_VAL} from '../types/otherHistory';
-import {recoveTag,confirm,setRadioValue,setNumberValue,setCheckBoxValue,setCheckText,setSearchData,insertLabelData,clearOtherHistory,
+import {recoveTag,confirm,setCheckBoxValue,setCheckText,setSearchData,insertLabelData,clearOtherHistory,
   changeTextLabel,setOtherInput,setTextModeValue,addLabelItem,otherEditClear,backspaceText,changeNumLabelVal,multipleComfirn,
   removeId,delSingleLable} from '../actions/otherHistory';
-import {setRadioInputValue} from '@utils/utils';
+import {setRadioInputValue,setRadioValue,setNumberValue} from '@utils/utils';
 import config from '@config/index';
 
 const block = Object.assign(JSON.parse(config.textLabel),{full:true});//空白时保留一个自由文本标签

+ 83 - 0
src/utils/utils.js

@@ -5,6 +5,89 @@ import {getLabelIndex} from './tools';
  *
  * */
 
+//数字键盘选中事件
+export function setNumberValue(state,action){console.log(action)
+  let res = Object.assign({},state);
+  const param = action.params;
+  const ikey = param.ikey;
+  let labelInx = getLabelIndex(ikey);
+  const subInx = ikey.split("-")[2];
+  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;
+      }
+      if(it.tagType===8){       //维护时的连接词无value
+        return it.name;
+      }else{
+        //组合中未填值的子标签预览中不显示
+        if(!it.value){
+          return '';
+        }
+        return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
+      }
+
+    });
+    res.saveText[labelInx] = hasValue?sub.join(''):'';
+  }
+  res.update = Math.random();
+  return res;
+}
+//单选下拉选中
+export function setRadioValue(state,action){
+  let res = Object.assign({},state);
+  const {ikey,id,text} = action;
+  let labelInx = getLabelIndex(ikey);
+  const subInx = ikey.split("-")[2];
+  let item = res.data[labelInx];
+  if(+item.tagType===1){
+    item.value = text;
+    res.saveText[labelInx] = item.labelPrefix+text+item.labelSuffix;
+    item.questionDetailList.map((its)=>{
+      if(its.id === id){
+        its.selected = true;
+      }else{
+        its.selected = false;
+      }
+    });
+  }else{
+    item.questionMapping[subInx].value = text;
+    let hasValue = false;
+    const sub = item.questionMapping.map((it)=>{
+      //添加选中状态
+      it.questionDetailList.map((its)=>{
+        if(its.id === id){
+          its.selected = true;
+        }else{
+          its.selected = false;
+        }
+      });
+
+      if(it.value){     //至少有一个子值才黑显
+        hasValue = true;
+      }
+      if(it.tagType===8){      //维护时的连接词无value
+        return it.name;
+      }else{
+        //组合中未填值的子标签预览中不显示
+        if(!it.value){
+          return '';
+        }
+        return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
+      }
+    });
+    res.saveText[labelInx] = hasValue?sub.join(''):'';
+    item.value = sub.join('');
+  }
+  res.update = Math.random();
+  return res;
+}
 
 //单选带输入值保存,该类型不可加入血压类型中
 export const setRadioInputValue = (state,action)=>{