From df079f762f480a9f07df39ee5d1875ee76897615 Mon Sep 17 00:00:00 2001 From: 18652063575 Date: Wed, 26 Oct 2022 16:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=9A=84=E5=85=AC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/salaryItem/formalFormModal.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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} />