Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-blocks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
pro-blocks
Commits
b4fd0e05
Commit
b4fd0e05
authored
Jan 23, 2018
by
jim chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Perfect fix # 744
parent
99f9e59b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
src/routes/Forms/TableForm.js
src/routes/Forms/TableForm.js
+13
-6
No files found.
src/routes/Forms/TableForm.js
View file @
b4fd0e05
import
React
,
{
PureComponent
}
from
'
react
'
;
import
Debounce
from
'
lodash-decorators/debounce
'
;
import
Bind
from
'
lodash-decorators/bind
'
;
import
{
Table
,
Button
,
Input
,
message
,
Popconfirm
,
Divider
}
from
'
antd
'
;
import
styles
from
'
./style.less
'
;
...
...
@@ -10,6 +8,7 @@ export default class TableForm extends PureComponent {
this
.
state
=
{
data
:
props
.
value
,
loading
:
false
,
};
}
componentWillReceiveProps
(
nextProps
)
{
...
...
@@ -35,9 +34,7 @@ export default class TableForm extends PureComponent {
}
});
}
@
Bind
()
@
Debounce
(
400
)
toggleEditable
(
e
,
key
)
{
toggleEditable
=
(
e
,
key
)
=>
{
e
.
preventDefault
();
const
newData
=
this
.
state
.
data
.
map
(
item
=>
({
...
item
}));
const
target
=
this
.
getRowByKey
(
key
,
newData
);
...
...
@@ -83,6 +80,9 @@ export default class TableForm extends PureComponent {
}
saveRow
(
e
,
key
)
{
e
.
persist
();
this
.
setState
({
loading
:
true
,
});
// save field when blur input
setTimeout
(()
=>
{
if
(
document
.
activeElement
.
tagName
===
'
INPUT
'
&&
...
...
@@ -102,7 +102,10 @@ export default class TableForm extends PureComponent {
delete
target
.
isNew
;
this
.
toggleEditable
(
e
,
key
);
this
.
props
.
onChange
(
this
.
state
.
data
);
},
10
);
this
.
setState
({
loading
:
false
,
});
},
500
);
}
cancel
(
e
,
key
)
{
this
.
clickedCancel
=
true
;
...
...
@@ -179,6 +182,9 @@ export default class TableForm extends PureComponent {
title
:
'
操作
'
,
key
:
'
action
'
,
render
:
(
text
,
record
)
=>
{
if
(
!!
record
.
editable
&&
this
.
state
.
loading
)
{
return
null
;
}
if
(
record
.
editable
)
{
if
(
record
.
isNew
)
{
return
(
...
...
@@ -214,6 +220,7 @@ export default class TableForm extends PureComponent {
return
(
<
div
>
<
Table
loading
=
{
this
.
state
.
loading
}
columns
=
{
columns
}
dataSource
=
{
this
.
state
.
data
}
pagination
=
{
false
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment