Browse Source

获取当前时间时分秒

Luolei 6 years ago
parent
commit
6c0082fced

+ 64 - 63
src/components/AddInspect/index.jsx

@@ -1,8 +1,8 @@
 import React from 'react';
-import { SearchOption, InspectCommon, Calendar ,Notify,ConfirmModal,Add,DelToast} from '@commonComp';
+import { SearchOption, InspectCommon, Calendar, Notify, ConfirmModal, Add, DelToast } from '@commonComp';
 import SlideExcel from './SlideExcel';
 import SlideSelect from './SlideSelect';
-import { deepClone,getPageCoordinate,getStatusImg } from '@utils/tools';
+import { deepClone, getPageCoordinate, getStatusImg ,getCurrentDate} from '@utils/tools';
 import styles from './index.less';
 import date1 from './img/date1.png';
 import close from './img/close.png';
@@ -24,9 +24,9 @@ class Inspect extends React.Component {
       num: 0,            //暂存数据,获取一次,不能每次都是新的数据
       type: null,
       id: null,
-      pageTop:'',
+      pageTop: '',
       // tmpIds: [],      //内层外层
-      impId:null
+      impId: null
     }
     this.handleChangeDate = this.handleChangeDate.bind(this)
     this.handleShowDate = this.handleShowDate.bind(this)
@@ -45,7 +45,7 @@ class Inspect extends React.Component {
   }
   delConfirm() {//弹窗确定
     const { delPartItem, handleCloseExcel, handlePush } = this.props;
-    const { type, id ,impId} = this.state;
+    const { type, id, impId } = this.state;
     if (type == 1) {
       delPartItem(id)
     } else if (type == 2) {
@@ -59,18 +59,18 @@ class Inspect extends React.Component {
     Notify.success("删除成功");
     handlePush && handlePush();       //右侧推送
   }
-  handleDelClick(type, idx) { 
-    if (type == 2){
+  handleDelClick(type, idx) {
+    if (type == 2) {
       this.setState({
-        impId:idx,
+        impId: idx,
         type: type,
-        id:null
+        id: null
       })
-    }else{
+    } else {
       this.setState({
         type: type,
         id: idx,
-        impId:null
+        impId: null
       })
     }
   }
@@ -101,9 +101,9 @@ class Inspect extends React.Component {
           this.setState({ showFill: false, date: false });
         }
       }
-      
-      if(_del){
-        if(!event.target.isEqualNode(_impClose) && !event.target.isEqualNode(_addClose) && !event.target.isEqualNode(_del)  && event.target.parentNode != _del && !event.target.isEqualNode(_closeTil)){
+
+      if (_del) {
+        if (!event.target.isEqualNode(_impClose) && !event.target.isEqualNode(_addClose) && !event.target.isEqualNode(_del) && event.target.parentNode != _del && !event.target.isEqualNode(_closeTil)) {
           this.setState({
             id: null,
             impId: null
@@ -111,7 +111,7 @@ class Inspect extends React.Component {
         }
       }
     });
-    this.getCurrentDate();
+    this.setState({ dateTime: getCurrentDate(1) })
   }
   componentWillReceiveProps(nextProps) {
     if (nextProps.fillActive.name != this.props.fillActive.name) {
@@ -122,12 +122,13 @@ class Inspect extends React.Component {
     this.setState({ showFill: false })
   }
   handleChangeDate(info) {
-    let date = info.year + '-' + (info.month < 10 ? '0' + info.month : info.month) + '-' + (info.day < 10 ? '0' + info.day : info.day);
+    let date = info.year+'-'+info.month.toString().padStart(2,'0')+'-'+info.day.toString().padStart(2,'0')
+    // let date = info.year+'-'+info.month.toString().padStart(2,'0')+'-'+info.day.toString().padStart(2,'0')+' '+h.toString().padStart(2,'0')+m.toString().padStart(2,'0')+s.toString().padStart(2,'0');
     this.setState({ dateTime: date, date: false })
   }
   handleSearchShow(e) {
     let tmpShow = this.state.show;
-    this.setState({ show: !tmpShow,pageTop:getPageCoordinate(e).boxTop })
+    this.setState({ show: !tmpShow, pageTop: getPageCoordinate(e).boxTop })
     // e.stopPropagation();
   }
   handleFillShow(e, idx) {
@@ -137,7 +138,7 @@ class Inspect extends React.Component {
       showFill: !tmpShow,
       currentIdx: idx,
       currentData: baseList,
-      dateTime: baseList.time ? baseList.time : this.getCurrentDate()
+      dateTime: baseList.time ? baseList.time : getCurrentDate(1)
     })
     e.stopPropagation();
   }
@@ -172,7 +173,7 @@ class Inspect extends React.Component {
         tempArr.details[i].value = ''
         tempArr.show = false;
       }
-      tempArr.time = this.getCurrentDate();
+      tempArr.time = getCurrentDate(1);
       this.setState({ currentData: tempArr })
       return;
     } else {
@@ -258,7 +259,7 @@ class Inspect extends React.Component {
             className={styles.searchLi}
             title={(item.name == item.retrievalName || !item.retrievalName) ? item.name : item.name + '(' + item.retrievalName + ')'}
             onClick={() => {
-              handleSign(item.questionId, idx,'search');
+              handleSign(item.questionId, idx, 'search');
               this.setState({ show: false })
             }}
           >
@@ -268,8 +269,8 @@ class Inspect extends React.Component {
       }
     </ul>
   }
-  getCommonList(){//常用列表
-    const { handleSign,inspectList } = this.props;
+  getCommonList() {//常用列表
+    const { handleSign, inspectList } = this.props;
     return <ul className={styles.searchLiUl}>
       {
         inspectList && inspectList.map((item, idx) => {
@@ -277,7 +278,7 @@ class Inspect extends React.Component {
             className={styles.searchLi}
             title={item.name}
             onClick={() => {
-              handleSign(item.questionId, idx,'common');
+              handleSign(item.questionId, idx, 'common');
               this.setState({ show: false })
             }}
           >
@@ -288,32 +289,32 @@ class Inspect extends React.Component {
     </ul>
   }
   showDetails(val) {
-  let min = val.minValue,max = val.maxValue,value = val.value,dom = '';
-  if(!isNaN(min) && !isNaN(max)){//有最大值最小值
-    if(isNaN(value)){//输入的不是数据
-      dom = getStatusImg(1,value,1)
-    }else if(value <= min){//下降
-      dom = getStatusImg(3,value,1)
-    }else if(value >= max){//上升
-      dom = getStatusImg(2,value,1)
-    }else{//正常
-      dom = getStatusImg(0,value,1)
-    }
-  }else if(isNaN(min) && !isNaN(max)){//有最大值无最小值
-    if(value >= max){//上升
-      dom = getStatusImg(2,value,1)
-    }else{//正常
-      dom = getStatusImg(0,value,1)
-    }
-  }else if(!isNaN(min) && isNaN(max)){//有最小值无最大值
-    if(value <= min){//下降
-      dom = getStatusImg(3,value,1)
-    }else{//正常
-      dom = getStatusImg(0,value,1)
+    let min = val.minValue, max = val.maxValue, value = val.value, dom = '';
+    if (!isNaN(min) && !isNaN(max)) {//有最大值最小值
+      if (isNaN(value)) {//输入的不是数据
+        dom = getStatusImg(1, value, 1)
+      } else if (value <= min) {//下降
+        dom = getStatusImg(3, value, 1)
+      } else if (value >= max) {//上升
+        dom = getStatusImg(2, value, 1)
+      } else {//正常
+        dom = getStatusImg(0, value, 1)
+      }
+    } else if (isNaN(min) && !isNaN(max)) {//有最大值无最小值
+      if (value >= max) {//上升
+        dom = getStatusImg(2, value, 1)
+      } else {//正常
+        dom = getStatusImg(0, value, 1)
+      }
+    } else if (!isNaN(min) && isNaN(max)) {//有最小值无最大值
+      if (value <= min) {//下降
+        dom = getStatusImg(3, value, 1)
+      } else {//正常
+        dom = getStatusImg(0, value, 1)
+      }
+    } else {//无最大最小值
+      dom = getStatusImg(1, value, 1)
     }
-  }else{//无最大最小值
-    dom = getStatusImg(1,value,1)
-  }
     if (val.questionDetailList.length > 0) {
       return val.questionDetailList.map((item) => {
         if (val.value == item.name) {
@@ -326,8 +327,8 @@ class Inspect extends React.Component {
     }
   }
   render() {
-    const { getInfomation,handleChangeValue,inspectVal, list, labelList,windowHeight, delPartItem, handleLabelSub, handleClear, handleConfirm, fillActive, getExcelDataList, handleCloseExcel, handlePush } = this.props;
-    const { tmpId, tmpIdx,id,pageTop,impId} = this.state;
+    const { getInfomation, handleChangeValue, inspectVal, list, labelList, windowHeight, delPartItem, handleLabelSub, handleClear, handleConfirm, fillActive, getExcelDataList, handleCloseExcel, handlePush } = this.props;
+    const { tmpId, tmpIdx, id, pageTop, impId } = this.state;
 
     return (
       <div className={styles.wrapper}>
@@ -339,10 +340,10 @@ class Inspect extends React.Component {
                   items && items.lisExcelRes.length > 0 ? <ul className={styles.excelDataLists}>
                     {/*<img className={styles.close} src={close} alt="关闭导入excel数据" onClick={() => { this.handleDelClick(2, id) }} />*/}
                     <span className={styles.close} id="impClose" onClick={() => { this.handleDelClick(2, ind) }}></span>
-                    <DelToast show={impId==ind?true:false}
-                    name="该导入项" 
-                    cancel={this.handleCancel}
-                    confirm={this.delConfirm}/>
+                    <DelToast show={impId == ind ? true : false}
+                      name="该导入项"
+                      cancel={this.handleCancel}
+                      confirm={this.delConfirm} />
                     {
                       items.lisExcelRes.map((item, idx) => {
                         return <SlideExcel
@@ -365,7 +366,7 @@ class Inspect extends React.Component {
                 return <SlideSelect
                   item={item}
                   idx={idx}
-                  showToast={idx==id?true:false}
+                  showToast={idx == id ? true : false}
                   showFill={this.state.showFill}
                   handlePush={handlePush}
                   fillActive={fillActive}
@@ -390,17 +391,17 @@ class Inspect extends React.Component {
             }
           </ul>
         </div>
-        <div style={{ position: "relative", clear: "both",top:"5px" }}>
+        <div style={{ position: "relative", clear: "both", top: "5px" }}>
           <Add showText="添加化验项" handleClick={(e) => this.handleSearchShow(e)} id="searchWrap" />
           {this.state.show ? <SearchOption windowHeight={windowHeight} height={280} pageTop={pageTop} handleChangeValue={handleChangeValue} visible={true}>
-            {list && list.length>0?this.getSearchList(list):(inspectVal == ''?'':<p style={{padding:'5px 30px',color:'#bfbfbf'}}>暂无筛选项</p>)}
+            {list && list.length > 0 ? this.getSearchList(list) : (inspectVal == '' ? '' : <p style={{ padding: '5px 30px', color: '#bfbfbf' }}>暂无筛选项</p>)}
             {
-              list && list.length>0 || (inspectVal != '')?'':<div>
-                  <p style={{padding:'5px 30px',color:'#bfbfbf'}}>常用化验项</p>
-                  {
-                    this.getCommonList()
-                  }
-                </div>
+              list && list.length > 0 || (inspectVal != '') ? '' : <div>
+                <p style={{ padding: '5px 30px', color: '#bfbfbf' }}>常用化验项</p>
+                {
+                  this.getCommonList()
+                }
+              </div>
             }
           </SearchOption> : ''}
         </div>

+ 2 - 2
src/components/EmergencyProcedure/EmergencyModal/index.jsx

@@ -16,7 +16,7 @@ class EmergencyModal extends React.Component{
       show:false,
       imgShow:false,
       diseaseName:[
-        '胸痛','心包积液','气胸','肺栓塞','急性冠脉综合征','主动脉夹层'
+        '','心包积液','气胸','肺栓塞','急性冠脉综合征','主动脉夹层'
       ]
     }
     this.handleImgShow=this.handleImgShow.bind(this)
@@ -68,7 +68,7 @@ class EmergencyModal extends React.Component{
               <i></i>
               {
                 this.state.diseaseName.map((item,index)=>{
-                  return <li className={idx == index?styles.selectColor:null} onClick={()=>{this.setDataIdx(index,false)}}>
+                  return <li className={idx == index?styles.selectColor:null} style={{display:item?'inline-block':'none'}} onClick={()=>{this.setDataIdx(index,false)}}>
                     {item}
                   </li>
                 })

+ 4 - 4
src/utils/tools.js

@@ -762,10 +762,10 @@ function getCurrentDate(flg,con){
   let day = myDate.getDate();            //获取当前日(1-31)
   let date = '';           
   if(flg){
-    var h = date.getHours();
-    var m = date.getMinutes();
-    var s = date.getSeconds();
-    date = year+link+mon.toString().padStart(2,'0')+link+day.toString().padStart(2,'0')+' '+h.toString().padStart(2,'0')+m.toString().padStart(2,'0')+s.toString().padStart(2,'0');
+    var h = myDate.getHours();
+    var m = myDate.getMinutes();
+    var s = myDate.getSeconds();
+    date = year+link+mon.toString().padStart(2,'0')+link+day.toString().padStart(2,'0')+' '+h.toString().padStart(2,'0')+':'+m.toString().padStart(2,'0')+':'+s.toString().padStart(2,'0');
   }else{
     date = year+link+mon.toString().padStart(2,'0')+link+day.toString().padStart(2,'0');
   }