浏览代码

改为失去焦点提交推送

yangdr 2 月之前
父节点
当前提交
610780dcfa
共有 3 个文件被更改,包括 70 次插入48 次删除
  1. 2 1
      package.json
  2. 67 46
      src/common/components/BlockInp/index.jsx
  3. 1 1
      src/utils/config.js

+ 2 - 1
package.json

@@ -70,9 +70,10 @@
     "koa2-cors": "^2.0.6",
     "log4js": "^3.0.4",
     "react-redux": "4.4.9",
+    "react-scripts": "^5.0.1",
     "react-scrollbar": "^0.5.6",
     "react-server": "^0.8.1",
     "redux": "3.5.2",
     "redux-thunk": "2.2.0"
   }
-}
+}

+ 67 - 46
src/common/components/BlockInp/index.jsx

@@ -2,20 +2,20 @@ import React, { PureComponent } from "react";
 import style from "./index.less";
 import Notify from '../Notify';
 import config from '@config/index';
-import {isIE,moveEnd} from '@utils/tools.js';
-import {getFeature} from '@store/async-actions/fetchModules';
-import {getAllDataList,getAllDataStringList,ifOtherClear,setFontColorSize} from "@utils/tools.js";
+import { isIE, moveEnd } from '@utils/tools.js';
+import { getFeature } from '@store/async-actions/fetchModules';
+import { getAllDataList, getAllDataStringList, ifOtherClear, setFontColorSize } from "@utils/tools.js";
 import store from '@store';
 import $ from "jquery";
-import {SET_CURRENT_MODULE} from '@types/homePage';
-import {getMRAnalyse} from '@store/async-actions/pushMessage';
+import { SET_CURRENT_MODULE } from '@types/homePage';
+import { getMRAnalyse } from '@store/async-actions/pushMessage';
 
 class BlockInp extends PureComponent {
   constructor(props) {
     super(props);
     this.state = {
-      timer:null,
-      inpText:'',
+      timer: null,
+      inpText: '',
     };
     this.$dom = React.createRef();
     this.handleInput = this.handleInput.bind(this);
@@ -24,94 +24,115 @@ class BlockInp extends PureComponent {
     this.handleKeydown = this.handleKeydown.bind(this);
     this.handleBlur = this.handleBlur.bind(this);
   }
-  handleFocus(e){            //初始显示props中的值,focus已经显示输入的值,避免值更新闪烁
-    const {boxMark,title,handlePush} = this.props;
+  handleFocus(e) {            //初始显示props中的值,focus已经显示输入的值,避免值更新闪烁
+    const { boxMark, title, handlePush } = this.props;
     const state = store.getState()
     const moduleName = state.homePage.moduleName
     //黏贴时去掉html格式
     const that = this;
     let txt = '';
-    $(this.$dom.current).on("paste",function(e){
-      setTimeout(function(){
-        txt = that.$dom.current.innerText||that.$dom.current.innerHTML;
+    $(this.$dom.current).on("paste", function (e) {
+      setTimeout(function () {
+        txt = that.$dom.current.innerText || that.$dom.current.innerHTML;
         that.$dom.current.innerHTML = txt;
         moveEnd($(that.$dom.current)[0]);     //光标落到最后去
       });
     });
-    handlePush&&handlePush({boxMark,isFocus:true,state});    //主诉、现病史空白聚焦推送
-    if(moduleName != title) {
+    handlePush && handlePush({ boxMark, isFocus: true, state });    //主诉、现病史空白聚焦推送
+    if (moduleName != title) {
       store.dispatch({
         type: SET_CURRENT_MODULE,
-        moduleName:title
+        moduleName: title
       })
       store.dispatch(getMRAnalyse())
     }
 
 
   }
-  handleInput(e){
-    const {handleInput,handlePush,boxMark} = this.props;
-    const text = e.target.innerText || e.target.innerHTML.replace(/&nbsp;+/g,' ').replace(/<br>$/,'');
+  handleInput(e) {
+    const { handleInput, handlePush, boxMark } = this.props;
+    const text = e.target.innerText || e.target.innerHTML.replace(/&nbsp;+/g, ' ').replace(/<br>$/, '');
     // console.log(text,999999999999)
     const stimer = this.state.timer;//console.log(e.target,text)
     this.setState({
-      inpText:text,
+      inpText: text,
     })
 
     //存值到store  FF26 会有一个<br>
-    handleInput&&handleInput({text:text.replace('<br>',''),boxMark});
+    handleInput && handleInput({ text: text.replace('<br>', ''), boxMark });
     //右侧推送--延时推送
     clearTimeout(stimer);
-    let timer = setTimeout(function(){
-      handlePush&&handlePush({boxMark});
+    let timer = setTimeout(function () {
+      handlePush && handlePush({ boxMark });
       clearTimeout(stimer);
-    },config.delayPushTime);
+    }, config.delayPushTime);
     this.setState({
       timer
     });
   }
-  handleBlur(e){
+  handleBlur(e) {
+
+    const { handleInput, handlePush, boxMark } = this.props;
+    const text = e.target.innerText || e.target.innerHTML.replace(/&nbsp;+/g, ' ').replace(/<br>$/, '');
+    // console.log("@@@", e, text)
+    // console.log(text,999999999999)
+    const stimer = this.state.timer;//console.log(e.target,text)
+    this.setState({
+      inpText: text,
+    })
+
+    //存值到store  FF26 会有一个<br>
+    handleInput && handleInput({ text: text.replace('<br>', ''), boxMark });
+    //右侧推送--延时推送
+    clearTimeout(stimer);
+    let timer = setTimeout(function () {
+      handlePush && handlePush({ boxMark });
+      clearTimeout(stimer);
+    }, config.delayPushTime);
+    this.setState({
+      timer
+    });
     //解除绑定事件
     $(this.$dom.current).off("paste");
   }
-  handleKeydown(e){
-    const ev = e||window.event;
-    if(ev.keyCode==13){return false;}
+  handleKeydown(e) {
+    const ev = e || window.event;
+    if (ev.keyCode == 13) { return false; }
   }
-  componentWillReceiveProps(next){
+  componentWillReceiveProps(next) {
     const isRead = this.props.isRead;
-    if(next.isRead != isRead){    //value对比解决复诊不显示bug,复诊对比解决关标跳到前面bug
-      this.$dom.current.innerHTML = next.value||'';   //ff26下不支持innerText,但ref会自动加上innerText属性,所以上面的判断不为空
+    if (next.isRead != isRead) {    //value对比解决复诊不显示bug,复诊对比解决关标跳到前面bug
+      this.$dom.current.innerHTML = next.value || '';   //ff26下不支持innerText,但ref会自动加上innerText属性,所以上面的判断不为空
       this.setState({
         inpText: next.value
       });
     }
   }
-  componentDidMount(){
-    const {value} = this.props;
-    if(value){
+  componentDidMount() {
+    const { value } = this.props;
+    if (value) {
       //this.$dom.current.innerText?(this.$dom.current.innerText = value||''):(this.$dom.current.innerText=value||'');
-      this.$dom.current.innerText=value||'';
+      this.$dom.current.innerText = value || '';
     }
-    if(isIE()){
-      $(this.$dom.current).onIe8Input(function(e){
+    if (isIE()) {
+      $(this.$dom.current).onIe8Input(function (e) {
         this.handleInput(e)
-      },this);
+      }, this);
     }
   }
   render() {
-    const { title,boxMark } = this.props;
+    const { title, boxMark } = this.props;
     // console.log(this.props,'=============');
     return (
       <div className={style["box"]}>
-        <div className={`${style["title"]} ${setFontColorSize(2,4)}`}>{title}</div>
-        <div className={`${style["content"]} ${setFontColorSize(2,5)}`}
-             onFocus={this.handleFocus}
-             ref={this.$dom}
-             contentEditable={true}
-             onInput={this.handleInput}
-             onkeydown={this.handleKeydown}
-             onBlur={+boxMark===1?this.handleBlur:null}>
+        <div className={`${style["title"]} ${setFontColorSize(2, 4)}`}>{title}</div>
+        <div className={`${style["content"]} ${setFontColorSize(2, 5)}`}
+          onFocus={this.handleFocus}
+          ref={this.$dom}
+          contentEditable={true}
+          // onInput={this.handleInput}
+          onkeydown={this.handleKeydown}
+          onBlur={+boxMark === 1 ? this.handleBlur : null}>
         </div>
       </div>
     );

+ 1 - 1
src/utils/config.js

@@ -11,7 +11,7 @@ const host = 'http://173.18.12.195:6060';//后端接口访问地址
 const imageUrlPrefix = 'http://173.18.12.194:82';
 function geturl() {
     return {
-        gourl: 'http://' + window.location.hostname + ':8081/cdss.html',
+        gourl: 'http://' + window.location.hostname + ':8082/cdss.html',
         imgurl: 'http://' + window.location.hostname + ':82'
     }
 }