|
@@ -1,14 +1,17 @@
|
|
import React, { Component } from "react";
|
|
import React, { Component } from "react";
|
|
import style from "./index.less";
|
|
import style from "./index.less";
|
|
import config from '@config/index';
|
|
import config from '@config/index';
|
|
|
|
+import $ from 'jquery';
|
|
|
|
|
|
class Textarea extends Component {
|
|
class Textarea extends Component {
|
|
constructor(props) {
|
|
constructor(props) {
|
|
super(props);
|
|
super(props);
|
|
this.state = {
|
|
this.state = {
|
|
- timer:null
|
|
|
|
|
|
+ timer:null,
|
|
|
|
+ val:'报告描述或意见'
|
|
};
|
|
};
|
|
this.$dom = React.createRef();
|
|
this.$dom = 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.handleBlur = this.handleBlur.bind(this);
|
|
this.handleBlur = this.handleBlur.bind(this);
|
|
@@ -24,6 +27,11 @@ class Textarea extends Component {
|
|
handlePush&&handlePush();
|
|
handlePush&&handlePush();
|
|
clearTimeout(stimer);
|
|
clearTimeout(stimer);
|
|
},config.delayPushTime);
|
|
},config.delayPushTime);
|
|
|
|
+ if(text.trim() != ''){
|
|
|
|
+ this.setState({val:''})
|
|
|
|
+ }else{
|
|
|
|
+ this.setState({val:'报告描述或意见'})
|
|
|
|
+ }
|
|
this.setState({
|
|
this.setState({
|
|
timer
|
|
timer
|
|
});
|
|
});
|
|
@@ -44,26 +52,32 @@ class Textarea extends Component {
|
|
const {value} = this.props;
|
|
const {value} = this.props;
|
|
if(value){
|
|
if(value){
|
|
this.$dom.current.innerText = value||'';
|
|
this.$dom.current.innerText = value||'';
|
|
|
|
+ this.setState({val:''})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
handleFocus(e){
|
|
handleFocus(e){
|
|
- console.log(e.target)
|
|
|
|
-
|
|
|
|
|
|
+ this.setState({val:''})
|
|
}
|
|
}
|
|
handleBlur(e){
|
|
handleBlur(e){
|
|
- console.log(e.target)
|
|
|
|
|
|
+ let str = this.$dom.current.innerText
|
|
|
|
+ if(str.trim() == ''){
|
|
|
|
+ this.setState({val:'报告描述或意见'})
|
|
|
|
+ }
|
|
}
|
|
}
|
|
render() {
|
|
render() {
|
|
- const {value} = this.props;
|
|
|
|
|
|
+ const {val} = this.state;
|
|
return (
|
|
return (
|
|
- <div className={style.divTextarea}
|
|
|
|
- contenteditable={true}
|
|
|
|
- ref={this.$dom}
|
|
|
|
- onInput={this.handleInput}
|
|
|
|
- onFocus={this.handleFocus}
|
|
|
|
- onBlur={this.handleBlur}
|
|
|
|
- onPropertyChange={this.handleInput}
|
|
|
|
- ></div>
|
|
|
|
|
|
+ <div className={style.textWap}>
|
|
|
|
+ <div className={style.divTextarea}
|
|
|
|
+ contenteditable={true}
|
|
|
|
+ ref={this.$dom}
|
|
|
|
+ onInput={this.handleInput}
|
|
|
|
+ onFocus={this.handleFocus}
|
|
|
|
+ onBlur={this.handleBlur}
|
|
|
|
+ onPropertyChange={this.handleInput}
|
|
|
|
+ ></div>
|
|
|
|
+ <p className={style.textareaWarring} id="textareaWarring">{val}</p>
|
|
|
|
+ </div>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|