Commit 6b7221c2 authored by wunayou's avatar wunayou Committed by ddcat1115

Let ‘button of save’ & ‘button of cancel’ have a opportunity to be used -- Advanced Form (#864)

* 让保存  取消 按钮有点击的机会

* Update TableForm.js

delete
parent 295580c0
...@@ -72,12 +72,7 @@ export default class TableForm extends PureComponent { ...@@ -72,12 +72,7 @@ export default class TableForm extends PureComponent {
this.setState({ this.setState({
loading: true, loading: true,
}); });
// save field when blur input
setTimeout(() => { setTimeout(() => {
if (document.activeElement.tagName === 'INPUT' &&
document.activeElement !== e.target) {
return;
}
if (this.clickedCancel) { if (this.clickedCancel) {
this.clickedCancel = false; this.clickedCancel = false;
return; return;
...@@ -110,6 +105,7 @@ export default class TableForm extends PureComponent { ...@@ -110,6 +105,7 @@ export default class TableForm extends PureComponent {
delete this.cacheOriginData[key]; delete this.cacheOriginData[key];
} }
this.setState({ data: newData }); this.setState({ data: newData });
this.clickedCancel = false;
} }
render() { render() {
const columns = [{ const columns = [{
...@@ -124,7 +120,6 @@ export default class TableForm extends PureComponent { ...@@ -124,7 +120,6 @@ export default class TableForm extends PureComponent {
value={text} value={text}
autoFocus autoFocus
onChange={e => this.handleFieldChange(e, 'name', record.key)} onChange={e => this.handleFieldChange(e, 'name', record.key)}
onBlur={e => this.saveRow(e, record.key)}
onKeyPress={e => this.handleKeyPress(e, record.key)} onKeyPress={e => this.handleKeyPress(e, record.key)}
placeholder="成员姓名" placeholder="成员姓名"
/> />
...@@ -143,7 +138,6 @@ export default class TableForm extends PureComponent { ...@@ -143,7 +138,6 @@ export default class TableForm extends PureComponent {
<Input <Input
value={text} value={text}
onChange={e => this.handleFieldChange(e, 'workId', record.key)} onChange={e => this.handleFieldChange(e, 'workId', record.key)}
onBlur={e => this.saveRow(e, record.key)}
onKeyPress={e => this.handleKeyPress(e, record.key)} onKeyPress={e => this.handleKeyPress(e, record.key)}
placeholder="工号" placeholder="工号"
/> />
...@@ -162,7 +156,6 @@ export default class TableForm extends PureComponent { ...@@ -162,7 +156,6 @@ export default class TableForm extends PureComponent {
<Input <Input
value={text} value={text}
onChange={e => this.handleFieldChange(e, 'department', record.key)} onChange={e => this.handleFieldChange(e, 'department', record.key)}
onBlur={e => this.saveRow(e, record.key)}
onKeyPress={e => this.handleKeyPress(e, record.key)} onKeyPress={e => this.handleKeyPress(e, record.key)}
placeholder="所属部门" placeholder="所属部门"
/> />
...@@ -181,7 +174,7 @@ export default class TableForm extends PureComponent { ...@@ -181,7 +174,7 @@ export default class TableForm extends PureComponent {
if (record.isNew) { if (record.isNew) {
return ( return (
<span> <span>
<a>保存</a> <a onClick={e => this.saveRow(e, record.key)}>添加</a>
<Divider type="vertical" /> <Divider type="vertical" />
<Popconfirm title="是否要删除此行?" onConfirm={() => this.remove(record.key)}> <Popconfirm title="是否要删除此行?" onConfirm={() => this.remove(record.key)}>
<a>删除</a> <a>删除</a>
...@@ -191,7 +184,7 @@ export default class TableForm extends PureComponent { ...@@ -191,7 +184,7 @@ export default class TableForm extends PureComponent {
} }
return ( return (
<span> <span>
<a>保存</a> <a onClick={e => this.saveRow(e, record.key)}>保存</a>
<Divider type="vertical" /> <Divider type="vertical" />
<a onClick={e => this.cancel(e, record.key)}>取消</a> <a onClick={e => this.cancel(e, record.key)}>取消</a>
</span> </span>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment