From 6b7221c263a576802b16c5d67228fd93a2571f88 Mon Sep 17 00:00:00 2001 From: wunayou <574612524@qq.com> Date: Thu, 1 Feb 2018 18:59:54 +0800 Subject: [PATCH] =?UTF-8?q?Let=20=E2=80=98button=20of=20save=E2=80=99=20&?= =?UTF-8?q?=20=E2=80=98button=20of=20cancel=E2=80=99=20have=20a=20opportun?= =?UTF-8?q?ity=20=20to=20be=20used=20--=20Advanced=20Form=20(#864)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 让保存 取消 按钮有点击的机会 * Update TableForm.js delete --- src/routes/Forms/TableForm.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/routes/Forms/TableForm.js b/src/routes/Forms/TableForm.js index 1f73e3bf..a8b18c6f 100644 --- a/src/routes/Forms/TableForm.js +++ b/src/routes/Forms/TableForm.js @@ -72,12 +72,7 @@ export default class TableForm extends PureComponent { this.setState({ loading: true, }); - // save field when blur input setTimeout(() => { - if (document.activeElement.tagName === 'INPUT' && - document.activeElement !== e.target) { - return; - } if (this.clickedCancel) { this.clickedCancel = false; return; @@ -110,6 +105,7 @@ export default class TableForm extends PureComponent { delete this.cacheOriginData[key]; } this.setState({ data: newData }); + this.clickedCancel = false; } render() { const columns = [{ @@ -124,7 +120,6 @@ export default class TableForm extends PureComponent { value={text} autoFocus onChange={e => this.handleFieldChange(e, 'name', record.key)} - onBlur={e => this.saveRow(e, record.key)} onKeyPress={e => this.handleKeyPress(e, record.key)} placeholder="成员姓名" /> @@ -143,7 +138,6 @@ export default class TableForm extends PureComponent { this.handleFieldChange(e, 'workId', record.key)} - onBlur={e => this.saveRow(e, record.key)} onKeyPress={e => this.handleKeyPress(e, record.key)} placeholder="工号" /> @@ -162,7 +156,6 @@ export default class TableForm extends PureComponent { this.handleFieldChange(e, 'department', record.key)} - onBlur={e => this.saveRow(e, record.key)} onKeyPress={e => this.handleKeyPress(e, record.key)} placeholder="所属部门" /> @@ -181,7 +174,7 @@ export default class TableForm extends PureComponent { if (record.isNew) { return ( - 保存 + this.saveRow(e, record.key)}>添加 this.remove(record.key)}> 删除 @@ -191,7 +184,7 @@ export default class TableForm extends PureComponent { } return ( - 保存 + this.saveRow(e, record.key)}>保存 this.cancel(e, record.key)}>取消 -- GitLab