薪资项目公式

This commit is contained in:
18652063575 2022-10-26 17:55:16 +08:00
parent df079f762f
commit 54da9eb8cd
1 changed files with 14 additions and 13 deletions

View File

@ -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}