Browse Source

无模板数据容错

zhouna 6 years ago
parent
commit
c5ddfe61f6

+ 1 - 1
src/common/js/func.js

@@ -96,7 +96,7 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
       value = '',
       item={},
       checkHiddenDefault=false;
-  arr.map((it,i)=>{
+  arr&&arr.map((it,i)=>{
     notText = notTextLabel(it);
     value = it.value||'';
     textLabel = !ifEmpty&&i==0?Object.assign({},JSON.parse(config.textLabel),{showInCheck:true}):JSON.parse(config.textLabel);

+ 3 - 1
src/containers/OtherHistory.js

@@ -7,6 +7,7 @@ import {getModule} from '@store/async-actions/fetchModules.js';
 import {billing} from '@store/async-actions/pushMessage';
 import {fullfillText} from '@common/js/func';
 import {didPushParamChange,filterDataArr} from '@utils/tools.js';
+import config from '@config/index.js';
 
 function mapStateToProps(state){
   const {otherHistory,homePage,typeConfig,mainSuit} = state;
@@ -41,7 +42,8 @@ function mapDispatchToProps(dispatch,store){
         const state = getStore();
         const initData = state.homePage.initData;
         const mode = state.typeConfig.typeConfig;
-        const model = JSON.parse(JSON.stringify(initData.otherHisModel));     //查体模板
+        const block = Object.assign(JSON.parse(config.textLabel),{full:true});//空白时保留一个自由文本标签
+        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));  //其他史杂音类选中项

+ 4 - 4
src/store/actions/currentIll.js

@@ -22,8 +22,8 @@ function insertPro(data,processModule){
 export const setModule = (state,action)=>{
   const res = Object.assign({},state);
   // 处理tagType=4的类型
-  const originalData = action.data;
-  const originalSonData = action.processModule;
+  const originalData = action.data||[];
+  const originalSonData = action.processModule||[];
   let spreadLabels=[];
   let sonSpreadLabels=[];//子模板
   for(let i=0; i<originalData.length;i++){
@@ -48,12 +48,12 @@ export const setModule = (state,action)=>{
   res.emptyData = action.emptyData;//空模板
   let data = action.data;
   let sliceIdx;
-  data.map((v,i)=>{
+  data&&data.map((v,i)=>{
     if(v.flag && v.flag==2){
       sliceIdx = i;
     }
   })
-  res.addModule = data.slice(0,sliceIdx+1);//截取到flag=2 有无治疗
+  res.addModule = data&&data.slice(0,sliceIdx+1);//截取到flag=2 有无治疗
   res.update=Math.random();
   return res;
 }

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

@@ -24,8 +24,8 @@ export const setMainMoudle = (state,action) => {
   // let data = action.data.push(emptySpan);
   // 处理tagType=4的类型
   // const originalData = JSON.parse(JSON.stringify(action.data));
-  const originalData = action.data;
-  const originalSonData = action.addSymptom;
+  const originalData = action.data||[];
+  const originalSonData = action.addSymptom||[];
   let spreadLabels=[];
   let sonSpreadLabels=[];//子模板
   for(let i=0; i<originalData.length;i++){

+ 1 - 1
src/utils/tools.js

@@ -586,7 +586,7 @@ function trimDots(str){
 
 //标签间连续标点只保留一个,保留前面一个
 function formatContinueDots(data){
-  let arr=data.filter((it,i)=>{
+  let arr=data&&data.filter((it,i)=>{
     if(i==0||(it.name&&(it.name.match(config.punctuationReg))||(data[i-1].name&&data[i-1].name.match(config.punctuationReg)))){
       return it;
     }