瀏覽代碼

现病史空模板子模板处理

liucf 5 年之前
父節點
當前提交
7e07e345bb
共有 3 個文件被更改,包括 37 次插入9 次删除
  1. 34 7
      src/store/actions/currentIll.js
  2. 1 0
      src/store/async-actions/homePage.js
  3. 2 2
      src/utils/tools.js

+ 34 - 7
src/store/actions/currentIll.js

@@ -15,16 +15,33 @@ function insertPro(data,processModule){
   }
   return data;
 }
-
+// 处理tagType==4
+function resetTagtype(data){
+  let newDataArr = [];
+  if(data&&data.length>0){
+    for(let i=0; i<data.length;i++){
+      if(data[i].tagType==4){
+        newDataArr.push(...data[i].questionMapping);
+      }else{
+        newDataArr.push(data[i]);
+      }
+    }
+  }
+  return newDataArr;
+}
 //设置模板
 export const setModule = (state,action)=>{
   const res = Object.assign({},state);
   // 处理tagType=4的类型
   const originalData = action.data||[];
   const originalSonData = action.processModule||[];
-  let spreadLabels=[];
-  let sonSpreadLabels=[];//子模板
-  if(originalData&&originalData.length>0){
+  const originalEmpty = action.emptyData||[];
+  const originalEmptySon = action.currentEmptySon||[];
+  let spreadLabels=resetTagtype(originalData);
+  let sonSpreadLabels=resetTagtype(originalSonData);//子模板
+  let emptySpreadLabels=resetTagtype(originalEmpty);//空模板
+  let emptySonSpreadLabels=resetTagtype(originalEmptySon);//空模板-子模板
+  /*if(originalData&&originalData.length>0){
     for(let i=0; i<originalData.length;i++){
       if(originalData[i].tagType==4){
         spreadLabels.push(...originalData[i].questionMapping);
@@ -41,13 +58,16 @@ export const setModule = (state,action)=>{
         sonSpreadLabels.push(originalSonData[j]);
       }
     }
-  }
+  }*/
   
   // res.moduleData = action.data;
   // res.processModule = action.processModule;//病程变化模板
+  // res.emptyData = action.emptyData;//空模板
+  // res.currentEmptySon = action.currentEmptySon;//空模板-子模板
   res.moduleData = spreadLabels;
   res.processModule = sonSpreadLabels;//病程变化模板
-  res.emptyData = action.emptyData;//空模板
+  res.emptyData = emptySpreadLabels;//空模板
+  res.currentEmptySon = emptySonSpreadLabels;//空模板-子模板
   let data = action.data;
   let sliceIdx;
   data&&data.map((v,i)=>{
@@ -63,11 +83,17 @@ export const setModule = (state,action)=>{
 //插入病程变化
 export const insertProcess = (state,action)=>{
   const res = Object.assign({},state);
+  const useEmpty = res.useEmpty;
   let addSmoduleData = [];
   if(res.currReadSonM.length>0){
     addSmoduleData = JSON.parse(JSON.stringify(res.currReadSonM))
   }else{
-    addSmoduleData = res.processModule.length>0?JSON.parse(JSON.stringify(res.processModule)):[];
+    if(!useEmpty){
+      addSmoduleData = res.processModule.length>0?JSON.parse(JSON.stringify(res.processModule)):[];
+    }else{//使用空模板则取空模板的子模板
+      addSmoduleData = res.currentEmptySon.length>0?JSON.parse(JSON.stringify(res.currentEmptySon)):[];
+    }
+    
   }
   if(addSmoduleData.length==0){//未匹配到子模板
     Notify.info("未找到相关内容");
@@ -147,6 +173,7 @@ export const setData = (state,action) =>{
   if (useEmpty) {
     const data = res.emptyData?JSON.parse(JSON.stringify(res.emptyData)):[];
     res.data = fullfillText(data).newArr;
+    res.useEmpty = true; //取子模板标识
   } else {
     if(mainData&&mainData.length>0){//主诉使用模板
       // 目前只需要将第一个主诉病程移植到现病史

+ 1 - 0
src/store/async-actions/homePage.js

@@ -76,6 +76,7 @@ export const getInitModules= (dispatch,getStore)=>{
             processModule:formatContinueDots(initData.process),//病程变化
             saveProcess:initSaveText.process,
             emptyData:formatContinueDots(initData.currentEmpty),//现病史空模板
+            currentEmptySon:formatContinueDots(initData.currentEmptySon),//现病史空模板-子模板
             saveEmpty:initSaveText.currentEmpty,
           });
         }else{//慢病--没有主诉模板

+ 2 - 2
src/utils/tools.js

@@ -151,7 +151,7 @@ const getUrlArgObject = (parm) => {
     return args[parm];//返回对象  
 } 
 const getAllDataList =(baseList) =>{           //获取所有模块结构化的数据
-    let jsonData = {};
+    let jsonData = {};console.log(111,baseList)
     //月经史公式
     const other = baseList.otherHistory;
     jsonData.lis = {};
@@ -182,7 +182,7 @@ const getAllDataList =(baseList) =>{           //获取所有模块结构化的
     jsonData.currentIds = baseList.currentIll.symptomIds;      //现病史去重
     jsonData.isFirstMainDiag = baseList.treat.isFirstMainDiag;      //治疗方案
     jsonData.mainReadSonM = baseList.mainSuit.addSmoduleData;      //主诉-子模板
-    jsonData.currReadSonM = baseList.currentIll.processModule;      //现病史-子模板
+    jsonData.currReadSonM = baseList.currentIll.useEmpty?baseList.currentIll.currentEmptySon:baseList.currentIll.processModule;      //现病史-子模板
     // console.log(jsonData,'结构化数据获取')
     return jsonData;
 }