薪资项目管理的公式修改

This commit is contained in:
18652063575 2022-10-26 16:38:09 +08:00
parent c4c24dd159
commit df079f762f
1 changed files with 19 additions and 0 deletions

View File

@ -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}
/>
</div>
<div style={{ display: "flex", height: "300px", marginTop: "10px" }}>