فهرست منبع

月经史预览显示公式

zhouna 6 سال پیش
والد
کامیت
0e31587fcd
4فایلهای تغییر یافته به همراه84 افزوده شده و 16 حذف شده
  1. 6 6
      src/components/NumberUnitDrop/index.jsx
  2. 18 4
      src/components/PreviewBody/index.jsx
  3. 9 2
      src/store/actions/otherHistory.js
  4. 51 4
      src/utils/tools.js

+ 6 - 6
src/components/NumberUnitDrop/index.jsx

@@ -41,7 +41,7 @@ class NumberUnitDrop extends Component{
     this.changeToEdit = this.changeToEdit.bind(this);
   }
   select(text){         //选中键盘上数字事件
-    const {handleSelect,ikey,suffix,prefix,mainSaveText} = this.props;
+    const {handleSelect,ikey,suffix,prefix,mainSaveText,formulaCode} = this.props;
     this.setState({
       hasSelect:true
     });
@@ -50,7 +50,7 @@ class NumberUnitDrop extends Component{
         value:''
       });
     }
-    handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
+    handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText,formulaCode});
   }
   
   handleNumClick(e){ 
@@ -85,13 +85,13 @@ class NumberUnitDrop extends Component{
   //数字框失焦,保存值到store中
   numInpBlur(e){
     e.stopPropagation();
-    const {handleSelect,ikey,suffix,prefix,mainSaveText,handleLabelChange,boxMark} = this.props;
+    const {handleSelect,ikey,suffix,prefix,mainSaveText,handleLabelChange,boxMark,formulaCode} = this.props;
     const {editable} = this.state;
     if(editable){
       const text = e.target.innerText;
       // this.$span.current.innerText='';      //修改生成文字变成输入的2倍bug 
       // handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
-      handleLabelChange&&handleLabelChange({ikey,changeVal:text,suffix,prefix,mainSaveText,type:boxMark});
+      handleLabelChange&&handleLabelChange({ikey,changeVal:text,suffix,prefix,mainSaveText,type:boxMark,formulaCode});
       
     }
     this.setState({
@@ -106,7 +106,7 @@ class NumberUnitDrop extends Component{
   handleSpanInp(e){ //数字框输入事件
     e.stopPropagation();
     // 主诉字数达到上限时不允许输入
-    const {mainSaveText,ikey,type,handleSelect,suffix,prefix,boxMark} = this.props;
+    const {mainSaveText,ikey,type,handleSelect,suffix,prefix,boxMark,formulaCode} = this.props;
     const {labelVal,editable} = this.state;
     let mainText = filterDataArr(mainSaveText);//主诉字数
     if(editable){//避免IE中点击标签也会触发
@@ -122,7 +122,7 @@ class NumberUnitDrop extends Component{
               labelVal:val
             });
           }else{
-            handleSelect&&handleSelect({ikey,text:val,suffix,prefix,mainSaveText});
+            handleSelect&&handleSelect({ikey,text:val,suffix,prefix,mainSaveText,formulaCode});
           }
         }
       }

+ 18 - 4
src/components/PreviewBody/index.jsx

@@ -1,6 +1,6 @@
 import React, { Component } from "react";
 import style from "./index.less";
-import { normalVal, filterDataArr } from '@utils/tools';
+import { normalVal, filterDataArr, filterOtherDataArr} from '@utils/tools';
 import Notify from '@commonComp/Notify';
 import $ from "jquery";
 
@@ -130,8 +130,8 @@ class PreviewBody extends Component {
   }
   render() {
     const { show, preInfo, dataJson, dataStr, baseObj, flg } = this.props;
-
-    return <div className={style['content']} style={{ width: flg ? '700' : '820' }}>
+    const other_yjs = filterOtherDataArr(JSON.parse(dataStr.other),dataJson.other);
+    return <div className={style['content']} style={{ width: flg ? '700' : '820' }}>1<sup><u>1</u></sup><sub>2</sub>
       <div className={style['contents']} id="content" style={{ margin: "0 auto", maxWidth: "600px" }}>
         <div ref={this.$content} style={{ clear: 'both', fontSize: '24px', margin: '0px 0px 30px 0px', textAlign: 'center' }}>{preInfo.hospitalName}</div>
         <table className={style['patInfo']} style={{ margin: '0px 0px 30px 0px', borderCollapse: 'collapse', width: "100%" }}>
@@ -169,7 +169,21 @@ class PreviewBody extends Component {
             <td style={{ textAlign: 'right', padding: '9px 5px 8px 0px', fontSize: '14px' }}>其他史:</td>
             <td style={{ fontSize: '14px', padding: '9px 0px 8px 0px', lineHeight: '20px' }}>
               {
-                filterDataArr(JSON.parse(dataStr.other))
+                other_yjs.str1
+              }
+              {dataJson['yjs_1']||dataJson['yjs_2']||dataJson['yjs_3']||dataJson['yjs_4']?<table style={{textAlign:'center',verticalAlign: 'middle',display:'inline-block'}}>
+                <tr>
+                  <td rowSpan='2' style={{verticalAlign: 'middle'}}>月经史:(</td>
+                  <td rowSpan='2' style={{verticalAlign: 'middle'}}>{dataJson['yjs_1']||'初潮年龄'}</td>
+                  <td style={{borderBottom:'1px solid #000'}}>{dataJson['yjs_2']||'行经天数'}</td>
+                  <td rowSpan='2' style={{verticalAlign: 'middle'}}>{dataJson['yjs_4']||'停经时间'})</td>
+                </tr>
+                <tr>
+                  <td style={{textAlign:'center'}}>{dataJson['yjs_3']||'周期'}</td>
+                </tr>
+              </table>:''}
+              {
+                other_yjs.str2
               }
             </td>
           </tr>

+ 9 - 2
src/store/actions/otherHistory.js

@@ -105,6 +105,7 @@ 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];
@@ -122,6 +123,7 @@ export function setNumberValue(state,action){
     });
     res.saveText[labelInx] = hasValue?sub.join(''):'';
   }
+  res[code] = param.text;
   res.update = Math.random();
   return res;
 }
@@ -276,11 +278,16 @@ export const changeNumLabelVal = (state,action)=>{
 
 export function clearOtherHistory(state,action){       //清空数据
   let res = Object.assign({},state);
-  res.data = action.data;
+  for(let it in action){
+    if(it!='type'){
+      res[it] = action[it];
+    }
+  }
+  /*res.data = action.data;
   res.saveText = action.saveText;
   res.selecteds = action.selecteds;
   res.editClear = action.editClear;
-  res.isEmpty = action.isEmpty;
+  res.isEmpty = action.isEmpty;*/
   return res;
 }
 //文本模式下值保存

+ 51 - 4
src/utils/tools.js

@@ -162,11 +162,17 @@ const getUrlArgObject = (parm) => {
 } 
 const getAllDataList =(baseList) =>{           //获取所有模块结构化的数据
     let jsonData = {};
+    //月经史公式
+    const other = baseList.otherHistory;
     jsonData.lis = {};
     jsonData.chief = baseList.mainSuit.data;      //主诉
     jsonData.present = baseList.currentIll.data;    //现病史
-    jsonData.other = baseList.otherHistory.data;      //其他史
-    jsonData.otherHistoryIsEmpty = baseList.otherHistory.isEmpty;
+    jsonData.other = other.data;      //其他史
+    jsonData.otherHistoryIsEmpty = other.isEmpty;
+    jsonData['yjs_1'] = other['yjs_1'];
+    jsonData['yjs_2'] = other['yjs_2'];
+    jsonData['yjs_3'] = other['yjs_3'];
+    jsonData['yjs_4'] = other['yjs_4'];
     jsonData.vital = baseList.checkBody.data;    //查体
     jsonData.checkBodyIsEmpty = baseList.checkBody.isEmpty;
     jsonData.lis.labelList = baseList.inspect.labelList;      //化验
@@ -282,6 +288,10 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
                 store.dispatch({
                     type: CLEAROTHERHISTORY,
                     data:dataJson.other,
+                    yjs_1:dataJson.yjs_1,
+                    yjs_2:dataJson.yjs_2,
+                    yjs_3:dataJson.yjs_3,
+                    yjs_4:dataJson.yjs_4,
                     selecteds:dataJson.otherHistorySelecteds?dataJson.otherHistorySelecteds:[],
                     isEmpty:onlyOneText?true:false,//dataJson.otherHistoryIsEmpty,
                     saveText:JSON.parse(dataJsonStr.other),
@@ -339,6 +349,10 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
                 store.dispatch({
                     type: CLEAROTHERHISTORY,
                     data:dataJson.other,
+                    yjs_1:dataJson.yjs_1,
+                    yjs_2:dataJson.yjs_2,
+                    yjs_3:dataJson.yjs_3,
+                    yjs_4:dataJson.yjs_4,
                     selecteds:dataJson.otherHistorySelecteds?dataJson.otherHistorySelecteds:[],
                     saveText:dataJsonStr[2].content ? JSON.parse(dataJsonStr[2].content):[],
                     isEmpty:onlyOneText?true:false,//dataJson.otherHistoryIsEmpty,回读回来后判断是否只有一个空标签,是的话要使用模板
@@ -507,10 +521,42 @@ function filterDataArr(arrTmp){   //数据处理
       });
     });
 
-    return tmpArr.join('').replace(config.punReg,function(word){
+    return trimDots(tmpArr.join(''));      //去掉开头的标点符号,最后的标点保留第一个,中间连续的保留第一个
+}
+//其他史预览数据处理-月经史
+function filterOtherDataArr(arrTmp,jsonArr){
+  let tmpArr = [];
+  let index1 = jsonArr.findIndex((item)=>{
+    return item.formulaCode=='yjs_1';
+  });
+  let index2 = jsonArr.findIndex((item)=>{
+    return item.formulaCode=='yjs_2';
+  });
+  let index3 = jsonArr.findIndex((item)=>{
+    return item.formulaCode=='yjs_3';
+  });
+  let index4 = jsonArr.findIndex((item)=>{
+    return item.formulaCode=='yjs_4';
+  });
+  tmpArr = arrTmp.map((it,i)=>{     //连续的标点符号保留第一个
+    if(!it.match(config.punctuationReg)&&!arrTmp[i-1]||[index1,index2,index3,index4].includes(i)){        //只有标点符号或者前一个标签无值是(说明本标点灰显,不显示在预览中)
+      return '';
+    }
+    return it.replace(config.punReg,function(word){
       return word.substr(0,1);
-    }).replace(/^[,,.。::"“?”;;、!!]+/,'');      //去掉开头的标点符号,最后的标点保留第一个,中间连续的保留第一个
+    });
+  });
+  const str1 = [...tmpArr].splice(0,index1).join("");
+  const str2 = [...tmpArr].splice(index1).join("");
+  return {str1:trimDots(str1),str2:trimDots(str2),index:index1};
 }
+//去掉开头的标点符号,最后的标点保留第一个,中间连续的保留第一个
+function trimDots(str){
+  return str.replace(config.punReg,function(word){
+    return word.substr(0,1);
+  }).replace(/^[,,.。::"“?”;;、!!]+/,'');
+}
+
 // 取消默认行为
 function preventDefault(event) {
     if (event.preventDefault) {
@@ -661,6 +707,7 @@ module.exports = {
     pushAllDataList,
     filterArr,
     filterDataArr,
+    filterOtherDataArr,
     preventDefault,
     handleEnter,
     didPushParamChange,