Browse Source

化验没有参考值正常显示

Luolei 6 years ago
parent
commit
94a4632714

+ 4 - 20
src/components/AddInspect/index.jsx

@@ -1,6 +1,6 @@
 import React from 'react';
 import { SearchOption, InspectCommon, Calendar ,Notify,ConfirmModal,Add} from '@commonComp';
-import { deepClone } from '@utils/tools';
+import { deepClone,normalVal } from '@utils/tools';
 import styles from './index.less';
 import date1 from './img/date1.png';
 import date2 from './img/date2.png';
@@ -30,7 +30,6 @@ class Inspect extends React.Component {
         this.getItemList = this.getItemList.bind(this)
         this.getSearchList = this.getSearchList.bind(this)
         this.changeActivePart = this.changeActivePart.bind(this)
-        this.normalVal = this.normalVal.bind(this)
         this.showDetails = this.showDetails.bind(this)
         this.delConfirm = this.delConfirm.bind(this)
         this.handleCancel = this.handleCancel.bind(this)
@@ -232,21 +231,6 @@ class Inspect extends React.Component {
         }
     </ul>
     }
-    normalVal(min,max){
-        if((min-0) && (max-0)){
-            return `正常值: (${min}~${max})`
-        }else if((min-0) && !(max-0)){
-            return `正常值: (>=${min})`
-        }else if(!(min-0) && (max-0)){
-            if(min == '' || min == null){
-                return `正常值: (<=${max})`
-            }else{
-                return `正常值: (${min}~${max})`
-            }
-        }else{
-            return null;
-        }
-    }
     showDetails(val){
         if(val.questionDetailList.length > 0){
             return val.questionDetailList.map((item)=>{
@@ -255,7 +239,7 @@ class Inspect extends React.Component {
                 }
             })
         }else{
-            return <td><span className={val.value > val.maxValue || val.value < val.minValue?"red":''}>{val.value}</span> { val.labelSuffix}</td>
+            return <td><span className={(val.maxValue || val.minValue) ? (val.value > val.maxValue || val.value < val.minValue?"red":''):''}>{val.value}</span> { val.labelSuffix}</td>
         }
     }
     render() {
@@ -283,7 +267,7 @@ class Inspect extends React.Component {
                                                                 <td>{value.itemName}</td>
                                                                 <td><span className={value.type == 1?'red':null}>{value.value}</span> {value.unit}</td>
                                                                 <td>
-                                                                    {this.normalVal(value.min,value.max)}
+                                                                    {normalVal(value.min,value.max)}
                                                                 </td>
                                                                 <td>{value.time == ''?('导入时间: '+this.state.dateTime):'化验时间: '+value.time}</td>
                                                             </tr>
@@ -322,7 +306,7 @@ class Inspect extends React.Component {
                                                                 <td>{val.name}</td>
                                                                 {this.showDetails(val)}
                                                                 <td>
-                                                                    {this.normalVal(val.minValue,val.maxValue)}
+                                                                    {normalVal(val.minValue,val.maxValue)}
                                                                 </td>
                                                                 <td>{'化验时间:'+item.time}</td>
                                                             </tr>

+ 5 - 20
src/components/PreviewBody/index.jsx

@@ -1,5 +1,6 @@
 import React, { Component } from "react";
 import style from "./index.less";
+import { normalVal } from '@utils/tools';
 import $ from "jquery";
 
 (function ($) {
@@ -67,7 +68,6 @@ class PreviewBody extends Component {
             dateTime:"",
         }
         this.$content = React.createRef();
-        this.normalVal = this.normalVal.bind(this);
         this.getCurrentDate = this.getCurrentDate.bind(this);
         this.onPrint = this.onPrint.bind(this);
     }
@@ -94,21 +94,6 @@ class PreviewBody extends Component {
         let date = year+'-'+(mon<10?'0'+mon:mon)+'-'+(day<10?'0'+day:day);
         this.setState({dateTime:date})
     }
-    normalVal(min,max){
-        if((min-0) && (max-0)){
-            return `正常值: (${min}~${max})`
-        }else if((min-0) && !(max-0)){
-            return `正常值: (>=${min})`
-        }else if(!(min-0) && (max-0)){
-            if(min == '' || min == null){
-                return `正常值: (<=${max})`
-            }else{
-                return `正常值: (${min}~${max})`
-            }
-        }else{
-            return null;
-        }
-    }
     showDetails(val){
         if(val.questionDetailList.length > 0){
             return val.questionDetailList.map((item)=>{
@@ -116,8 +101,8 @@ class PreviewBody extends Component {
                     return <td style={{width:'23%'}}><span style={{color:item.abnormal != '0' ?"red":null}}>{val.value}</span> { val.labelSuffix}</td>
                 }
             })
-        }else{
-            return <td style={{width:'23%'}}><span style={{color:val.value > val.maxValue || val.value < val.minValue?"red":null}}>{val.value}</span> { val.labelSuffix}</td>
+        }else{ 
+            return <td style={{width:'23%'}}><span style={{color:(val.maxValue || val.minValue)?(val.value > val.maxValue || val.value < val.minValue?"red":null):null}}>{val.value}</span> { val.labelSuffix}</td>
         }
     }
     render() {
@@ -188,7 +173,7 @@ class PreviewBody extends Component {
                                                             <td style={{width:'25%',fontSize:'12px'}}>{value.itemName}</td>
                                                             <td style={{width:'23%',fontSize:'12px'}}><span style={{fontSize:'12px',color:value.type == 1?"red":null}}>{value.value}</span> {value.unit}</td>
                                                             <td style={{width:'24%',fontSize:'12px'}}>
-                                                                {this.normalVal(value.min,value.max)}
+                                                                {normalVal(value.min,value.max)}
                                                             </td>
                                                             <td style={{width:'28%',fontSize:'12px'}}>{value.time == ''?('导入时间: '+this.state.dateTime):'化验时间: '+value.time}</td>
                                                         </tr>
@@ -211,7 +196,7 @@ class PreviewBody extends Component {
                                                                 {this.showDetails(val)}
                                                                 
                                                                 <td style={{width:'24%'}}>
-                                                                    {this.normalVal(val.minValue,val.maxValue)}
+                                                                    {normalVal(val.minValue,val.maxValue)}
                                                                 </td>
                                                                 <td style={{width:'28%'}}>{'化验时间:'+item.time}</td>
                                                             </tr>

+ 1 - 1
src/components/PushContainer/index.jsx

@@ -146,7 +146,7 @@ class PushContainer extends Component {
     }
     /**
      * 改变模板标题
-     * @param {模板id和模板title} obj 
+     * @param {模板id和模板title} obj
      */
     handleTitleChange(obj) {
         store.dispatch(changeVisible(true))

+ 2 - 3
src/components/TemplateItems/TemplateItem/index.jsx

@@ -74,7 +74,7 @@ class TemplateItem extends React.Component {
                     isOpen: false
                 });
             });
-            console.log($(this.content).parent().siblings().find('.content'))
+            // console.log($(this.content).parent().siblings().find('.content'))
             return;
         }
         $(this.content).slideDown(() => {
@@ -148,12 +148,11 @@ class TemplateItem extends React.Component {
 
     handleEditIconClick(e) {
         e.stopPropagation();
-        const text = $.trim($(`<div>${this.titleDOM.innerHTML}</div>`).text());
+        const text = this.titleDOM.innerHTML;
         this.props.handleTitleChange({
             id: this.props.id,
             text: text
         });
-        return true;
     }
 
     recoverTitle() {

+ 17 - 2
src/utils/tools.js

@@ -599,7 +599,21 @@ function isAllClear(jsonData,jsonStr){
     return true;
   }
 }
-
+function normalVal(min,max){
+  if((min-0) && (max-0)){
+      return `正常值: (${min}~${max})`
+  }else if((min-0) && !(max-0)){
+      return `正常值: (>=${min})`
+  }else if(!(min-0) && (max-0)){
+      if(min == '' || min == null){
+          return `正常值: (<=${max})`
+      }else{
+          return `正常值: (${min}~${max})`
+      }
+  }else{
+      return null;
+  }
+}
 module.exports = {
     checkType: Type.checkType,
     regexp,
@@ -622,5 +636,6 @@ module.exports = {
     didPushParamChange,
     getEMRParams,
     windowEventHandler,
-    isAllClear
+    isAllClear,
+    normalVal
 };