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
陈智峰
jinfa-platform
Commits
c3b887ed
Commit
c3b887ed
authored
Jul 31, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增schema组件
parent
7d1553b7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
1 deletion
+146
-1
CardCheckBox.tsx
src/components/NiceForm/components/CardCheckBox.tsx
+98
-0
CustomSlider.tsx
src/components/NiceForm/components/CustomSlider.tsx
+26
-0
Text.tsx
src/components/NiceForm/components/Text.tsx
+14
-0
index.tsx
src/components/NiceForm/index.tsx
+8
-1
No files found.
src/components/NiceForm/components/CardCheckBox.tsx
0 → 100644
View file @
c3b887ed
import
React
from
'react'
import
{
Row
,
Col
}
from
'antd'
;
import
styled
from
'styled-components'
import
{
findItemAndDelete
}
from
'@/utils'
import
cx
from
'classnames'
const
RowStyleLayout
=
styled
(
props
=>
<
div
{
...
props
}
/>)
`
.card-checkbox {
display: flex;
flex-wrap: wrap;
}
.card-checkbox-item {
width: 320px;
height: 48px;
margin-right: 32px;
margin-bottom: 16px;
border:1px solid rgba(235,236,240,1);
padding: 0 16px;
display: flex;
align-items: center;
cursor: pointer;
}
.card-checkbox-item.active {
border-color: #00B382;
position: relative;
}
.card-checkbox-item.active::after {
content: '';
position: absolute;
bottom: 0;
right: 0;
width: 0;
height: 0;
border: 6px solid transparent;
border-right: 6px solid #00B382;
border-bottom: 6px solid #00B382;
}
.card-logo {
display: block;
width: 32px;
height: 32px;
border-radius: 50%;
margin-right: 8px;
}
.card-logo.default {
background: #669EDE;
text-align: center;
line-height: 32px;
color: #fff;
font-size: 12px;
}
.card-checkbox-title {
font-size: 14px;
color: #42526E;
}
`
const
CardCheckBox
=
(
props
)
=>
{
const
{
dataSource
=
[]
}
=
props
.
props
[
'x-component-props'
]
const
value
:
number
[]
=
props
.
value
||
[]
const
handleChange
=
(
id
)
=>
{
if
(
value
.
includes
(
id
))
{
const
newValue
=
findItemAndDelete
(
value
,
id
)
props
.
mutators
.
change
(
newValue
)
}
else
{
props
.
mutators
.
change
([...
value
,
id
])
}
}
const
isChecked
=
(
id
)
=>
{
return
value
.
includes
(
id
)
}
return
(
<
RowStyleLayout
>
<
Row
className=
'card-checkbox'
>
{
dataSource
.
map
((
v
,
i
)
=>
{
return
(
<
Col
key=
{
v
.
id
}
className=
{
cx
(
'card-checkbox-item'
,
isChecked
(
v
.
id
)
?
'active'
:
''
)
}
onClick=
{
()
=>
handleChange
(
v
.
id
)
}
>
{
v
.
logo
?
<
img
className=
'card-logo'
src=
{
v
.
logo
}
/>
:
<
div
className=
'card-logo default'
>
logo
</
div
>
}
<
span
className=
'card-checkbox-title'
>
{
v
.
title
}
</
span
>
</
Col
>
)
})
}
</
Row
>
</
RowStyleLayout
>
)
}
CardCheckBox
.
defaultProps
=
{}
CardCheckBox
.
isFieldComponent
=
true
;
export
default
CardCheckBox
\ No newline at end of file
src/components/NiceForm/components/CustomSlider.tsx
0 → 100644
View file @
c3b887ed
import
React
from
'react'
import
{
Slider
,
Input
,
Space
}
from
'antd'
const
CustomSlider
=
(
props
)
=>
{
const
value
=
props
.
value
||
0
const
max
=
props
.
props
[
'x-component-props'
]?.
max
||
0
return
(
<
div
style=
{
{
width
:
'100%'
}
}
>
<
Slider
value=
{
value
}
onChange=
{
e
=>
props
.
mutators
.
change
(
e
)
}
{
...
props
.
props
['
x
-
component
-
props
']}
></
Slider
>
<
Space
>
<
Input
type=
'number'
disabled
max=
{
max
}
value=
{
props
.
value
}
onChange=
{
e
=>
props
.
mutators
.
change
(
e
.
target
.
value
)
}
addonAfter=
'尺'
/>
{
max
&&
<
span
>
还剩:
{
max
-
value
}
尺
</
span
>
}
</
Space
>
</
div
>
)
}
CustomSlider
.
defaultProps
=
{}
CustomSlider
.
isFieldComponent
=
true
;
export
default
CustomSlider
\ No newline at end of file
src/components/NiceForm/components/Text.tsx
0 → 100644
View file @
c3b887ed
import
React
from
'react'
const
Text
=
(
props
)
=>
{
return
(
<
span
{
...
props
.
props
['
x
-
component
-
props
']}
>
{
props
.
value
}
</
span
>
)
}
Text
.
defaultProps
=
{}
Text
.
isFieldComponent
=
true
;
export
default
Text
\ No newline at end of file
src/components/NiceForm/index.tsx
View file @
c3b887ed
...
@@ -4,8 +4,11 @@ import { Button, Space } from 'antd';
...
@@ -4,8 +4,11 @@ import { Button, Space } from 'antd';
import
CustomUpload
from
'./components/CustomUpload'
;
import
CustomUpload
from
'./components/CustomUpload'
;
import
CustomStatus
from
'./components/CustomStatus'
;
import
CustomStatus
from
'./components/CustomStatus'
;
import
CustomAddArray
from
'./components/CustomAddArray'
;
import
CustomAddArray
from
'./components/CustomAddArray'
;
import
CustomSlider
from
'./components/CustomSlider'
;
import
Search
from
'./components/Search'
;
import
Search
from
'./components/Search'
;
import
Submit
from
'./components/Submit'
;
import
Submit
from
'./components/Submit'
;
import
Text
from
'./components/Text'
;
import
CardCheckBox
from
'./components/CardCheckBox'
;
export
interface
NiceFormProps
extends
IAntdSchemaFormProps
{
export
interface
NiceFormProps
extends
IAntdSchemaFormProps
{
}
}
...
@@ -16,14 +19,18 @@ const NiceForm:React.FC<NiceFormProps> = (props) => {
...
@@ -16,14 +19,18 @@ const NiceForm:React.FC<NiceFormProps> = (props) => {
CustomUpload
,
CustomUpload
,
CustomStatus
,
CustomStatus
,
CustomAddArray
,
CustomAddArray
,
CustomSlider
,
Search
,
Search
,
Submit
Submit
,
Text
,
CardCheckBox
}
}
const
defineComponents
=
Object
.
assign
(
customComponents
,
components
)
const
defineComponents
=
Object
.
assign
(
customComponents
,
components
)
return
(
return
(
<
SchemaForm
<
SchemaForm
colon=
{
false
}
components=
{
defineComponents
}
components=
{
defineComponents
}
{
...
reset
}
{
...
reset
}
>
>
...
...
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