Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenshaokai
jinfa-platform
Commits
c890010c
Commit
c890010c
authored
Apr 29, 2022
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 调整布局
parent
ccc45f48
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
CustomAddArray.tsx
src/components/NiceForm/components/CustomAddArray.tsx
+20
-21
No files found.
src/components/NiceForm/components/CustomAddArray.tsx
View file @
c890010c
...
...
@@ -3,26 +3,21 @@ import styled from 'styled-components'
import
{
toArr
}
from
'@formily/shared'
;
import
{
SchemaField
,
FormPath
}
from
'@formily/antd'
;
import
{
Button
}
from
'antd'
;
import
{
PlusOutlined
}
from
'@ant-design/icons'
;
// 由于自增列表里 无法进行mega布局, 所以只能在该组件下 重写样式
const
RowStyleLayout
=
styled
(
props
=>
<
div
{
...
props
}
/>)
`
.ant-btn {
margin-right: 16px;
}
.ant-form-item {
display: inline-flex;
margin-right: 16px;
margin-bottom: 16px;
}
const
RowStyleLayout
=
styled
(({
style
,
...
restProps
})
=>
<
div
{
...
restProps
}
style=
{
{
paddingRight
:
56
,
position
:
'relative'
,
...
style
,
}
}
/>)
`
> .ant-form-item {
margin-bottom: 20px
;
margin-right: 20px
;
width: 100%
;
flex: 1
;
}
> .ant-form-item:last-child
{
margin-right: 0
;
.schema-wrap
{
width: 100%
;
}
.ant-form-item-control {
max-width: none;
.btn-remove {
position: absolute;
top: 0;
right: 0;
}
`
...
...
@@ -34,17 +29,21 @@ const CustomAddArray = (props) => {
const
onRemove
=
index
=>
mutators
.
remove
(
index
)
return
(
<
div
>
<
div
style=
{
{
width
:
'100%'
,
flex
:
1
}
}
>
{
toArr
(
value
).
map
((
item
,
index
,
arr
)
=>
(
<
RowStyleLayout
{
...
componentProps
}
key=
{
index
}
>
<
SchemaField
path=
{
FormPath
.
parse
(
path
).
concat
(
index
)
}
onlyRenderProperties
/>
<
Button
onClick=
{
onAdd
.
bind
(
null
,
index
)
}
type=
'primary'
>
+
</
Button
>
<
Button
onClick=
{
onRemove
.
bind
(
null
,
index
)
}
>
-
</
Button
>
<
Button
className=
"btn-remove"
onClick=
{
onRemove
.
bind
(
null
,
index
)
}
>
-
</
Button
>
</
RowStyleLayout
>
))
}
{
(
!
value
||
!
value
.
length
)
&&
(
<
Button
onClick=
{
onAdd
}
type=
'primary'
>
+
</
Button
>
)
}
<
Button
onClick=
{
onAdd
}
type=
"dashed"
icon=
{
<
PlusOutlined
/>
}
block
>
添加
</
Button
>
</
div
>
)
}
...
...
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