diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index 038056e1..27176264 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js @@ -74,18 +74,18 @@ export default class FormalFormModal extends React.Component { } triggerKeyDown = (e) => { - const { value } = this.state; - if (e.key === "Backspace" && value) { - let propsTextarea = this.contentProps.refs.textareaNormal.refs.input.refs.input; // 获取dom节点实例 + let propsTextarea = this.contentProps.refs.textareaNormal.refs.input.refs.input; // 获取dom节点实例 + if (e.key === "Backspace" && propsTextarea.value) { const { end } = this.getPositionForTextArea(propsTextarea); - const str = value.substring(end - 1, end); + const str = propsTextarea.value.substring(end - 1, end); if (str === "}") { - const index = value.lastIndexOf("{", end - 1); - const currentValue = value.substring(index, end); - console.log("currentValue", this.state.value, currentValue); - console.log(this.state.value.replace(currentValue, "}")); + const index = propsTextarea.value.lastIndexOf("{", end - 1); + const currentValue = propsTextarea.value.substring(index, end); this.setState({ - value: this.state.value.replace(currentValue, "}") + value: propsTextarea.value.replace(currentValue, "") + },()=>{ + console.log(this.state.value); + propsTextarea.value= 'this.state.value'; }); } } @@ -109,12 +109,13 @@ export default class FormalFormModal extends React.Component { // 多行文本编辑 handleChange(value) { + console.log(value); if (value && value.trim() == "") { this.parameters = []; } - this.setState({ - value - }); + // this.setState({ + // value + // }); } // 获取光标位置 @@ -289,7 +290,7 @@ export default class FormalFormModal extends React.Component { ref={(input) => this.contentProps = input} minRows={8} maxRows={8} - value={value} onChange={(value) => this.handleChange(value)} + // value={value} onChange={(value) => this.handleChange(value)} noResize={true} style={{ fontSize: "14px", lineHeight: 1.2 }} onKeyDown={this.triggerKeyDown}