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
f38eec07
Commit
f38eec07
authored
Sep 04, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增下拉选择时间组件
parent
8e1aba35
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
DateSelect.tsx
src/components/NiceForm/components/DateSelect.tsx
+53
-0
index.tsx
src/components/NiceForm/index.tsx
+2
-0
No files found.
src/components/NiceForm/components/DateSelect.tsx
0 → 100644
View file @
f38eec07
import
React
,
{
useRef
,
useEffect
,
useMemo
}
from
'react'
import
{
Select
}
from
'antd'
;
import
moment
from
'moment'
export
enum
DATE_SELECT_TYPE
{
TODAY
,
WITHIN_WEEK
,
WITHIN_MONTH
,
WITHIN_THREE_MONTH
,
WITHIN_SIX_MONTH
,
WITHIN_YEAR
,
A_YEAR_AGO
}
const
getPrevTime
=
(
num
,
flag
)
=>
{
return
moment
().
subtract
(
num
,
flag
).
valueOf
()
}
const
DateSelect
=
(
props
)
=>
{
const
{
value
=
[],
mutators
}
=
props
const
todayStartTime
=
moment
().
startOf
(
'day'
).
format
(
'x'
)
const
nowTime
=
moment
().
format
(
'x'
).
valueOf
()
const
dateMemo
=
useMemo
(()
=>
[
{
label
:
'今天'
,
value
:
`
${
todayStartTime
}
,
${
nowTime
}
`
},
{
label
:
'一周内'
,
value
:
`
${
getPrevTime
(
1
,
'week'
)}
,
${
nowTime
}
`
},
{
label
:
'一月内'
,
value
:
`
${
getPrevTime
(
1
,
'month'
)}
,
${
nowTime
}
`
},
{
label
:
'三月内'
,
value
:
`
${
getPrevTime
(
3
,
'month'
)}
,
${
nowTime
}
`
},
{
label
:
'六月内'
,
value
:
`
${
getPrevTime
(
6
,
'month'
)}
,
${
nowTime
}
`
},
{
label
:
'一年内'
,
value
:
`
${
getPrevTime
(
1
,
'year'
)}
,
${
nowTime
}
`
},
{
label
:
'一年前'
,
value
:
`0,
${
getPrevTime
(
1
,
'year'
)}
`
},
],
[])
const
handleChange
=
(
e
)
=>
{
mutators
.
change
(
e
.
split
(
','
))
}
const
{
placeholder
,
dataSource
=
dateMemo
}
=
props
.
props
[
"x-component-props"
]
||
{}
return
(
<
Select
style=
{
{
minWidth
:
160
}
}
placeholder=
{
placeholder
}
onChange=
{
handleChange
}
value=
{
value
.
join
()
}
options=
{
dataSource
}
/>
)
}
DateSelect
.
defaultProps
=
{}
DateSelect
.
isFieldComponent
=
true
;
export
default
DateSelect
\ No newline at end of file
src/components/NiceForm/index.tsx
View file @
f38eec07
...
...
@@ -23,6 +23,7 @@ import SearchSelect from './components/SearchSelect';
import
TableTagList
from
'./components/TableTagList'
;
import
'./index.less'
import
{
Checkbox
}
from
'@formily/antd-components'
;
import
DateSelect
from
'./components/DateSelect'
;
export
interface
NiceFormProps
extends
IAntdSchemaFormProps
{}
...
...
@@ -88,6 +89,7 @@ export const componentExport = {
SearchSelect
,
DateRangePicker
:
DatePicker
.
RangePicker
,
TableTagList
,
DateSelect
}
const
NiceForm
:
React
.
FC
<
NiceFormProps
>
=
props
=>
{
const
{
children
,
components
,
...
reset
}
=
props
;
...
...
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