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
985b81e2
Commit
985b81e2
authored
Sep 12, 2018
by
afc163
Committed by
偏右
Sep 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using onValuesChange instead of binding onChange
to every form item close #2196
parent
0f15cfc9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
57 deletions
+53
-57
src/pages/List/Applications.js
src/pages/List/Applications.js
+17
-30
src/pages/List/Articles.js
src/pages/List/Articles.js
+15
-4
src/pages/List/List.js
src/pages/List/List.js
+6
-1
src/pages/List/Projects.js
src/pages/List/Projects.js
+15
-22
No files found.
src/pages/List/Applications.js
View file @
985b81e2
...
@@ -12,29 +12,27 @@ import styles from './Applications.less';
...
@@ -12,29 +12,27 @@ import styles from './Applications.less';
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
const
FormItem
=
Form
.
Item
;
const
FormItem
=
Form
.
Item
;
@
Form
.
create
()
@
connect
(({
list
,
loading
})
=>
({
@
connect
(({
list
,
loading
})
=>
({
list
,
list
,
loading
:
loading
.
models
.
list
,
loading
:
loading
.
models
.
list
,
}))
}))
class
FilterCardList
extends
PureComponent
{
@
Form
.
create
({
componentDidMount
()
{
onValuesChange
({
dispatch
},
values
)
{
const
{
dispatch
}
=
this
.
props
;
// 表单项变化时请求数据
// eslint-disable-next-line
console
.
log
(
values
);
// 模拟查询表单生效
dispatch
({
dispatch
({
type
:
'
list/fetch
'
,
type
:
'
list/fetch
'
,
payload
:
{
payload
:
{
count
:
8
,
count
:
8
,
},
},
});
});
}
},
})
handleFormSubmit
=
()
=>
{
class
FilterCardList
extends
PureComponent
{
const
{
form
,
dispatch
}
=
this
.
props
;
componentDidMount
()
{
// setTimeout 用于保证获取表单值是在所有表单字段更新完毕的时候
const
{
dispatch
}
=
this
.
props
;
setTimeout
(()
=>
{
form
.
validateFields
(
err
=>
{
if
(
!
err
)
{
// eslint-disable-next-line
dispatch
({
dispatch
({
type
:
'
list/fetch
'
,
type
:
'
list/fetch
'
,
payload
:
{
payload
:
{
...
@@ -42,9 +40,6 @@ class FilterCardList extends PureComponent {
...
@@ -42,9 +40,6 @@ class FilterCardList extends PureComponent {
},
},
});
});
}
}
});
},
0
);
};
render
()
{
render
()
{
const
{
const
{
...
@@ -101,7 +96,7 @@ class FilterCardList extends PureComponent {
...
@@ -101,7 +96,7 @@ class FilterCardList extends PureComponent {
<
StandardFormRow
title
=
"
所属类目
"
block
style
=
{{
paddingBottom
:
11
}}
>
<
StandardFormRow
title
=
"
所属类目
"
block
style
=
{{
paddingBottom
:
11
}}
>
<
FormItem
>
<
FormItem
>
{
getFieldDecorator
(
'
category
'
)(
{
getFieldDecorator
(
'
category
'
)(
<
TagSelect
onChange
=
{
this
.
handleFormSubmit
}
expandable
>
<
TagSelect
expandable
>
<
TagSelect
.
Option
value
=
"
cat1
"
>
类目一
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat1
"
>
类目一
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat2
"
>
类目二
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat2
"
>
类目二
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat3
"
>
类目三
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat3
"
>
类目三
<
/TagSelect.Option
>
...
@@ -123,11 +118,7 @@ class FilterCardList extends PureComponent {
...
@@ -123,11 +118,7 @@ class FilterCardList extends PureComponent {
<
Col
lg
=
{
8
}
md
=
{
10
}
sm
=
{
10
}
xs
=
{
24
}
>
<
Col
lg
=
{
8
}
md
=
{
10
}
sm
=
{
10
}
xs
=
{
24
}
>
<
FormItem
{...
formItemLayout
}
label
=
"
作者
"
>
<
FormItem
{...
formItemLayout
}
label
=
"
作者
"
>
{
getFieldDecorator
(
'
author
'
,
{})(
{
getFieldDecorator
(
'
author
'
,
{})(
<
Select
<
Select
placeholder
=
"
不限
"
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
>
onChange
=
{
this
.
handleFormSubmit
}
placeholder
=
"
不限
"
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
>
<
Option
value
=
"
lisa
"
>
王昭君
<
/Option
>
<
Option
value
=
"
lisa
"
>
王昭君
<
/Option
>
<
/Select
>
<
/Select
>
)}
)}
...
@@ -136,11 +127,7 @@ class FilterCardList extends PureComponent {
...
@@ -136,11 +127,7 @@ class FilterCardList extends PureComponent {
<
Col
lg
=
{
8
}
md
=
{
10
}
sm
=
{
10
}
xs
=
{
24
}
>
<
Col
lg
=
{
8
}
md
=
{
10
}
sm
=
{
10
}
xs
=
{
24
}
>
<
FormItem
{...
formItemLayout
}
label
=
"
好评度
"
>
<
FormItem
{...
formItemLayout
}
label
=
"
好评度
"
>
{
getFieldDecorator
(
'
rate
'
,
{})(
{
getFieldDecorator
(
'
rate
'
,
{})(
<
Select
<
Select
placeholder
=
"
不限
"
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
>
onChange
=
{
this
.
handleFormSubmit
}
placeholder
=
"
不限
"
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
>
<
Option
value
=
"
good
"
>
优秀
<
/Option
>
<
Option
value
=
"
good
"
>
优秀
<
/Option
>
<
Option
value
=
"
normal
"
>
普通
<
/Option
>
<
Option
value
=
"
normal
"
>
普通
<
/Option
>
<
/Select
>
<
/Select
>
...
...
src/pages/List/Articles.js
View file @
985b81e2
...
@@ -12,11 +12,24 @@ const FormItem = Form.Item;
...
@@ -12,11 +12,24 @@ const FormItem = Form.Item;
const
pageSize
=
5
;
const
pageSize
=
5
;
@
Form
.
create
()
@
connect
(({
list
,
loading
})
=>
({
@
connect
(({
list
,
loading
})
=>
({
list
,
list
,
loading
:
loading
.
models
.
list
,
loading
:
loading
.
models
.
list
,
}))
}))
@
Form
.
create
({
onValuesChange
({
dispatch
},
values
)
{
// 表单项变化时请求数据
// eslint-disable-next-line
console
.
log
(
values
);
// 模拟查询表单生效
dispatch
({
type
:
'
list/fetch
'
,
payload
:
{
count
:
5
,
},
});
},
})
class
SearchList
extends
Component
{
class
SearchList
extends
Component
{
componentDidMount
()
{
componentDidMount
()
{
const
{
dispatch
}
=
this
.
props
;
const
{
dispatch
}
=
this
.
props
;
...
@@ -125,7 +138,7 @@ class SearchList extends Component {
...
@@ -125,7 +138,7 @@ class SearchList extends Component {
<
StandardFormRow
title
=
"
所属类目
"
block
style
=
{{
paddingBottom
:
11
}}
>
<
StandardFormRow
title
=
"
所属类目
"
block
style
=
{{
paddingBottom
:
11
}}
>
<
FormItem
>
<
FormItem
>
{
getFieldDecorator
(
'
category
'
)(
{
getFieldDecorator
(
'
category
'
)(
<
TagSelect
onChange
=
{
this
.
handleFormSubmit
}
expandable
>
<
TagSelect
expandable
>
<
TagSelect
.
Option
value
=
"
cat1
"
>
类目一
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat1
"
>
类目一
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat2
"
>
类目二
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat2
"
>
类目二
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat3
"
>
类目三
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat3
"
>
类目三
<
/TagSelect.Option
>
...
@@ -174,7 +187,6 @@ class SearchList extends Component {
...
@@ -174,7 +187,6 @@ class SearchList extends Component {
<
FormItem
{...
formItemLayout
}
label
=
"
活跃用户
"
>
<
FormItem
{...
formItemLayout
}
label
=
"
活跃用户
"
>
{
getFieldDecorator
(
'
user
'
,
{})(
{
getFieldDecorator
(
'
user
'
,
{})(
<
Select
<
Select
onChange
=
{
this
.
handleFormSubmit
}
placeholder
=
"
不限
"
placeholder
=
"
不限
"
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
>
>
...
@@ -187,7 +199,6 @@ class SearchList extends Component {
...
@@ -187,7 +199,6 @@ class SearchList extends Component {
<
FormItem
{...
formItemLayout
}
label
=
"
好评度
"
>
<
FormItem
{...
formItemLayout
}
label
=
"
好评度
"
>
{
getFieldDecorator
(
'
rate
'
,
{})(
{
getFieldDecorator
(
'
rate
'
,
{})(
<
Select
<
Select
onChange
=
{
this
.
handleFormSubmit
}
placeholder
=
"
不限
"
placeholder
=
"
不限
"
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
>
>
...
...
src/pages/List/List.js
View file @
985b81e2
...
@@ -21,7 +21,12 @@ class SearchList extends Component {
...
@@ -21,7 +21,12 @@ class SearchList extends Component {
default
:
default
:
break
;
break
;
}
}
};
}
handleFormSubmit
=
(
value
)
=>
{
// eslint-disable-next-line
console
.
log
(
value
);
}
render
()
{
render
()
{
const
tabList
=
[
const
tabList
=
[
...
...
src/pages/List/Projects.js
View file @
985b81e2
...
@@ -15,29 +15,27 @@ const FormItem = Form.Item;
...
@@ -15,29 +15,27 @@ const FormItem = Form.Item;
/* eslint react/no-array-index-key: 0 */
/* eslint react/no-array-index-key: 0 */
@
Form
.
create
()
@
connect
(({
list
,
loading
})
=>
({
@
connect
(({
list
,
loading
})
=>
({
list
,
list
,
loading
:
loading
.
models
.
list
,
loading
:
loading
.
models
.
list
,
}))
}))
class
CoverCardList
extends
PureComponent
{
@
Form
.
create
({
componentDidMount
()
{
onValuesChange
({
dispatch
},
values
)
{
const
{
dispatch
}
=
this
.
props
;
// 表单项变化时请求数据
// eslint-disable-next-line
console
.
log
(
values
);
// 模拟查询表单生效
dispatch
({
dispatch
({
type
:
'
list/fetch
'
,
type
:
'
list/fetch
'
,
payload
:
{
payload
:
{
count
:
8
,
count
:
8
,
},
},
});
});
}
},
})
handleFormSubmit
=
()
=>
{
class
CoverCardList
extends
PureComponent
{
const
{
form
,
dispatch
}
=
this
.
props
;
componentDidMount
()
{
// setTimeout 用于保证获取表单值是在所有表单字段更新完毕的时候
const
{
dispatch
}
=
this
.
props
;
setTimeout
(()
=>
{
form
.
validateFields
(
err
=>
{
if
(
!
err
)
{
// eslint-disable-next-line
dispatch
({
dispatch
({
type
:
'
list/fetch
'
,
type
:
'
list/fetch
'
,
payload
:
{
payload
:
{
...
@@ -45,9 +43,6 @@ class CoverCardList extends PureComponent {
...
@@ -45,9 +43,6 @@ class CoverCardList extends PureComponent {
},
},
});
});
}
}
});
},
0
);
};
render
()
{
render
()
{
const
{
const
{
...
@@ -108,7 +103,7 @@ class CoverCardList extends PureComponent {
...
@@ -108,7 +103,7 @@ class CoverCardList extends PureComponent {
<
StandardFormRow
title
=
"
所属类目
"
block
style
=
{{
paddingBottom
:
11
}}
>
<
StandardFormRow
title
=
"
所属类目
"
block
style
=
{{
paddingBottom
:
11
}}
>
<
FormItem
>
<
FormItem
>
{
getFieldDecorator
(
'
category
'
)(
{
getFieldDecorator
(
'
category
'
)(
<
TagSelect
onChange
=
{
this
.
handleFormSubmit
}
expandable
>
<
TagSelect
expandable
>
<
TagSelect
.
Option
value
=
"
cat1
"
>
类目一
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat1
"
>
类目一
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat2
"
>
类目二
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat2
"
>
类目二
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat3
"
>
类目三
<
/TagSelect.Option
>
<
TagSelect
.
Option
value
=
"
cat3
"
>
类目三
<
/TagSelect.Option
>
...
@@ -131,7 +126,6 @@ class CoverCardList extends PureComponent {
...
@@ -131,7 +126,6 @@ class CoverCardList extends PureComponent {
<
FormItem
{...
formItemLayout
}
label
=
"
作者
"
>
<
FormItem
{...
formItemLayout
}
label
=
"
作者
"
>
{
getFieldDecorator
(
'
author
'
,
{})(
{
getFieldDecorator
(
'
author
'
,
{})(
<
Select
<
Select
onChange
=
{
this
.
handleFormSubmit
}
placeholder
=
"
不限
"
placeholder
=
"
不限
"
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
>
>
...
@@ -144,7 +138,6 @@ class CoverCardList extends PureComponent {
...
@@ -144,7 +138,6 @@ class CoverCardList extends PureComponent {
<
FormItem
{...
formItemLayout
}
label
=
"
好评度
"
>
<
FormItem
{...
formItemLayout
}
label
=
"
好评度
"
>
{
getFieldDecorator
(
'
rate
'
,
{})(
{
getFieldDecorator
(
'
rate
'
,
{})(
<
Select
<
Select
onChange
=
{
this
.
handleFormSubmit
}
placeholder
=
"
不限
"
placeholder
=
"
不限
"
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
style
=
{{
maxWidth
:
200
,
width
:
'
100%
'
}}
>
>
...
...
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