diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index 8d9cd46d..038056e1 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js @@ -73,6 +73,24 @@ export default class FormalFormModal extends React.Component { this.formulaDatasourceList(); } + triggerKeyDown = (e) => { + const { value } = this.state; + if (e.key === "Backspace" && value) { + let propsTextarea = this.contentProps.refs.textareaNormal.refs.input.refs.input; // 获取dom节点实例 + const { end } = this.getPositionForTextArea(propsTextarea); + const str = 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, "}")); + this.setState({ + value: this.state.value.replace(currentValue, "}") + }); + } + } + }; + formulaDatasourceList = () => { const { salaryItemStore } = this.props; const { formulaDatasourceList } = salaryItemStore; @@ -274,6 +292,7 @@ export default class FormalFormModal extends React.Component { value={value} onChange={(value) => this.handleChange(value)} noResize={true} style={{ fontSize: "14px", lineHeight: 1.2 }} + onKeyDown={this.triggerKeyDown} />