1 let dateTimes = [ 2 { 3 id: 1, 4 name: '本周', 5 start_time: dayjs().startOf('week').add(1, 'day').format('YYYY-MM-DD'), 6 end_time: dayjs().endOf('week').add(1, 'day').format('YYYY-MM-DD'), 7 }, 8 { 9 id: 2, 10 name: '上周', 11 start_time: dayjs().add(-1, 'week').startOf('week').add(1, 'day').format('YYYY-MM-DD'), 12 end_time: dayjs().add(-1, 'week').endOf('week').add(1, 'day').format('YYYY-MM-DD'), 13 }, 14 { 15 id: 3, 16 name: '本月', 17 start_time: dayjs().startOf('month').format('YYYY-MM-DD') , 18 end_time: dayjs().endOf('month').format('YYYY-MM-DD'), 19 }, 20 { 21 id: 4, 22 name: '上月', 23 start_time: dayjs().add(-1, 'month').startOf('month').format('YYYY-MM-DD') , 24 end_time: dayjs().add(-1, 'month').endOf('month').format('YYYY-MM-DD'), 25 }, 26 ] 27 let curMonth = dayjs().month() + 1 28 if (curMonth < 3) { 29 dateTimes.push( 30 { 31 id: 5, 32 name: '本季度', 33 start_time: dayjs().month(0).format('YYYY-MM-DD'), 34 end_time: dayjs().month(2).endOf('month').format('YYYY-MM-DD'), 35 }, 36 { 37 id: 6, 38 name: '上季度', 39 start_time: dayjs().add(-1, 'year').month(9).format('YYYY-MM-DD'), 40 end_time: dayjs().add(-1, 'year').month(11).endOf('month').format('YYYY-MM-DD'), 41 }, 42 ) 43 } else if (curMonth < 6) { 44 dateTimes.push( 45 { 46 id: 5, 47 name: '本季度', 48 start_time: dayjs().month(3).format('YYYY-MM-DD'), 49 end_time: dayjs().month(5).endOf('month').format('YYYY-MM-DD'), 50 }, 51 { 52 id: 6, 53 name: '上季度', 54 start_time: dayjs().month(0).format('YYYY-MM-DD'), 55 end_time: dayjs().month(2).endOf('month').format('YYYY-MM-DD') , 56 }, 57 ) 58 } else if (curMonth < 9) { 59 dateTimes.push( 60 { 61 id: 5, 62 name: '本季度', 63 start_time: dayjs().month(6).format('YYYY-MM-DD'), 64 end_time: dayjs().month(8).endOf('month').format('YYYY-MM-DD'), 65 }, 66 { 67 id: 6, 68 name: '上季度', 69 start_time: dayjs().month(3).format('YYYY-MM-DD'), 70 end_time: dayjs().month(5).endOf('month').format('YYYY-MM-DD'), 71 }, 72 ) 73 } else if (curMonth < 12) { 74 dateTimes.push( 75 { 76 id: 5, 77 name: '本季度', 78 start_time: dayjs().month(9).format('YYYY-MM-DD'), 79 end_time: dayjs().month(11).endOf('month').format('YYYY-MM-DD'), 80 }, 81 { 82 id: 6, 83 name: '上季度', 84 start_time: dayjs().month(6).format('YYYY-MM-DD'), 85 end_time: dayjs().month(8).endOf('month').format('YYYY-MM-DD'), 86 }, 87 ) 88 }