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
60f0b1ec
Commit
60f0b1ec
authored
Dec 20, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加限制时分秒
parent
25226f9f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
index.tsx
src/components/RangeTime/index.tsx
+30
-0
No files found.
src/components/RangeTime/index.tsx
View file @
60f0b1ec
...
...
@@ -5,6 +5,16 @@ import moment, { Moment } from 'moment';
import
styles
from
'./index.less'
;
import
{
getIntl
}
from
'umi'
;
const
intl
=
getIntl
();
function
range
(
start
,
end
)
{
const
result
=
[];
for
(
let
i
=
start
;
i
<
end
;
i
++
)
{
result
.
push
(
i
);
}
return
result
;
}
interface
Iprops
{
containerStyle
?:
CSSProperties
,
/**
...
...
@@ -74,6 +84,24 @@ const RangeTime: React.FC<Iprops> = (props: Iprops) => {
}
},
[
innerRangeTime
]);
const
disabledDateTime
=
(
current
:
Moment
,
partial
:
'start'
|
'end'
)
=>
{
const
{
startTime
}
=
innerRangeTime
;
if
(
partial
===
'start'
)
{
return
{
disabledHours
:
()
=>
range
(
0
,
24
).
splice
(
0
,
moment
().
get
(
'hour'
)),
disabledMinutes
:
()
=>
range
(
0
,
60
).
splice
(
0
,
moment
().
get
(
'minute'
)),
disabledSeconds
:
()
=>
range
(
0
,
60
).
splice
(
0
,
moment
().
get
(
'second'
)),
};
}
if
(
partial
===
'end'
)
{
return
{
disabledHours
:
()
=>
range
(
0
,
24
).
splice
(
0
,
startTime
.
get
(
'hour'
)),
disabledMinutes
:
()
=>
range
(
0
,
60
).
splice
(
0
,
current
&&
current
.
isSame
(
startTime
,
'hour'
)
?
startTime
.
get
(
'minute'
)
:
0
),
disabledSeconds
:
()
=>
range
(
0
,
60
).
splice
(
0
,
current
&&
current
.
isSame
(
startTime
,
'hour'
)
&&
current
.
isSame
(
startTime
,
'minute'
)
?
startTime
.
get
(
'second'
)
+
1
:
0
),
};
}
return
{};
};
return
(
<
div
className=
{
cx
(
styles
.
container
,
containerStyle
)
}
>
...
...
@@ -83,6 +111,7 @@ const RangeTime: React.FC<Iprops> = (props: Iprops) => {
value=
{
innerRangeTime
.
startTime
}
onChange=
{
(
date
:
Moment
|
null
,
dateString
:
string
)
=>
handleChange
(
date
,
dateString
,
"startTime"
)
}
disabledDate=
{
(
current
)
=>
getDisableDate
(
current
,
'startTime'
)
}
disabledTime=
{
(
current
)
=>
disabledDateTime
(
current
,
'start'
)
}
placeholder=
{
placeholader
!
[
0
]
}
disabled=
{
disabled
}
showTime=
{
showTime
}
...
...
@@ -95,6 +124,7 @@ const RangeTime: React.FC<Iprops> = (props: Iprops) => {
value=
{
innerRangeTime
.
endTime
}
onChange=
{
(
date
:
Moment
|
null
,
dateString
:
string
)
=>
handleChange
(
date
,
dateString
,
"endTime"
)
}
disabledDate=
{
(
current
)
=>
getDisableDate
(
current
,
'endTime'
)
}
disabledTime=
{
(
current
)
=>
disabledDateTime
(
current
,
'end'
)
}
placeholder=
{
placeholader
!
[
1
]
}
disabled=
{
disabled
}
showTime=
{
showTime
}
...
...
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