浏览代码

推送模式更改

luolei 4 年之前
父节点
当前提交
e3b6c417d3

+ 15 - 1
src/components/AddAssistCheck/Textarea/index.jsx

@@ -17,6 +17,7 @@ class Textarea extends Component {
     this.$domW = React.createRef();
     this.$domW = React.createRef();
     this.handleInput = this.handleInput.bind(this);
     this.handleInput = this.handleInput.bind(this);
     this.handleFocus = this.handleFocus.bind(this);
     this.handleFocus = this.handleFocus.bind(this);
+    this.handleInputFocus = this.handleInputFocus.bind(this);
   }
   }
   handleInput(e){
   handleInput(e){
     const {handleChangeAssistValue,idx,handlePush} = this.props;
     const {handleChangeAssistValue,idx,handlePush} = this.props;
@@ -24,9 +25,9 @@ class Textarea extends Component {
     $(e.target).find('img').remove();
     $(e.target).find('img').remove();
     this.context.scrollArea.scrollBottom();       //避免滚动条上移不见
     this.context.scrollArea.scrollBottom();       //避免滚动条上移不见
     // e.target.innerHTML = e.target.textContent
     // e.target.innerHTML = e.target.textContent
-    const stimer = this.state.timer;
     handleChangeAssistValue&&handleChangeAssistValue(text,idx);
     handleChangeAssistValue&&handleChangeAssistValue(text,idx);
     //右侧推送--延时推送
     //右侧推送--延时推送
+    const stimer = this.state.timer;
     clearTimeout(stimer);
     clearTimeout(stimer);
     let timer = setTimeout(function(){
     let timer = setTimeout(function(){
       handlePush&&handlePush({mode:9});
       handlePush&&handlePush({mode:9});
@@ -42,6 +43,18 @@ class Textarea extends Component {
       timer
       timer
     });
     });
   }
   }
+  handleInputFocus(){
+    const {handlePush} = this.props;
+    const stimer = this.state.timer;
+    clearTimeout(stimer);
+    let timer = setTimeout(function(){
+      handlePush&&handlePush({mode:9});
+      clearTimeout(stimer);
+    },config.delayPushTime);
+    this.setState({
+      timer
+    });
+  }
   shouldComponentUpdate(next){
   shouldComponentUpdate(next){
     if(JSON.stringify(next) == JSON.stringify(this.props)){
     if(JSON.stringify(next) == JSON.stringify(this.props)){
       return false;
       return false;
@@ -97,6 +110,7 @@ class Textarea extends Component {
             ref={this.$dom}
             ref={this.$dom}
             onInput={this.handleInput}
             onInput={this.handleInput}
             onKeyUp={this.handleInput}
             onKeyUp={this.handleInput}
+            onFocus={this.handleInputFocus}
         ></div>
         ></div>
         <p ref={this.textInput} onClick={this.handleFocus} className={`${style.textareaWarring} ${setFontColorSize(2)}`}></p>
         <p ref={this.textInput} onClick={this.handleFocus} className={`${style.textareaWarring} ${setFontColorSize(2)}`}></p>
       </div>
       </div>

+ 21 - 6
src/components/AddAssistCheck/index.jsx

@@ -1,6 +1,7 @@
 import React from 'react';
 import React from 'react';
 import { SearchOption, Calendar, ConfirmModal, Notify, Add ,DelToast} from '@commonComp';
 import { SearchOption, Calendar, ConfirmModal, Notify, Add ,DelToast} from '@commonComp';
 import styles from './index.less';
 import styles from './index.less';
+import config from '@config/index';
 import $ from 'jquery';
 import $ from 'jquery';
 import Textarea from './Textarea';
 import Textarea from './Textarea';
 import AssistName from './AssistName';
 import AssistName from './AssistName';
@@ -18,6 +19,7 @@ class AddAssistCheck extends React.Component {
       visible: false,
       visible: false,
       pageTop:'',
       pageTop:'',
       id: null,
       id: null,
+      stimer: null,
       activeName:''
       activeName:''
     }
     }
     this.handleShowDate = this.handleShowDate.bind(this)
     this.handleShowDate = this.handleShowDate.bind(this)
@@ -185,13 +187,25 @@ class AddAssistCheck extends React.Component {
     $(e.target).removeAttr('disabled').focus()
     $(e.target).removeAttr('disabled').focus()
   }
   }
   handleBlur(){
   handleBlur(){
-    const {handlePush} = this.props;
+    // const {handlePush} = this.props;
     $('.canEdit').attr('disabled','disabled')
     $('.canEdit').attr('disabled','disabled')
-    handlePush && handlePush({mode:8});       //右侧推送
+    // handlePush && handlePush({mode:8});       //右侧推送
   }
   }
   handleInput(e,item,idx){
   handleInput(e,item,idx){
-    const {setTipValue} = this.props
+    const {setTipValue,handlePush} = this.props
     setTipValue(item,e.target.value,idx)
     setTipValue(item,e.target.value,idx)
+    //右侧推送--延时推送
+    const stimer = this.state.timer;
+    clearTimeout(stimer);
+    let timer = setTimeout(function(){
+      handlePush&&handlePush({mode:9});
+      clearTimeout(stimer);
+    },config.delayPushTime);
+    this.setState({timer})
+  }
+  handleFocus(){
+    const {handlePush} = this.props;
+    handlePush&&handlePush({mode:9});
   }
   }
   getAssistLabel() {
   getAssistLabel() {
     const { assistLabel,checkedListImport, handleChangeAssistValue,checkOnOff, handleChangeDate, isRead, handlePush, winWidth,getInfomation,assistList } = this.props;
     const { assistLabel,checkedListImport, handleChangeAssistValue,checkOnOff, handleChangeDate, isRead, handlePush, winWidth,getInfomation,assistList } = this.props;
@@ -246,15 +260,16 @@ class AddAssistCheck extends React.Component {
               </div>
               </div>
               <div className={`${styles.pointerFinger} ${setFontColorSize(2,2)}`}>
               <div className={`${styles.pointerFinger} ${setFontColorSize(2,2)}`}>
                 <p>报告日期:<span>
                 <p>报告日期:<span>
-                  <input disabled="disabled" type="text" 
+                  <input type="text" 
                       class="canEdit"
                       class="canEdit"
-                      onDoubleClick={(e)=>this.setEdit(e)}
+                      // onDoubleClick={(e)=>this.setEdit(e)}
                       style={'#333'}
                       style={'#333'}
                       placeholder='时间'
                       placeholder='时间'
                       autoComplete="off"
                       autoComplete="off"
                       value={item.time}
                       value={item.time}
+                      onFocus={()=>{this.handleFocus()}}
                       onInput={(e)=>{this.handleInput(e,item,idx)}}
                       onInput={(e)=>{this.handleInput(e,item,idx)}}
-                      onBlur={()=>{this.handleBlur()}}
+                      // onBlur={()=>{this.handleBlur()}}
                       />
                       />
                 </span></p>
                 </span></p>
                 <span className={styles.closeIcon} id="assiClose" onClick={() => { this.handleDelClick(idx,item) }}></span>
                 <span className={styles.closeIcon} id="assiClose" onClick={() => { this.handleDelClick(idx,item) }}></span>

+ 17 - 24
src/components/AddInspect/SlidePic/index.jsx

@@ -1,13 +1,12 @@
 import React, { Component } from "react";
 import React, { Component } from "react";
 import styles from "./index.less";
 import styles from "./index.less";
-import { normalVal,getArrow,timestampToTime,getDomUpDown,getPageCoordinate,setPosition,setFontColorSize } from '@utils/tools';
+import { normalVal,getArrow,getDomUpDown,getPageCoordinate,setPosition,setFontColorSize } from '@utils/tools';
 import { InspectCommon, Notify,DelToast} from '@commonComp';
 import { InspectCommon, Notify,DelToast} from '@commonComp';
 import slideUp from "@common/images/slide-up.png";
 import slideUp from "@common/images/slide-up.png";
 import slideDown from "@common/images/slide-down.png";
 import slideDown from "@common/images/slide-down.png";
 import checkOff from '@common/images/check_off.png';
 import checkOff from '@common/images/check_off.png';
 import checkOn from '@common/images/check_on.png';
 import checkOn from '@common/images/check_on.png';
 import $ from 'jquery';
 import $ from 'jquery';
-import date1 from '../img/date1.png';
 import ScrollArea from 'react-scrollbar';
 import ScrollArea from 'react-scrollbar';
 import InspectName from '../InspectName';
 import InspectName from '../InspectName';
 import store from '@store';
 import store from '@store';
@@ -27,7 +26,6 @@ class SlideSelect extends Component {
       style:'',
       style:'',
       timer: null,
       timer: null,
     };
     };
-    this.toTime = this.toTime.bind(this);
     this.handleSlide = this.handleSlide.bind(this);
     this.handleSlide = this.handleSlide.bind(this);
     this.handleDel = this.handleDel.bind(this);
     this.handleDel = this.handleDel.bind(this);
     this.handleCancel = this.handleCancel.bind(this);
     this.handleCancel = this.handleCancel.bind(this);
@@ -64,18 +62,6 @@ class SlideSelect extends Component {
     });
     });
     // this.setState({ dateTime: getCurrentDate(1) })
     // this.setState({ dateTime: getCurrentDate(1) })
   }
   }
-  toTime(time){
-    let tmpTim = time.split(',').join('')-0
-    if(time && tmpTim.toString() != 'NaN'){
-      let date = new Date('1900-01-01');
-      let dateTim = date.getTime();
-      let times = (tmpTim-2)*24*60*60*1000;
-      let result = timestampToTime(dateTim+times).split(' ')[0]
-      return result;
-    }else{
-      return time;
-    }
-  }
   handleSlide(){
   handleSlide(){
     let tmpShow = this.state.show
     let tmpShow = this.state.show
     this.setState({
     this.setState({
@@ -149,6 +135,10 @@ class SlideSelect extends Component {
     $('.canEdit').attr('disabled','disabled')
     $('.canEdit').attr('disabled','disabled')
     handlePush && handlePush({mode:8});       //右侧推送
     handlePush && handlePush({mode:8});       //右侧推送
   }
   }
+  handleFocus(){
+    const {handlePush} = this.props;
+    handlePush && handlePush({mode:8});       //右侧推送
+  }
   checkOnOff(item,idx){
   checkOnOff(item,idx){
     const {checkOnOff,handlePush} = this.props
     const {checkOnOff,handlePush} = this.props
     checkOnOff(item,idx)
     checkOnOff(item,idx)
@@ -175,15 +165,16 @@ class SlideSelect extends Component {
               <span className={styles.edit}></span>
               <span className={styles.edit}></span>
               <span className={styles.maxmin}></span>
               <span className={styles.maxmin}></span>
               <span className={styles.pass}>检验时间:
               <span className={styles.pass}>检验时间:
-                <input disabled="disabled" type="text" 
+                <input type="text" 
                     class="canEdit" 
                     class="canEdit" 
-                    onDoubleClick={(e)=>this.setEdit(e)}
+                    // onDoubleClick={(e)=>this.setEdit(e)}
                     style={{color:'#333'}}
                     style={{color:'#333'}}
                     placeholder='时间'
                     placeholder='时间'
                     autoComplete="off"
                     autoComplete="off"
                     value={item.time}
                     value={item.time}
                     onInput={(e)=>{this.handleInput(e,item,idx)}}
                     onInput={(e)=>{this.handleInput(e,item,idx)}}
-                    onBlur={()=>{this.handleBlur()}}
+                    onFocus={()=>{this.handleFocus()}}
+                    // onBlur={()=>{this.handleBlur()}}
                     />
                     />
               </span>
               </span>
               <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item,idx)}}></span>
               <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item,idx)}}></span>
@@ -200,28 +191,30 @@ class SlideSelect extends Component {
           <span className={styles.bigname}>{item.name}</span>
           <span className={styles.bigname}>{item.name}</span>
           <span className={styles.smallname}>{item.uniqueName}</span>
           <span className={styles.smallname}>{item.uniqueName}</span>
           <span className={styles.edit}>
           <span className={styles.edit}>
-            <input disabled="disabled" type="text" 
+            <input type="text" 
               class="canEdit"
               class="canEdit"
-              onDoubleClick={(e)=>this.setEdit(e)}
+              // onDoubleClick={(e)=>this.setEdit(e)}
               style={{ color: style == 2 || style == 4 ? 'red' : style == 1 ? '#D949FF' : '#333', backgroundColor: item.value && item.value.length>0 ? '#eeeeee' : ''}}
               style={{ color: style == 2 || style == 4 ? 'red' : style == 1 ? '#D949FF' : '#333', backgroundColor: item.value && item.value.length>0 ? '#eeeeee' : ''}}
               placeholder='(填写)'
               placeholder='(填写)'
               autoComplete="off"
               autoComplete="off"
               value={item.value||item.otherValue}
               value={item.value||item.otherValue}
               onInput={(e)=>{this.handleInput(e,item,idx)}}
               onInput={(e)=>{this.handleInput(e,item,idx)}}
-              onBlur={()=>{this.handleBlur()}}
+              // onBlur={()=>{this.handleBlur()}}
+              onFocus={()=>{this.handleFocus()}}
               /><img style={{display:style==1||style==2?'inline-block':'none'}} src={style==1?down:style==2?up:''} />{item.units}
               /><img style={{display:style==1||style==2?'inline-block':'none'}} src={style==1?down:style==2?up:''} />{item.units}
           </span>
           </span>
           <span className={styles.maxmin}>{normalVal(item.minValue,item.maxValue)}</span>
           <span className={styles.maxmin}>{normalVal(item.minValue,item.maxValue)}</span>
           <span className={styles.pass}>检验时间:
           <span className={styles.pass}>检验时间:
-            <input disabled="disabled" type="text" 
+            <input type="text" 
                 class="canEdit" 
                 class="canEdit" 
-                onDoubleClick={(e)=>this.setEdit(e)}
+                // onDoubleClick={(e)=>this.setEdit(e)}
                 style={{color:'#333'}}
                 style={{color:'#333'}}
                 placeholder='时间'
                 placeholder='时间'
                 autoComplete="off"
                 autoComplete="off"
                 value={item.time}
                 value={item.time}
                 onInput={(e)=>{this.handleInput(e,item,idx,1)}}
                 onInput={(e)=>{this.handleInput(e,item,idx,1)}}
-                onBlur={()=>{this.handleBlur()}}
+                // onBlur={()=>{this.handleBlur()}}
+                onFocus={()=>{this.handleFocus()}}
                 />
                 />
           </span>
           </span>
           <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item,idx)}}></span>
           <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item,idx)}}></span>

+ 17 - 16
src/components/AddNewInspect/SlideIpt/index.jsx

@@ -1,5 +1,6 @@
 import React, { Component } from "react";
 import React, { Component } from "react";
 import $ from 'jquery';
 import $ from 'jquery';
+import config from '@config/index';
 
 
 class SlideIpt extends Component {
 class SlideIpt extends Component {
   constructor(props) {
   constructor(props) {
@@ -13,7 +14,6 @@ class SlideIpt extends Component {
       value:''
       value:''
     };
     };
     this.setEdit = this.setEdit.bind(this);
     this.setEdit = this.setEdit.bind(this);
-    this.handleBlur = this.handleBlur.bind(this);
   }
   }
   
   
   componentDidMount(){
   componentDidMount(){
@@ -21,35 +21,36 @@ class SlideIpt extends Component {
     this.setState({value:item.time})
     this.setState({value:item.time})
   }
   }
   handleInput(e,item,sign){
   handleInput(e,item,sign){
-    e.stopPropagation();
-    const {setTipValue} = this.props
+    const {setTipValue,handlePush} = this.props;
     setTipValue(item,e.target.value,sign)
     setTipValue(item,e.target.value,sign)
+    //右侧推送--延时推送
+    const stimer = this.state.timer;
+    clearTimeout(stimer);
+    let timer = setTimeout(function(){
+      handlePush&&handlePush({mode:8});
+      clearTimeout(stimer);
+    },config.delayPushTime);
+    this.setState({timer})
   }
   }
-  handleInputTime(e){
-    this.setState({value:e.target.value})
-  }
-  handleBlur(e,item,sign){
-    const {handlePush,setTipValue} = this.props;
-    $('.canEdit').attr('disabled','disabled')
-    setTipValue(item,e.target.value,sign)
-    handlePush && handlePush({mode:8});       //右侧推送
+  handleFocus(){
+    const {handlePush} = this.props;
+    handlePush&&handlePush({mode:8});
   }
   }
   setEdit(e){
   setEdit(e){
-    // $('.canEdit').blur().attr('disabled','disabled')
     $(e.target).removeAttr('disabled').focus()
     $(e.target).removeAttr('disabled').focus()
   }
   }
   render() {
   render() {
     const {item,idx} = this.props;
     const {item,idx} = this.props;
     return (
     return (
-      <input disabled="disabled" type="text" 
+      <input type="text" 
           class="canEdit" 
           class="canEdit" 
-          onDoubleClick={(e)=>this.setEdit(e)}
+          // onDoubleClick={(e)=>this.setEdit(e)}
           style={{color:'#333'}}
           style={{color:'#333'}}
           placeholder='时间'
           placeholder='时间'
           autoComplete="off"
           autoComplete="off"
           value={this.state.value}
           value={this.state.value}
-          onInput={(e)=>{this.handleInputTime(e)}}
-          onBlur={(e)=>{this.handleBlur(e,item,1,idx)}}
+          onInput={(e)=>{this.handleInput(e,item,1,idx)}}
+          onFocus={()=>{this.handleFocus()}}
           />
           />
     );
     );
   }
   }

+ 18 - 4
src/components/AddNewInspect/SlidePic/index.jsx

@@ -1,6 +1,7 @@
 import React, { Component } from "react";
 import React, { Component } from "react";
 import styles from "./index.less";
 import styles from "./index.less";
 import {  Notify,DelToast} from '@commonComp';
 import {  Notify,DelToast} from '@commonComp';
+import config from '@config/index';
 import $ from 'jquery';
 import $ from 'jquery';
 import checkOff from '@common/images/check_off.png';
 import checkOff from '@common/images/check_off.png';
 import checkOn from '@common/images/check_on.png';
 import checkOn from '@common/images/check_on.png';
@@ -60,8 +61,16 @@ class SlidePic extends Component {
   }
   }
   handleInput(e,item,sign){
   handleInput(e,item,sign){
     e.stopPropagation();
     e.stopPropagation();
-    const {setTipValue} = this.props
+    const {setTipValue,handlePush} = this.props
     setTipValue(item,e.target.value,sign)
     setTipValue(item,e.target.value,sign)
+    //右侧推送--延时推送
+    const stimer = this.state.timer;
+    clearTimeout(stimer);
+    let timer = setTimeout(function(){
+      handlePush&&handlePush({mode:8});
+      clearTimeout(stimer);
+    },config.delayPushTime);
+    this.setState({timer})
   }
   }
   handleBlur(){
   handleBlur(){
     const {handlePush} = this.props;
     const {handlePush} = this.props;
@@ -77,6 +86,10 @@ class SlidePic extends Component {
     // $('.canEdit').blur().attr('disabled','disabled')
     // $('.canEdit').blur().attr('disabled','disabled')
     $(e.target).removeAttr('disabled').focus()
     $(e.target).removeAttr('disabled').focus()
   }
   }
+  handleFocus(){
+    const {handlePush} = this.props;
+    handlePush&&handlePush({mode:8});
+  }
   render() {
   render() {
     const {item,time,setTipValue,idx,handlePush} = this.props;
     const {item,time,setTipValue,idx,handlePush} = this.props;
     const {canEdit,activeInd,activeName,value,style} = this.state;
     const {canEdit,activeInd,activeName,value,style} = this.state;
@@ -88,15 +101,16 @@ class SlidePic extends Component {
           <span className={styles.edit}>
           <span className={styles.edit}>
             {
             {
               item.flg == 5||item.flg == 8?
               item.flg == 5||item.flg == 8?
-              <input disabled='disabled' type="text" 
+              <input type="text" 
                 class="canEdit" 
                 class="canEdit" 
-                onDoubleClick={(e)=>this.setEdit(e)}
+                // onDoubleClick={(e)=>this.setEdit(e)}
                 style={{color:'#333'}}
                 style={{color:'#333'}}
                 placeholder={item.flg == 5?'(填写用法计量)':'(填写用量)'}
                 placeholder={item.flg == 5?'(填写用法计量)':'(填写用量)'}
                 autoComplete="off"
                 autoComplete="off"
                 value={item.value}
                 value={item.value}
                 onInput={(e)=>{this.handleInput(e,item,2,idx)}}
                 onInput={(e)=>{this.handleInput(e,item,2,idx)}}
-                onBlur={()=>{this.handleBlur()}}
+                // onBlur={()=>{this.handleBlur()}}
+                onFocus={()=>{this.handleFocus()}}
                 />:null
                 />:null
             }
             }
           </span>
           </span>