diff --git a/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js b/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js index 40210edd..34df10d7 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js @@ -205,7 +205,7 @@ export default class CustomSalaryItemSlide extends React.Component { }} onClick={() => { if (this.props.record.canEdit || isAdd) { - this.handleShowFormal(); + editable && this.handleShowFormal(); } }}> {formulaContent} diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index 8d9cd46d..5b01e4b1 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js @@ -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} />
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/index.js b/pc4mobx/hrmSalary/pages/salaryItem/index.js index eaa343a4..b1de5c9a 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/index.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/index.js @@ -75,7 +75,7 @@ export default class SalaryItem extends React.Component { const { salaryItemStore: { deleteItemRequest, getTableDatas } } = this.props; Modal.confirm({ title: "信息确认", - content: "确认删除", + content: "确认删除该条数据吗?", onOk: () => { deleteItemRequest([record.id]).then(() => { getTableDatas({ ...this.state.searchParams }).then(res => { @@ -143,7 +143,7 @@ export default class SalaryItem extends React.Component { }}>删除 }> - + ); } else {