Merge branch 'feature/v2-薪资项目公式添加-1026' into develop

This commit is contained in:
18652063575 2022-11-02 13:44:52 +08:00
commit 5a27891e29
1 changed files with 31 additions and 1 deletions

View File

@ -24,6 +24,7 @@ export default class FormalFormModal extends React.Component {
this.field = {};
this.parameters = [];
this.referenceType = "";
this.timer = null;
}
componentWillMount() {
@ -73,6 +74,33 @@ export default class FormalFormModal extends React.Component {
this.formulaDatasourceList();
}
componentWillUnmount() {
clearTimeout(this.timer);
}
triggerKeyDown = (e) => {
let propsTextarea = this.contentProps.refs.textareaNormal.refs.input.refs.input; // 获取dom节点实例
const { value } = this.state;
if (e.key === "Backspace" && value) {
const { end } = this.getPositionForTextArea(propsTextarea);
const str = value.substring(end - 1, end);
if (str === "}") {
e.preventDefault();
const index = value.lastIndexOf("{", end - 1);
const currentValue = value.substring(index, end);
this.setState({
value: value.replace(currentValue, "")
}, () => {
if (propsTextarea.setSelectionRange) {
this.timer = setTimeout(() => {
propsTextarea.setSelectionRange(index, index);
}, 0);
}
});
}
}
};
formulaDatasourceList = () => {
const { salaryItemStore } = this.props;
const { formulaDatasourceList } = salaryItemStore;
@ -271,9 +299,11 @@ 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}
/>
</div>
<div style={{ display: "flex", height: "300px", marginTop: "10px" }}>