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
A
ant-design-pro
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
ant-design-pro
Commits
5bcf895a
Commit
5bcf895a
authored
Sep 12, 2018
by
afc163
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor render or AdvancedForm
parent
77d714f2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
54 deletions
+66
-54
src/pages/Forms/AdvancedForm.js
src/pages/Forms/AdvancedForm.js
+66
-54
No files found.
src/pages/Forms/AdvancedForm.js
View file @
5bcf895a
...
...
@@ -74,35 +74,11 @@ class AdvancedForm extends PureComponent {
window
.
removeEventListener
(
'
resize
'
,
this
.
resizeFooterToolbar
);
}
resizeFooterToolbar
=
()
=>
{
requestAnimationFrame
(()
=>
{
const
sider
=
document
.
querySelectorAll
(
'
.ant-layout-sider
'
)[
0
];
if
(
sider
)
{
const
width
=
`calc(100% -
${
sider
.
style
.
width
}
)`
;
const
{
width
:
stateWidth
}
=
this
.
state
;
if
(
stateWidth
!==
width
)
{
this
.
setState
({
width
});
}
}
});
};
render
()
{
const
{
form
,
dispatch
,
submitting
}
=
this
.
props
;
const
{
getFieldDecorator
,
validateFieldsAndScroll
,
getFieldsError
}
=
form
;
const
validate
=
()
=>
{
validateFieldsAndScroll
((
error
,
values
)
=>
{
if
(
!
error
)
{
// submit the values
dispatch
({
type
:
'
form/submitAdvancedForm
'
,
payload
:
values
,
});
}
});
};
getErrorInfo
=
()
=>
{
const
{
form
:
{
getFieldsError
},
}
=
this
.
props
;
const
errors
=
getFieldsError
();
const
getErrorInfo
=
()
=>
{
const
errorCount
=
Object
.
keys
(
errors
).
filter
(
key
=>
errors
[
key
]).
length
;
if
(
!
errors
||
errorCount
===
0
)
{
return
null
;
...
...
@@ -140,7 +116,43 @@ class AdvancedForm extends PureComponent {
<
/span
>
);
};
resizeFooterToolbar
=
()
=>
{
requestAnimationFrame
(()
=>
{
const
sider
=
document
.
querySelectorAll
(
'
.ant-layout-sider
'
)[
0
];
if
(
sider
)
{
const
width
=
`calc(100% -
${
sider
.
style
.
width
}
)`
;
const
{
width
:
stateWidth
}
=
this
.
state
;
if
(
stateWidth
!==
width
)
{
this
.
setState
({
width
});
}
}
});
};
validate
=
()
=>
{
const
{
form
:
{
validateFieldsAndScroll
},
dispatch
,
}
=
this
.
props
;
validateFieldsAndScroll
((
error
,
values
)
=>
{
if
(
!
error
)
{
// submit the values
dispatch
({
type
:
'
form/submitAdvancedForm
'
,
payload
:
values
,
});
}
});
};
render
()
{
const
{
form
:
{
getFieldDecorator
},
submitting
,
}
=
this
.
props
;
const
{
width
}
=
this
.
state
;
return
(
<
PageHeaderWrapper
title
=
"
ι«ηΊ§θ‘¨ε
"
...
...
@@ -298,8 +310,8 @@ class AdvancedForm extends PureComponent {
})(
<
TableForm
/>
)}
<
/Card
>
<
FooterToolbar
style
=
{{
width
}}
>
{
getErrorInfo
()}
<
Button
type
=
"
primary
"
onClick
=
{
validate
}
loading
=
{
submitting
}
>
{
this
.
getErrorInfo
()}
<
Button
type
=
"
primary
"
onClick
=
{
this
.
validate
}
loading
=
{
submitting
}
>
ζδΊ€
<
/Button
>
<
/FooterToolbar
>
...
...
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