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
2bfa621e
Commit
2bfa621e
authored
Jul 29, 2020
by
tjy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽取公共方法 获取时间范围
parent
c66dbba8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
86 deletions
+60
-86
index.tsx
src/pages/member/memberMaintain/index.tsx
+12
-83
index.ts
src/services/index.ts
+0
-0
index.ts
src/utils/index.ts
+48
-3
No files found.
src/pages/member/memberMaintain/index.tsx
View file @
2bfa621e
...
...
@@ -36,7 +36,7 @@ import moment from 'moment';
import
{
PublicApi
}
from
'@/services/api'
;
import
style
from
'./index.less'
;
import
UploadModal
from
'@/components/UploadModal'
;
import
timeRange
from
'@/utils/index'
;
import
{
timeRange
}
from
'@/utils/index'
;
const
{
Option
}
=
Select
;
...
...
@@ -284,94 +284,23 @@ const memberMaintain: React.FC<[]> = () => {
status
:
filter
.
memberStatus
||
0
,
outerStatus
:
filter
.
outerStatus
||
0
,
innerStatus
:
filter
.
innerStatus
||
0
,
current
:
params
.
current
,
pageSize
:
params
.
pageSize
,
};
console
.
log
(
obj
);
setSearchForm
(
obj
);
};
useEffect
(()
=>
{
return
console
.
log
(
timeRange
());
if
(
!
isFirst
)
return
;
let
st
=
''
,
et
=
''
,
execute
=
false
;
switch
(
searchForm
.
timeRange
)
{
case
0
:
execute
=
false
;
setIsFirst
(
false
);
setSearchForm
({
...
searchForm
,
startDate
:
''
,
endDate
:
''
});
break
;
case
1
:
execute
=
true
;
st
=
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
;
case
2
:
execute
=
true
;
st
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
et
=
moment
()
.
subtract
(
6
,
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
;
case
3
:
execute
=
true
;
st
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
et
=
moment
()
.
startOf
(
'month'
)
.
format
(
'YYYY-MM-DD'
);
break
;
case
4
:
execute
=
true
;
st
=
moment
()
.
subtract
(
2
,
'month'
)
.
format
(
'YYYY-MM'
)
+
'-01'
;
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
;
case
5
:
execute
=
true
;
st
=
moment
()
.
subtract
(
5
,
'month'
)
.
format
(
'YYYY-MM'
)
+
'-01'
;
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
;
case
6
:
execute
=
true
;
st
=
moment
()
.
startOf
(
'years'
)
.
format
(
'YYYY-MM-DD'
);
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
;
case
7
:
execute
=
true
;
st
=
moment
()
.
years
(
moment
().
years
()
-
1
)
.
startOf
(
'years'
)
.
format
(
'YYYY-MM-DD'
);
et
=
moment
()
.
years
(
moment
().
years
()
-
1
)
.
endOf
(
'years'
)
.
format
(
'YYYY-MM-DD'
);
break
;
}
if
(
execute
)
{
let
timeRanges
=
timeRange
(
searchForm
.
timeRange
);
if
(
searchForm
.
timeRange
==
0
)
{
setIsFirst
(
false
);
}
else
{
setIsFirst
(
false
);
setSearchForm
({
...
searchForm
,
startDate
:
st
,
endDate
:
et
});
}
setSearchForm
({
...
searchForm
,
startDate
:
timeRanges
.
st
,
endDate
:
timeRanges
.
et
,
});
},
[
searchForm
.
timeRange
]);
useEffect
(()
=>
{
...
...
@@ -441,8 +370,8 @@ const memberMaintain: React.FC<[]> = () => {
<
StandardTable
tableProps=
{
{
rowKey
:
'memberId'
,
//
onChange: (pagination: any, filter: any) =>
//
handleSearch(pagination, filter),
onChange
:
(
pagination
:
any
,
filter
:
any
)
=>
handleSearch
(
pagination
,
filter
),
}
}
columns=
{
columns
}
currentRef=
{
ref
}
...
...
src/services/index.ts
View file @
2bfa621e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/utils/index.ts
View file @
2bfa621e
import
moment
from
'moment'
;
function
isArray
(
arr
:
any
)
{
return
Array
.
isArray
(
arr
)
...
...
@@ -7,24 +8,68 @@ function isObject(obj: any) {
return
Object
.
prototype
.
toString
.
call
(
obj
)
===
'[object Object]'
}
function
timeRange
(
val
:
number
)
{
export
function
timeRange
(
val
:
number
)
{
let
st
=
''
,
et
=
''
;
switch
(
val
)
{
case
0
:
st
=
et
=
''
break
case
1
:
st
=
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
case
2
:
st
=
moment
()
.
subtract
(
6
,
'days'
)
.
format
(
'YYYY-MM-DD'
);
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
case
3
:
st
=
moment
()
.
startOf
(
'month'
)
.
format
(
'YYYY-MM-DD'
);
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
case
4
:
st
=
moment
()
.
subtract
(
2
,
'month'
)
.
format
(
'YYYY-MM'
)
+
'-01'
;
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
case
5
:
st
=
moment
()
.
subtract
(
5
,
'month'
)
.
format
(
'YYYY-MM'
)
+
'-01'
;
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
case
6
:
st
=
moment
()
.
startOf
(
'year'
)
.
format
(
'YYYY-MM-DD'
);
et
=
moment
()
.
startOf
(
'days'
)
.
format
(
'YYYY-MM-DD'
);
break
case
7
:
st
=
moment
()
.
years
(
moment
().
years
()
-
1
)
.
startOf
(
'year'
)
.
format
(
'YYYY-MM-DD'
);
et
=
moment
()
.
years
(
moment
().
years
()
-
1
)
.
endOf
(
'year'
)
.
format
(
'YYYY-MM-DD'
);
break
}
return
{
st
,
et
}
...
...
@@ -41,6 +86,5 @@ export function omit(obj: any, arr: string[]) {
export
default
{
isArray
,
isObject
,
omit
,
timeRange
omit
}
\ No newline at end of file
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