Przeglądaj źródła

拆分fullfullText

zhouna 6 lat temu
rodzic
commit
ef70a85008

+ 2 - 2
src/containers/SpreadDrop.js

@@ -11,7 +11,7 @@ import {SETCHECKBOX,CHANGECHECKTEXTLABEL,CHECKCONFIRMSELECTED} from '@types/chec
 import {CURRENT_CONFIRM,SETMAINCHECKBOX,CURRENT_TEXT_LABEL,CURRENT_GET_BIGDATAPUSH} from '@types/currentIll';
 import {billing} from '@store/async-actions/pushMessage';
 import {Notify} from '@commonComp';
-import {filterArr,didPushParamChange,filterDataArr,getLabelIndex,fullfillText,getIds} from '@utils/tools.js';
+import {filterArr,didPushParamChange,filterDataArr,getLabelIndex,fullfillText,checkFullfillText,getIds} from '@utils/tools.js';
 import config from '@config/index.js';
 
 function mapStateToProps(state) {//console.log(state);
@@ -272,7 +272,7 @@ function checkBodyConfirm(dispatch,store,params){
       });
       dispatch({
         type: CHECKCONFIRMSELECTED,
-        data: {exists:fullfillText(has,false,false).newArr,withs:fullfillText(wes,false,false).newArr,nones:nones,ikey,copyType}
+        data: {exists:checkFullfillText(has).newArr,withs:checkFullfillText(wes).newArr,nones:nones,ikey,copyType}
       });
       dispatch({
         type:ISREAD

+ 9 - 9
src/store/actions/checkBody.js

@@ -1,5 +1,5 @@
 import config from '@config/index.js';
-import {formatContinueDots,getLabelIndex,fullfillText} from '@utils/tools.js';
+import {formatContinueDots,getLabelIndex,fullfillText,checkFullfillText} from '@utils/tools.js';
 
 export function preSetCheckbody(state,action) {
   let res = Object.assign({},state);
@@ -11,7 +11,7 @@ export function preSetCheckbody(state,action) {
 export function set(state,action){
   let res = Object.assign({},state);
   const {data} = action;
-  const obj = fullfillText(data,false,false,false);
+  const obj = checkFullfillText(data);
   res.data = obj.newArr;
   res.saveText = obj.saveText;//存逗号
   res.showAll = obj.checkHiddenDefault;
@@ -67,7 +67,7 @@ export const confirm = (state,action) =>{
   arr.splice(ikey,0,...exists,...withs);
   //arr[ikey-1].value = text;
   //res.saveText[ikey+items.length] = text;
-  res.saveText = fullfillText(arr).saveText;
+  res.saveText = checkFullfillText(arr).saveText;
   res.update=Math.random();         //用于触发组件更新(data变化了因在对象中无法被组件检测到)
   return res;
 };
@@ -251,7 +251,7 @@ export function setCheckBoxValue(state,action) {
   }
   res.data[labelInx].value = showText;
   res.selecteds[labelInx] = action.data;
-  res.saveText = fullfillText(res.data).saveText;
+  res.saveText = checkFullfillText(res.data).saveText;
   res.update = Math.random();
   return res;
 }
@@ -271,7 +271,7 @@ export function insertLabelData(state,action){
   const searchStr = res.searchStr;
   const {index,data,isReplace,span,searchInEnd}=action;
   const showText = res.saveText[index];
-  let tempLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
+  let tempLabels = data.tagType==4?checkFullfillText(data.questionMapping).newArr:[data];
   tempLabels = formatContinueDots(tempLabels);
   //查体中,默认显示区域搜索出来的标签要默认显示,隐藏区域搜索出的默认隐藏
   let hideAreaIndex = [...res.data].reverse().findIndex((it)=>it.showInCheck);
@@ -287,12 +287,12 @@ export function insertLabelData(state,action){
     const pText = Object.assign({},text,{value:newText});
     if(searchInEnd){
       res.data.splice(index,1,pText,...spreadLabels,text);
-      res.saveText = fullfillText(res.data).saveText;
+      res.saveText = checkFullfillText(res.data).saveText;
       //res.saveText.splice(index,1,newText,'','');
       res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null),null);
     }else{
       res.data.splice(index,1,text,...spreadLabels,pText);
-      res.saveText = fullfillText(res.data).saveText;
+      res.saveText = checkFullfillText(res.data).saveText;
       //res.saveText.splice(index,1,'','',newText);
       res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null),null);
     }
@@ -365,7 +365,7 @@ export const changeLabelVal = (state,action)=>{//双击标签输入改变值
     const num = nextIsDot?2:1;
     res.data.splice(index,num);
     res.selecteds.splice(index,num);//杂音类样式选中状态对应
-    res.saveText = fullfillText(res.data).saveText;
+    res.saveText = checkFullfillText(res.data).saveText;
   }
   res.update = Math.random();
   return res;
@@ -397,7 +397,7 @@ export const changeNumLabelVal = (state,action)=>{
     const num = nextIsDot?2:1;
     res.data.splice(index,num);
     res.selecteds.splice(index,num);      //杂音类样式选中状态对应
-    res.saveText = fullfillText(res.data).saveText;
+    res.saveText = checkFullfillText(res.data).saveText;
   }
 
   res.update = Math.random();

+ 9 - 11
src/store/async-actions/fetchModules.js

@@ -2,7 +2,7 @@ import {json} from '@utils/ajax.js';
 import {SET,PRESET} from '@types/checkBody.js';
 import {SETDATA} from '@store/types/otherHistory';
 import store from '@store';
-import {getEMRParams,didPushParamChange,inspectAndAssist,fullfillText} from '@utils/tools.js';
+import {getEMRParams,didPushParamChange,inspectAndAssist,fullfillText,checkFullfillText,deepClone} from '@utils/tools.js';
 import {Notify} from '@commonComp';
 import {billing} from '@store/async-actions/pushMessage';
 import {SETOTHERHISTORY,ISREAD} from "../types/homePage";
@@ -106,9 +106,6 @@ export const getOtherHisRecord = ()=>{
               save:[]
             });
           }
-
-          //console.log('其他史最近数据无')
-          //arr = state.homePage.initData.otherHis;
         }else{
           arr = obj.other;
           if(mode =='1'){     //文本模式
@@ -164,7 +161,7 @@ export function pregetCheckbodyData(flag){     //flag=true获取到数据后立
           data:data
         });
         if(flag){
-          const arr = fullfillText(data,false,false,false).newArr;
+          const arr = checkFullfillText(data).newArr;
           dispatch({
             type:SET,
             data:arr,
@@ -188,7 +185,7 @@ export function getInitData(){
     if(!preData||preData.length==0){
       dispatch(pregetCheckbodyData(true));
     }
-      const arr = fullfillText(preData,false,false,false).newArr;
+      const arr = checkFullfillText(preData).newArr;
       dispatch({
         type:SET,
         data:arr,
@@ -204,12 +201,13 @@ export function setOtherHisModule(){
     const initData = state.homePage.initData;
     const block = Object.assign(JSON.parse(config.textLabel),{full:true});
     const mode = state.typeConfig.typeConfig;
-    const model = JSON.parse(JSON.stringify(initData.otherHisModel || null))||[block];     //查体模板
-    const arr = JSON.parse(JSON.stringify(initData.otherHis || null));        //最近其他史数据
-    const arrSave = JSON.parse(JSON.stringify(initData.otherHisSave || null));    //最近其他史saveText
-    const selects = JSON.parse(JSON.stringify(initData.otherSelecteds || null));  //其他史杂音类选中项
+    const model = deepClone(initData.otherHisModel)||[block];     //查体模板
+    const arr = deepClone(initData.otherHis);        //最近其他史数据
+    const arrSave = deepClone(initData.otherHisSave);    //最近其他史saveText
+    const selects = deepClone(initData.otherSelecteds);  //其他史杂音类选中项
     const isHis = initData.otherIsHis;     //是否是历史数据
-    const onlyOneText = arr && arr.length == 1 && arr[0].tagType == 8 && !arr[0].value;    //是否只有一个自由文本标签
+    const onlyOneText = arr && arr.length == 1 && arr[0].tagType == 8 && !arr[0].value;    //是否只有一个空的自由文本标签
+    //是历史数据且不为空则显示历史数据,否则显示模板
     const listObj = isHis && (mode == 1 || (!onlyOneText && mode == 0)) ? {
       newArr: arr,
       saveText: arrSave || []

+ 2 - 3
src/store/async-actions/homePage.js

@@ -3,11 +3,10 @@ import {SETINITDATA,MODI_LOADING,GET_ASSIST_LIST,GET_INSPECT_LIST,SETALLMODULES}
 import {SET_CURRENT} from '@store/types/currentIll';
 import {SET_MAINSUIT} from '@store/types/mainSuit';
 import config from '@config/index.js';
-import store from '@store';
 import {formatContinueDots} from '@utils/tools';
 import {getOtherHisRecord,getInitData} from '@store/async-actions/fetchModules.js';
 import {initHistoryDetails} from '@store/async-actions/patInfo';
-import {storageLocal,fullfillText} from '@utils/tools';
+import {storageLocal,fullfillText,checkFullfillText} from '@utils/tools';
 
 const api = {
   getModules:'/moduleInfo/getAll',
@@ -20,7 +19,7 @@ function modulesParseJson(data){
   let json = {},obj={},saveTextJson={},moduleName={};
   data.map((it)=>{
     moduleName[config.moduleCP[it.type]] = it.name;//添加病情变化/病程变化子模板需要使用模板名称
-    obj = it.type==4?fullfillText(it.moduleDetailDTOList,false,false,false):fullfillText(it.moduleDetailDTOList);
+    obj = it.type==4?checkFullfillText(it.moduleDetailDTOList):fullfillText(it.moduleDetailDTOList);
     json[config.moduleCP[it.type]] = formatContinueDots(obj.newArr);
     saveTextJson[config.moduleCP[it.type]] = obj.saveText;
   });

+ 95 - 19
src/utils/tools.js

@@ -933,35 +933,111 @@ function notTextLabel(label){
 * 入参:arr源数组,
 *       noPre是否不添加前置文本标签,默认false即添加
 *       noEnd是否不添加后置文本标签,默认false即添加
-*       ifEmpty是否添加空标签,默认true即添加,传false添加逗号,如查体,
-*       showInCheck是否默认在查体中展开
+*  出参:newArr添加自由文本标签后的数据Array,
+*        saveText添加自由文本后对应的预览数据Array,
 * */
-function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
+function fullfillText(arr,noPre=false,noEnd=false){
   let newArr =[],
     pre={},
     textLabel={},
-    _textLabel={},
     notText = true,
     saveText=[],
     tempText = '',
     value = '',
-    item={},
-    cNum = 0,
-    checkHiddenDefault=false;//console.log(arr)
+    cNum = 0;
   arr&&arr.map((it,i)=>{
     notText = notTextLabel(it);
     cNum = i;
     value = it.value||'';
-    textLabel = !ifEmpty&&i==0?Object.assign({},JSON.parse(config.textLabel),{showInCheck:true}):JSON.parse(config.textLabel);
+    textLabel = JSON.parse(config.textLabel);
+    //n个显示的标签最后一个标签后面要落关标,所以+1
+    if(i===0){
+      //第一个标签不是文本标签时在前面添加文本标签
+      if(!noPre&&notText){
+        newArr.push(textLabel);
+        saveText.push('');
+      }
+      newArr.push(it);
+      if(it.tagType != 3){      //非血压类组合标签
+        tempText = value?it.labelPrefix+value+it.labelSuffix:'';
+        tempText = notText?tempText:it.value||it.name;
+      }else{
+        tempText = getSaveText(it);
+      }
+      saveText.push(tempText);
+      // 模板只有一个标签时第一项后面也要加空标签
+      if(arr.length==1&&notText){
+        newArr.push(JSON.parse(config.textLabel));
+        saveText.push('');
+      }
+    }else{
+      pre = arr[i-1];
+      //如果本身不是文本标签且前面一个也不是文本标签,该标签前面添加文本标签
+      if(notTextLabel(pre)&&notText){
+        newArr.push(textLabel,it);
+        if(it.tagType != 3) {
+          tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
+        }else{
+          tempText = getSaveText(it);
+        }
+        saveText.push("",tempText);
+      }else{    //本身是或者前面是文本标签时,前面不添加文本标签
+        newArr.push(it);
+        if(it.tagType != 3) {
+          tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
+          tempText = notText ? tempText : (it.value || it.value == "" ? it.value : it.name);
+        }else{
+          tempText = getSaveText(it);
+        }
+        saveText.push(tempText);
+      }
+      if(notText&&!noEnd&&i===arr.length-1){//最后一个非文本标签,后面添加一个文本标签
+        //不能用上面的变量textLabel,因为上一个if可能也进了,这样就是同一个对象,值改变时会同步
+        newArr.push(JSON.parse(config.textLabel));
+        saveText.push("");
+      }
+    }
+  });
+  return {newArr,saveText};
+};
+
+/*
+ * 查体添加自由文本标签函数
+ * 默认标签直接添加,
+ * 前config.showCheckNum个源数据标签默认显示,剩余隐藏收起
+ *  入参:arr源数组,
+ *       noPre是否不添加前置文本标签,默认false即添加
+ *       noEnd是否不添加后置文本标签,默认false即添加
+ *  showInCheck是否默认在查体中展开
+ *  出参:newArr添加自由文本标签后的数据Array,
+ *        saveText添加自由文本后对应的预览数据Array,
+ *        checkHiddenDefault查体是否全部标签展开
+ *
+ * */
+function checkFullfillText(arr,noPre=false,noEnd=false){
+  let newArr =[],
+    pre={},
+    textLabel={},
+    notText = true,
+    saveText=[],
+    tempText = '',
+    value = '',
+    item={},
+    checkHiddenDefault=false;
+  arr&&arr.map((it,i)=>{
+    notText = notTextLabel(it);
+    value = it.value||'';
+    //textLabel = i==0?JSON.parse(config.textLabel):Object.assign({},JSON.parse(config.textLabel),{showInCheck:true});
     //n个显示的标签最后一个标签后面要落关标,所以+1
-    _textLabel = !ifEmpty&&cNum<config.showCheckNum+1?Object.assign({},JSON.parse(config._textLabel),{showInCheck:true}):JSON.parse(config._textLabel);
+    //_textLabel = !ifEmpty&&cNum<config.showCheckNum+1?Object.assign({},JSON.parse(config._textLabel),{showInCheck:true}):JSON.parse(config._textLabel);
     if(i===0){
+      textLabel = Object.assign({},JSON.parse(config.textLabel),{showInCheck:true});
       //第一个标签不是文本标签时在前面添加文本标签
       if(!noPre&&notText){
         newArr.push(textLabel);
         saveText.push('');
       }
-      item = ifEmpty?it:Object.assign({},it,{showInCheck:true});
+      item = Object.assign({},it,{showInCheck:true});
       newArr.push(item);
       if(it.tagType != 3){
         tempText = value?it.labelPrefix+value+it.labelSuffix:'';
@@ -977,17 +1053,18 @@ function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
       }
     }else{
       pre = arr[i-1];
-      item = !ifEmpty&&cNum<config.showCheckNum?Object.assign({},it,{showInCheck:true}):it;
+      item = i<config.showCheckNum?Object.assign({},it,{showInCheck:true}):it;
       //判断单选项是否有默认选中,位置在隐藏区域时,查体所有标签展示
-      if(!ifEmpty&&!checkHiddenDefault&&cNum>config.showCheckNum&&+it.tagType===1&&(+it.controlType===0||+it.controlType===1)){
+      if(!checkHiddenDefault&&i>config.showCheckNum&&+it.tagType===1&&(+it.controlType===0||+it.controlType===1)){
         if(it.questionDetailList.find((it)=>it.defaultSelect=='1')){
           checkHiddenDefault=true;
         }
       }
       //如果本身不是文本标签且前面一个也不是文本标签,该标签前面添加文本标签
       if(notTextLabel(pre)&&notText){
-        // newArr.push(textLabel,it);
-        ifEmpty?newArr.push(textLabel,it):newArr.push(_textLabel,item);
+        textLabel = Object.assign(JSON.parse(config._textLabel),{showInCheck:i-1<config.showCheckNum?true:false});
+        newArr.push(textLabel,item);
+
         if(it.tagType != 3) {
           tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
         }else{
@@ -998,7 +1075,6 @@ function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
         newArr.push(item);
         if(it.tagType != 3) {
           tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
-          // tempText = notText?tempText:it.value||it.name;
           tempText = notText ? tempText : (it.value || it.value == "" ? it.value : it.name);
         }else{
           tempText = getSaveText(it);
@@ -1006,15 +1082,14 @@ function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
         saveText.push(tempText);
       }
       if(notText&&!noEnd&&i===arr.length-1){//最后一个非文本标签,后面添加一个文本标签
-        //不能用上面的变量textLabel,因为上一个if可能也进了,这样就是同一个对象,值改变时会同步
-        const _text = arr.length>config.showCheckNum?JSON.parse(config._textLabel):_textLabel;
-        newArr.push(ifEmpty?textLabel:_text);
+        const _text = Object.assign(JSON.parse(config.textLabel),{showInCheck:arr.length>config.showCheckNum?false:true});
+        newArr.push(_text);
         saveText.push("");
       }
     }
   });
   return {newArr,saveText,checkHiddenDefault};
-};
+}
 
 
 //获取标签index,入参:病例项index+标签index+标签内index
@@ -1074,6 +1149,7 @@ module.exports = {
     getWindowInnerHeight,
     getLabelIndex,
     fullfillText,
+    checkFullfillText,
     parseUrl,
     getAge,
     dateParser,