Commit ba465d50 authored by tjy's avatar tjy

调整timeRange方法,输出时间戳

parent 2bfa621e
This diff is collapsed.
...@@ -291,11 +291,7 @@ const memberMaintain: React.FC<[]> = () => { ...@@ -291,11 +291,7 @@ const memberMaintain: React.FC<[]> = () => {
useEffect(() => { useEffect(() => {
if (!isFirst) return; if (!isFirst) return;
let timeRanges = timeRange(searchForm.timeRange); let timeRanges = timeRange(searchForm.timeRange);
if (searchForm.timeRange == 0) {
setIsFirst(false); setIsFirst(false);
} else {
setIsFirst(false);
}
setSearchForm({ setSearchForm({
...searchForm, ...searchForm,
startDate: timeRanges.st, startDate: timeRanges.st,
......
...@@ -9,68 +9,97 @@ function isObject(obj: any) { ...@@ -9,68 +9,97 @@ function isObject(obj: any) {
} }
export function timeRange(val: number) { export function timeRange(val: number) {
let st = '', et = ''; let st, et;
switch (val) { switch (val) {
case 0: case 0:
st = et = '' st = et = '';
break break;
case 1: case 1:
st = et = moment() st = moment(
moment()
.startOf('days') .startOf('days')
.format('YYYY-MM-DD'); .format('YYYY-MM-DD HH:mm:ss'),
break ).unix();
et = moment(
moment()
.endOf('days')
.format('YYYY-MM-DD HH:mm:ss'),
).unix();
break;
case 2: case 2:
st = moment() st = moment(
.subtract(6, 'days') moment()
.format('YYYY-MM-DD'); .subtract(7, 'days')
et = moment() .format('YYYY-MM-DD') + ' 00:00:00',
.startOf('days') ).unix();
.format('YYYY-MM-DD'); et = moment(
break moment()
.endOf('days')
.format('YYYY-MM-DD HH:mm:ss'),
).unix();
break;
case 3: case 3:
st = moment() st = moment(
.startOf('month') moment()
.format('YYYY-MM-DD'); .subtract(29, 'days')
et = moment() .format('YYYY-MM-DD') + ' 00:00:00',
.startOf('days') ).unix();
.format('YYYY-MM-DD'); et = moment(
break moment()
.endOf('days')
.format('YYYY-MM-DD HH:mm:ss'),
).unix();
break;
case 4: case 4:
st = st = moment(
moment() moment()
.subtract(2, 'month') .subtract(89, 'days')
.format('YYYY-MM') + '-01'; .format('YYYY-MM-DD') + ' 00:00:00',
et = moment() ).unix();
.startOf('days') et = moment(
.format('YYYY-MM-DD'); moment()
break .endOf('days')
.format('YYYY-MM-DD HH:mm:ss'),
).unix();
break;
case 5: case 5:
st = st = moment(
moment() moment()
.subtract(5, 'month') .subtract(179, 'days')
.format('YYYY-MM') + '-01'; .format('YYYY-MM-DD') + ' 00:00:00',
et = moment() ).unix();
.startOf('days') et = moment(
.format('YYYY-MM-DD'); moment()
break .endOf('days')
.format('YYYY-MM-DD HH:mm:ss'),
).unix();
break;
case 6: case 6:
st = moment() st = moment(
.startOf('year') moment()
.format('YYYY-MM-DD'); .subtract(364, 'days')
et = moment() .format('YYYY-MM-DD') + ' 00:00:00',
.startOf('days') ).unix();
.format('YYYY-MM-DD'); et = moment(
break moment()
.endOf('days')
.format('YYYY-MM-DD HH:mm:ss'),
).unix();
break;
case 7: case 7:
st = moment() st = moment(
.years(moment().years() - 1) moment()
.year(moment().year() - 1)
.startOf('year') .startOf('year')
.format('YYYY-MM-DD'); .format('YYYY-MM-DD HH:mm:ss'),
et = moment() ).unix();
.years(moment().years() - 1) et = moment(
moment()
.year(moment().year() - 1)
.endOf('year') .endOf('year')
.format('YYYY-MM-DD'); .format('YYYY-MM-DD HH:mm:ss'),
break ).unix();
break;
} }
return { st, et } return { st, et }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment