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
1109e1c7
Commit
1109e1c7
authored
Dec 04, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:
parent
a77f5329
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
96 deletions
+96
-96
package.json
package.json
+1
-1
NumberRange.tsx
src/components/NiceForm/components/NumberRange.tsx
+95
-95
No files found.
package.json
View file @
1109e1c7
...
...
@@ -86,7 +86,7 @@
"
chalk
"
:
"^4.1.0"
,
"
clone
"
:
"^2.1.2"
,
"
connect-history-api-fallback
"
:
"^1.6.0"
,
"
cross-env
"
:
"^7.0.
2
"
,
"
cross-env
"
:
"^7.0.
3
"
,
"
events
"
:
"^3.2.0"
,
"
express
"
:
"^4.17.1"
,
"
fs-extra
"
:
"^9.0.1"
,
...
...
src/components/NiceForm/components/NumberRange.tsx
View file @
1109e1c7
import
React
,
{
useRef
,
useEffect
,
useState
}
from
'react'
import
{
Input
}
from
'antd'
;
import
styled
from
'styled-components'
/**
* 自定义数值范围控件
*/
const
RowStyleLayout
=
styled
(
props
=>
<
div
{
...
props
}
/>)
`
.site-input-split {
background-color: #fff;
}
.site-input-right {
border-left-width: 0;
}
.site-input-right:hover,
.site-input-right:focus {
border-left-width: 1px;
}
.ant-input-rtl.site-input-right {
border-right-width: 0;
}
.ant-input-rtl.site-input-right:hover,
.ant-input-rtl.site-input-right:focus {
border-right-width: 1px;
}
`
const
NumberRange
=
(
props
)
=>
{
const
{
value
,
mutators
}
=
props
const
{
placeholder
=
[],
...
rest
}
=
props
.
props
[
"x-component-props"
]
||
{}
const
[
rangeValue
,
setrangeValue
]
=
useState
([])
useEffect
(()
=>
{
if
(
rangeValue
.
length
)
{
mutators
.
change
(
rangeValue
);
}
},
[
rangeValue
])
const
loseBlur
=
(
e
,
index
)
=>
{
setrangeValue
(()
=>
{
let
newValue
=
[...
rangeValue
]
newValue
[
index
]
=
e
.
target
.
value
return
newValue
})
}
return
(
<
RowStyleLayout
>
<
Input
.
Group
compact
{
...
rest
}
>
<
Input
style=
{
{
width
:
100
,
textAlign
:
'center'
}
}
placeholder=
{
placeholder
[
0
]
||
'最小值'
}
onBlur=
{
(
e
)
=>
loseBlur
(
e
,
0
)
}
/>
<
Input
className=
"site-input-split"
style=
{
{
width
:
30
,
borderLeft
:
0
,
borderRight
:
0
,
pointerEvents
:
'none'
,
}
}
placeholder=
"~"
disabled
/>
<
Input
className=
"site-input-right"
style=
{
{
width
:
100
,
textAlign
:
'center'
,
}
}
placeholder=
{
placeholder
[
1
]
||
'最大值'
}
onBlur=
{
(
e
)
=>
loseBlur
(
e
,
1
)
}
/>
</
Input
.
Group
>
</
RowStyleLayout
>
)
}
NumberRange
.
defaultProps
=
{}
NumberRange
.
isFieldComponent
=
true
;
export
default
NumberRange
\ No newline at end of file
import
React
,
{
useRef
,
useEffect
,
useState
}
from
'react'
import
{
Input
}
from
'antd'
;
import
styled
from
'styled-components'
/**
* 自定义数值范围控件
*/
const
RowStyleLayout
=
styled
(
props
=>
<
div
{
...
props
}
/>)
`
.site-input-split {
background-color: #fff;
}
.site-input-right {
border-left-width: 0;
}
.site-input-right:hover,
.site-input-right:focus {
border-left-width: 1px;
}
.ant-input-rtl.site-input-right {
border-right-width: 0;
}
.ant-input-rtl.site-input-right:hover,
.ant-input-rtl.site-input-right:focus {
border-right-width: 1px;
}
`
const
NumberRange
=
(
props
)
=>
{
const
{
value
,
mutators
}
=
props
const
{
placeholder
=
[],
...
rest
}
=
props
.
props
[
"x-component-props"
]
||
{}
const
[
rangeValue
,
setrangeValue
]
=
useState
([])
useEffect
(()
=>
{
if
(
rangeValue
.
length
)
{
mutators
.
change
(
rangeValue
);
}
},
[
rangeValue
])
const
loseBlur
=
(
e
,
index
)
=>
{
setrangeValue
(()
=>
{
let
newValue
=
[...
rangeValue
]
newValue
[
index
]
=
e
.
target
.
value
return
newValue
})
}
return
(
<
RowStyleLayout
>
<
Input
.
Group
compact
{
...
rest
}
>
<
Input
style=
{
{
width
:
100
,
textAlign
:
'center'
}
}
placeholder=
{
placeholder
[
0
]
||
'最小值'
}
onBlur=
{
(
e
)
=>
loseBlur
(
e
,
0
)
}
/>
<
Input
className=
"site-input-split"
style=
{
{
width
:
30
,
borderLeft
:
0
,
borderRight
:
0
,
pointerEvents
:
'none'
,
background
:
'#fff'
,
}
}
placeholder=
"~"
disabled
/>
<
Input
className=
"site-input-right"
style=
{
{
width
:
100
,
textAlign
:
'center'
,
}
}
placeholder=
{
placeholder
[
1
]
||
'最大值'
}
onBlur=
{
(
e
)
=>
loseBlur
(
e
,
1
)
}
/>
</
Input
.
Group
>
</
RowStyleLayout
>
)
}
NumberRange
.
defaultProps
=
{}
NumberRange
.
isFieldComponent
=
true
;
export
default
NumberRange
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