Browse Source

主诉现病史去重和获取症状尾巴id分开

liucf 6 năm trước cách đây
mục cha
commit
fe8872e60d

+ 26 - 14
src/components/CommonSymptom/index.jsx

@@ -18,7 +18,8 @@ class CommonSymptom extends Component{
     this.state={
       select:[],
       ids:[],
-      hide:false
+      hide:false,
+      conceptId:[]
     }
     this.handleSelect = this.handleSelect.bind(this);
     this.handleClear = this.handleClear.bind(this);
@@ -31,29 +32,38 @@ class CommonSymptom extends Component{
 
   handleSelect(e,item){
     e.stopPropagation();
-    let {select,ids} = this.state;
+    let {select,ids,conceptId} = this.state;
     const id = item.questionId
-    if(ids.includes(id)){
-      ids.splice(ids.indexOf(id),1);
+    const copid = item.conceptId
+    if(conceptId.includes(copid)){
+      conceptId.splice(conceptId.indexOf(copid),1);
+      if(ids.includes(id)){
+        ids.splice(ids.indexOf(id),1);
+      }
       let selectData = select;  
       select.forEach((it,i)=>{
-        if(it.questionId==id){
+        if(it.conceptId==copid){
          selectData.splice(i,1); 
         }
       })
       select = selectData; 
     }else{
-      ids.push(id);
+      // ids.push(id); //questionId可能没有
+      if(id){
+        ids.push(id);
+      }
+      conceptId.push(copid);
       select.push(item);
     }
     this.setState({
       select,
-      ids
+      ids,
+      conceptId
     })
   }
   getStyle(id){
-    const {ids} = this.state;
-    if(ids.includes(id)){
+    const {conceptId} = this.state;
+    if(conceptId.includes(id)){
       return style['selected'];
     }
     return '';
@@ -62,14 +72,15 @@ class CommonSymptom extends Component{
     e.stopPropagation();
     this.setState({
       select:[],
-      ids:[]
+      ids:[],
+      conceptId:[]
     })
   }
   handleConfirm(e){
     e.stopPropagation();
     const {onSelect} = this.props;
-    const {select,ids} = this.state;
-    onSelect&&onSelect({select,ids});
+    const {select,ids,conceptId} = this.state;
+    onSelect&&onSelect({select,ids,conceptId});
   }
 
   componentDidMount(){
@@ -82,7 +93,8 @@ class CommonSymptom extends Component{
         this.setState({
           hide:true,
           select:[],
-          ids:[]
+          ids:[],
+          conceptId:[]
         })
       }else{
         this.setState({
@@ -98,7 +110,7 @@ class CommonSymptom extends Component{
     return <div className={this.getClass()} contenteditable="false" id="symptBox" style={{'display':hide?'none':'block'}}>
       <ul className={style["listBox"]} id="listBox">
         {data&&data.map((it)=>{
-          return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getStyle(it.questionId)} title={it.name.length>5?it.name:''}>{it.name.length>5?it.name.slice(0,4)+'...':it.name}</li>
+          return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getStyle(it.conceptId)} title={it.name.length>5?it.name:''}>{it.name.length>5?it.name.slice(0,4)+'...':it.name}</li>
         })}
       </ul>
       <div className={style['oper']} id="oper">

+ 2 - 2
src/components/CurrentIll/index.jsx

@@ -38,7 +38,7 @@ class CurrentIll extends Component{
 
   handleFocus(e){
     // 判断主诉是否为空
-    const {mainData,mainText,setData,moduleNum,mainIds,data,changeEditIll,editClear,symptomFeature,isChronic} = this.props;
+    const {mainData,mainText,setData,moduleNum,mainIds,mainTailIds,data,changeEditIll,editClear,symptomFeature,isChronic} = this.props;
     const that = this;
     const ev = e || window.event;
     const text = ev.target.innerText || ev.target.innerHTML;
@@ -55,7 +55,7 @@ class CurrentIll extends Component{
       if(data.length==0 && !isChronic || !isChronic.name ){
         clearTimeout(setDataTimer);
         setDataTimer = setTimeout(function(){//延时,等待主诉失焦数据返回
-            setData && setData({num,mainData,mainIds,symptomFeature:symptomFeature.featureData,isChronic});   
+            setData && setData({num,mainData,mainIds,symptomFeature:symptomFeature.featureData,isChronic,mainTailIds});   
         },200)  
         this.setState({
           setDataTimer

+ 2 - 2
src/components/ScaleTable/index.jsx

@@ -191,7 +191,7 @@ class ScaleTable extends React.Component{
   componentDidMount(){
     const {tableId,scaleInfo} = this.props;
     if(scaleInfo&&scaleInfo[tableId]){
-      let scale = this.filterScale(scaleInfo[tableId]);console.log(22,JSON.parse(scale.content));
+      let scale = this.filterScale(scaleInfo[tableId]);
       this.setState({
         // valueData:JSON.parse(scaleInfo[tableId][1].content)
         valueData:scale.content?JSON.parse(scale.content):{}
@@ -230,7 +230,7 @@ class ScaleTable extends React.Component{
     let {selecteds,valueData,start,scaleResult1} = this.state;
     const {tableId,formulaResult} = this.props;
     const scaleResult = scaleResult1 || formulaResult&&formulaResult[tableId]; //量表计算结果
-    const datas = valueData&&valueData.group?valueData:'';console.log(666,datas);
+    const datas = valueData&&valueData.group?valueData:'';//console.log(666,datas);
     let content =  datas&&datas.group&&datas.group.map((v,i)=>{
                 return <div className={style['group']}>
                   <p className={style['groupName']}>{v.groupName}</p>

+ 4 - 2
src/components/SpreadDrop/index.jsx

@@ -304,9 +304,11 @@ class SpreadDrop extends Component{
         nones += name+'、';
         noneIds.push(id);
       }else if(nowOn=='with'){
-        withs.push({id:id,name:name,questionId:item.questionId});
+        // withs.push({id:id,name:name,questionId:item.questionId});
+        withs.push({id:id,name:name,questionId:item.questionId,conceptId:item.conceptId});
       }else{
-        exists.push({id:id,name:name,listIndex,questionId:item.questionId});
+        // exists.push({id:id,name:name,listIndex,questionId:item.questionId});
+        exists.push({id:id,name:name,listIndex,questionId:item.questionId,conceptId:item.conceptId});
       }
     }
     this.setState({

+ 3 - 1
src/containers/CurrentIll.js

@@ -28,6 +28,7 @@ function mapStateToProps(state) { //console.log(111,state);
         moduleNum:mainSuit.moduleNum,//主诉使用的模板
         type: state.typeConfig.typeConfig,
         mainIds:mainSuit.mainIds,//主诉症状选中的id(去重用)
+        mainTailIds:mainSuit.mainTailIds,//主诉症状选中的id(去重用)
         showArr:homePage.showDrop,
         totalHide: homePage.totalHide,
         saveText:currentIll.saveText,
@@ -66,7 +67,8 @@ function mapDispatchToProps(dispatch) {
         })
        },
        async setData(info){//设置现病史使用模板
-        let idsArr = info.mainIds;
+        // let idsArr = info.mainIds;
+        let idsArr = info.mainTailIds.filter((it,i)=>{return it});
         let ids = idsArr.join(",");
         let labelModule = await getModules(ids);
         if(labelModule.data.code==0){//根据id获取标签模板

+ 10 - 2
src/store/actions/currentIll.js

@@ -346,8 +346,17 @@ export const confirm = (state,action) =>{
   let length1 = res.data.length;
   let arr = JSON.parse(JSON.stringify(res.data));
   const {nones,exists,withs,ikey,exclusion,excluName,ban,noneIds} = action.data;
-  let existsId = exists && exists.length>0?getIds(exists):[];
+  /*let existsId = exists && exists.length>0?getIds(exists):[];
   let withsId = withs && withs.length>0?getIds(withs):[];
+  res.symptomIds = res.symptomIds.concat(existsId,withsId,noneIds);//搜索去重*/
+  let existConpId = [];
+  let withConpId = [];
+  exists.map((v,i)=>{
+    existConpId.push(v.conceptId);
+  })
+  withs.map((v,i)=>{
+    withConpId.push(v.conceptId);
+  })
   res.symptomIds = res.symptomIds.concat(existsId,withsId,noneIds);//搜索去重
   // 伴 标签
   const banText = JSON.stringify(ban)=='{}'?'':{id:ban.id,name:ban.name,value:ban.name,tagType:config.tagType};
@@ -658,7 +667,6 @@ export const clearCurrentIll = (state,action)=>{
   res.saveText = action.saveText;
   res.selecteds = action.selecteds?action.selecteds:[];
   res.symptomIds = action.symptomIds;
-  res.symptomIds = action.symptomIds;
   if(action.editClear){
     res.editClear = action.editClear;
   }

+ 51 - 23
src/store/actions/mainSuit.js

@@ -131,6 +131,7 @@ export const insertMain = (state,action) => {
   const res = Object.assign({},state);
   const items = action.item.select;
   const id = action.item.ids;
+  const conceptId = action.item.conceptId;
   let data = JSON.parse(JSON.stringify(res.moduleData));
   if(items.length>1){
     for(let i=1; i<items.length; i++){
@@ -140,7 +141,7 @@ export const insertMain = (state,action) => {
   }
   let obj = [];
   for(let i=0; i<items.length; i++){
-    obj.push({id:items[i].questionId,name:items[i].name,value:items[i].name,tagType:config.tagType,exist:1});
+    obj.push({id:items[i].questionId,name:items[i].name,value:items[i].name,tagType:config.tagType,exist:1,conceptId:items[i].conceptId});
   }
   let inserIndx = null;
   data.map((it,i)=>{
@@ -160,17 +161,17 @@ export const insertMain = (state,action) => {
   res.saveText = [];//将手动输入的值清掉
   // res.saveText[inserIndx] = text.name;
   res.saveText = fullfillText(res.data).saveText;
-  // res.mainIds.push(id);
-  res.mainIds = res.mainIds.concat(id);
+  res.mainIds = res.mainIds.concat(conceptId);
+  res.mainTailIds = res.mainTailIds.concat(id);
   res.editClear = false;//主诉框编辑状态
   res.update=Math.random();
   return res;
 }
 
 
-function getTextLabel(id,name,flag){
+function getTextLabel(id,name,flag,copid){
   // exist 主症状1,伴随2
-  return {id:id,name:name,value:name,tagType:config.tagType,exist:flag};
+  return {id:id,name:name,value:name,tagType:config.tagType,exist:flag,conceptId:copid};
 }
 
 function addPoint(data,num){//给伴随添加顿号
@@ -188,12 +189,21 @@ export const confirm = (state,action) =>{
   const {exists,withs,ikey,withsName,existsName,ban} = action.data;
   let banText = JSON.stringify(ban) == "{}" ? '':{id:ban.id,name:ban.name,value:ban.name,tagType:config.tagType};
   let length = exists.length;
+  let existConpId = [];
+  let withConpId = [];
+  exists.map((v,i)=>{
+    existConpId.push(v.conceptId);
+  })
+  withs.map((v,i)=>{
+    withConpId.push(v.conceptId);
+  })
   let labelIndx = parseInt(ikey);//当前点击标签的index
   // 取第一个添加症状的主症状和伴随
   if(!arr[labelIndx].pos){
     let existsId = getIds(exists);
     let withsId = getIds(withs);
-    res.mainIds = res.mainIds?res.mainIds.concat(existsId,withsId):[];
+    res.mainIds = res.mainIds?res.mainIds.concat(existConpId,withConpId):[];
+    res.mainTailIds = res.mainTailIds?res.mainTailIds.concat(existsId,withsId):[];
   }
 
   // 第二病程-伴位置处理
@@ -217,7 +227,7 @@ export const confirm = (state,action) =>{
         let withsAddP = addPoint(exists,1);
         for(let i=0; i<withsAddP.length; i++){
           let pos = labelIndx + i;
-          arr.splice(pos,0,getTextLabel(withsAddP[i].id,withsAddP[i].name,1));
+          arr.splice(pos,0,getTextLabel(withsAddP[i].id,withsAddP[i].name,1,withsAddP[i].conceptId));
           res.saveText[pos] = withsAddP[i].name;
         }
       }
@@ -229,7 +239,7 @@ export const confirm = (state,action) =>{
        }
        for(let j=0; j<newWiths.length; j++){
         let withsPos = labelIndx +length + j;
-        arr.splice(withsPos,0,getTextLabel(newWiths[j].id,newWiths[j].name,2));
+        arr.splice(withsPos,0,getTextLabel(newWiths[j].id,newWiths[j].name,2,newWiths[j].conceptId));
         res.saveText[withsPos] = newWiths[j].name;
       }
     }
@@ -248,7 +258,7 @@ export const confirm = (state,action) =>{
         existsAddP = addPoint(exists,startInd);
         for(let i=0; i<existsAddP.length; i++){
           let pos = forwardId + index + i;
-          arr.splice(pos,0,getTextLabel(existsAddP[i].id,existsAddP[i].name,1));
+          arr.splice(pos,0,getTextLabel(existsAddP[i].id,existsAddP[i].name,1,existsAddP[i].conceptId));
           res.saveText[pos] = existsAddP[i].name;
         }
       }
@@ -257,7 +267,7 @@ export const confirm = (state,action) =>{
         let withsAddP = addPoint(withs,0);     
         for(let j=0; j<withsAddP.length; j++){
           let withsPos = labelIndx +length + j;
-          arr.splice(withsPos,0,getTextLabel(withsAddP[j].id,withsAddP[j].name,2));
+          arr.splice(withsPos,0,getTextLabel(withsAddP[j].id,withsAddP[j].name,2,withsAddP[j].conceptId));
           res.saveText[withsPos] = withsAddP[j].name;
         }
       }
@@ -269,7 +279,7 @@ export const confirm = (state,action) =>{
       if(exists.length > 0){
         for(let i=0; i<exists.length; i++){
           let pos = labelIndx + i;
-          arr.splice(pos,0,getTextLabel(exists[i].id,'、'+exists[i].name,1));
+          arr.splice(pos,0,getTextLabel(exists[i].id,'、'+exists[i].name,1,exists[i].conceptId));
           res.saveText[pos] = exists[i].name;
         }
       }
@@ -281,7 +291,7 @@ export const confirm = (state,action) =>{
        }
        for(let j=0; j<newWiths.length; j++){
         let withsPos = labelIndx +length + j;
-        arr.splice(withsPos,0,getTextLabel(newWiths[j].id,newWiths[j].name,2));
+        arr.splice(withsPos,0,getTextLabel(newWiths[j].id,newWiths[j].name,2,newWiths[j].conceptId));
         res.saveText[withsPos] = newWiths[j].name;
       }
     }
@@ -289,7 +299,7 @@ export const confirm = (state,action) =>{
       if(exists.length > 0){
         for(let i=0; i<exists.length; i++){
           let pos = index + i;
-          arr.splice(pos,0,getTextLabel(exists[i].id,'、'+exists[i].name,1));
+          arr.splice(pos,0,getTextLabel(exists[i].id,'、'+exists[i].name,1,exists[i].conceptId));
           res.saveText[pos] = exists[i].name;
         }
       }
@@ -298,7 +308,7 @@ export const confirm = (state,action) =>{
         let withsAddP = addPoint(withs,0);     
         for(let j=0; j<withsAddP.length; j++){
           let withsPos = labelIndx +length + j;
-          arr.splice(withsPos,0,getTextLabel(withsAddP[j].id,withsAddP[j].name,2));
+          arr.splice(withsPos,0,getTextLabel(withsAddP[j].id,withsAddP[j].name,2,withsAddP[j].conceptId));
           res.saveText[withsPos] = withsAddP[j].name;
         }
       }
@@ -345,10 +355,11 @@ export const insertSearch = (state,action)=>{
   let data = res.data;
   let moduleData = JSON.parse(JSON.stringify(res.moduleData));
   let searchData = action.info.name;
-  const id = action.info.questionId;
+  const id = action.info.questionId;//获取尾巴id
+  const ids = action.info.conceptId;//去重id
   let focusIndex = res.focusIndex;
   let span = action.span;
-  let text = {id:id,name:searchData,value:searchData,tagType:config.tagType};
+  let text = {id:id,name:searchData,value:searchData,tagType:config.tagType,conceptId:ids};
   const emptySpan = JSON.parse(config.textLabel);
   if(data.length==0){   
     let inserIndx = null;
@@ -360,14 +371,17 @@ export const insertSearch = (state,action)=>{
     // flag=1前是文本标签就替换,否则插入
     const iftext = inserIndx&&moduleData[inserIndx-1]&&moduleData[inserIndx-1].tagType;
     if(iftext==config.tagType){
-       moduleData.splice(inserIndx-1,1,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1});
+       moduleData.splice(inserIndx-1,1,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1,conceptId:ids});
      }else{
-       moduleData.splice(inserIndx,0,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1});
+       moduleData.splice(inserIndx,0,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1,conceptId:ids});
      }  
     res.saveText = [];//将手动输入的值清掉
     res.data = moduleData;
     res.saveText = fullfillText(res.data).saveText;
-    res.mainIds.push(id);
+    res.mainIds.push(ids);
+    if(id){
+      res.mainTailIds.push(id);
+    }
     res.editClear = false;//主诉框编辑状态
   }else{
     /*******************第一病程搜索结果也移植到现病史修改(2-18)********************/
@@ -411,7 +425,10 @@ export const insertSearch = (state,action)=>{
       res.data[focusIndex].value = value;
     }
     span.current.innerText?(span.current.innerText = value):(span.current.innerHTML=value);
-    res.mainIds.push(id);
+    res.mainIds.push(ids);
+    if(id){
+      res.mainTailIds.push(id);
+    }
   }
   res.update=Math.random();
   return res;
@@ -644,6 +661,7 @@ export const clearMainSuit = (state,action)=>{//回读和清除
   // res.saveText = fullfillText(action.data).saveText;//解决删除data里的值保存,回读后页面上有内容saveText里没有的情况
   res.selecteds = action.selecteds?action.selecteds:[];
   res.mainIds = action.mainIds;
+  res.mainTailIds = action.mainTailIds || [];
   res.chronicDesease = action.chronicDesease;//慢病疾病字段
   if(action.editClear){
     res.editClear = action.editClear;
@@ -747,10 +765,17 @@ export function removeId(state,action){
   let res = Object.assign({},state);
   const {index,text} = action;
   const data = res.data;
+  // 获取尾巴id-questionId
   const id = data[index].id;
+  let tailIds = res.mainTailIds;
+  if(tailIds.includes(id)){
+    tailIds.splice(tailIds.indexOf(id),1);
+  }
+  // 去重id
+  const copid = data[index].conceptId;
   let ids = res.mainIds;
-  if(ids.includes(id)){
-    ids.splice(ids.indexOf(id),1);
+  if(ids.includes(copid)){
+    ids.splice(ids.indexOf(copid),1);
   }
   if(!data[index].value && data[index-1].tagType==8){
     data.splice(index,1);
@@ -799,7 +824,10 @@ export function getSymptomFeature(state,action){
   if(data && data.length>0){
     for(let i=0; i<data.length; i++){
       data[i].tagType = '8';
-      res.mainIds.push(data[i].id);
+      res.mainIds.push(data[i].conceptId);
+      if(data[i].id){//questionId有可能为null
+        res.mainTailIds.push(data[i].id);
+      } 
     }
     res.symptomFeature.featureData = data;
     res.symptomFeature.refresh = !res.symptomFeature.refresh;

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

@@ -27,7 +27,8 @@ const initState = {
     featureData:[],
     refresh:false //用于数据更新
   },
-  chronicDesease:{} //慢病
+  chronicDesease:{}, //慢病
+  mainTailIds:[]  //获取症状尾巴用
 }
 
 export default function(state=initState,action){

+ 1 - 1
src/utils/tools.js

@@ -244,7 +244,7 @@ const getAllDataStringList =(baseList) =>{           //获取所有模块文本
 const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清空所有的数据
     if(action == 'clear'){     //清空
       const block = Object.assign(JSON.parse(config.textLabel),{full:true});//空白时保留一个自由文本标签
-      store.dispatch({type: CLEAR_MAIN_SUIT,data:[],saveText:[],selecteds:[],editClear:true,mainIds:[],clearAction:true,symptomFeature:[],chronicDesease:{}});
+      store.dispatch({type: CLEAR_MAIN_SUIT,data:[],saveText:[],selecteds:[],editClear:true,mainIds:[],mainTailIds:[],clearAction:true,symptomFeature:[],chronicDesease:{}});
         store.dispatch({type: CLEAR_CURRENT_ILL,data:[],saveText:[],selecteds:[],editClear:true,symptomIds:[]});
         store.dispatch({type: CLEAROTHERHISTORY,data:[block],isEmpty:true,saveText:[],selecteds:[],editClear:true,yjs_1:'',yjs_2:'',yjs_3:'',yjs_4:''});
         store.dispatch({type: CLEARCHECKBODY,data:[block],isEmpty:true,saveText:[],selecteds:[]});