From df079f762f480a9f07df39ee5d1875ee76897615 Mon Sep 17 00:00:00 2001 From: 18652063575 Date: Wed, 26 Oct 2022 16:38:09 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=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} />
From 54da9eb8cdc310a92a62873bb532051e790c14cf Mon Sep 17 00:00:00 2001 From: 18652063575 Date: Wed, 26 Oct 2022 17:55:16 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=85=AC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/salaryItem/formalFormModal.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index 038056e1..27176264 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js @@ -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} From 3bef4802426599921497ec31d3c338afc6bdbdb4 Mon Sep 17 00:00:00 2001 From: 18652063575 Date: Thu, 27 Oct 2022 10:29:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=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 | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index 27176264..c79eff3d 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js @@ -80,12 +80,13 @@ export default class FormalFormModal extends React.Component { const str = propsTextarea.value.substring(end - 1, end); if (str === "}") { const index = propsTextarea.value.lastIndexOf("{", end - 1); - const currentValue = propsTextarea.value.substring(index, end); + const currentValue = propsTextarea.value.substring(index + 1, end); + console.log(currentValue); + console.log(propsTextarea.value.replace(currentValue, "")); this.setState({ value: propsTextarea.value.replace(currentValue, "") },()=>{ - console.log(this.state.value); - propsTextarea.value= 'this.state.value'; + propsTextarea.value= this.state.value; }); } } @@ -109,13 +110,12 @@ export default class FormalFormModal extends React.Component { // 多行文本编辑 handleChange(value) { - console.log(value); if (value && value.trim() == "") { this.parameters = []; } - // this.setState({ - // value - // }); + this.setState({ + value + }); } // 获取光标位置 @@ -290,7 +290,8 @@ 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} From 91a131913828878996126933a26bb33cbb549a91 Mon Sep 17 00:00:00 2001 From: 18652063575 Date: Thu, 27 Oct 2022 15:07:47 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feature/v2-=E8=96=AA=E8=B5=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=85=AC=E5=BC=8F=E6=B7=BB=E5=8A=A0-1026?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/salaryItem/formalFormModal.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index c79eff3d..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,20 +74,28 @@ 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节点实例 - if (e.key === "Backspace" && propsTextarea.value) { + const { value } = this.state; + if (e.key === "Backspace" && value) { const { end } = this.getPositionForTextArea(propsTextarea); - const str = propsTextarea.value.substring(end - 1, end); + const str = value.substring(end - 1, end); if (str === "}") { - const index = propsTextarea.value.lastIndexOf("{", end - 1); - const currentValue = propsTextarea.value.substring(index + 1, end); - console.log(currentValue); - console.log(propsTextarea.value.replace(currentValue, "")); + e.preventDefault(); + const index = value.lastIndexOf("{", end - 1); + const currentValue = value.substring(index, end); this.setState({ - value: propsTextarea.value.replace(currentValue, "") - },()=>{ - propsTextarea.value= this.state.value; + value: value.replace(currentValue, "") + }, () => { + if (propsTextarea.setSelectionRange) { + this.timer = setTimeout(() => { + propsTextarea.setSelectionRange(index, index); + }, 0); + } }); } } From c287818eec0b7cd5c02142019768177069176590 Mon Sep 17 00:00:00 2001 From: 18652063575 Date: Wed, 2 Nov 2022 13:59:35 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js | 2 +- pc4mobx/hrmSalary/pages/salaryItem/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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 {