| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 | import moment from 'moment'import { getFormatDatetime } from "@/utils/date";export const shortcuts = [    {        text: '今天',        value: (() => {            let start = new Date()            return [getFormatDatetime(start, 'YYYY-MM-DD'), getFormatDatetime(start, 'YYYY-MM-DD')]        })(),    },    {        text: '最近一周',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)            return [start, end]        })(),    },    {        text: '最近一个月',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)            return [start, end]        })(),    },    {        text: '最近三个月',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)            return [start, end]        })(),    },]export const clockinShortcuts = [    {        text: '上一个月',        value: (() => {            const start = moment(moment().month(moment().month() - 1).startOf('month').valueOf()).format('YYYY-MM-DD');            const end = moment(moment().month(moment().month() - 1).endOf('month').valueOf()).format('YYYY-MM-DD');            return [start, end]        })(),    },    {        text: '本月',        value: (() => {            const start = moment(moment().month(moment().month()).startOf('month').valueOf()).format('YYYY-MM-DD')            const end = new Date()            return [start, end]        })(),    },]export const healthCardShortcuts = [    {        text: '最近三天',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 3)            return [start, end]        })(),    },    {        text: '最近一周',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)            return [start, end]        })(),    },    {        text: '最近一个月',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)            return [start, end]        })(),    },]export const maxHalfYear = [    {        text: '最近一个月',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)            return [start, end]        })(),    },    {        text: '最近三个月',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)            return [start, end]        })(),    },    {        text: '最近半年',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 180)            return [start, end]        })(),    },]export const setlShtcuts = [    {        text: '最近一周',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)            return [start, end]        })(),    },    {        text: '最近半个月',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 15)            return [start, end]        })(),    },    {        text: '最近一个月',        value: (() => {            const end = new Date()            const start = new Date()            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)            return [start, end]        })(),    },]export const seltYearAndNowLast = [    {        text: '第一个月',        value: (() => {            const now = new Date()            const start = now.getFullYear() + "-01-01";            const end = now.getFullYear() + "-01-31";            return [start, end]        })(),    },    {        text: '上一个月',        value: (() => {            const nowDate = new Date()            const month = nowDate.getMonth()            // 如果是现在1月份,就取现在1月份的时间,否则取上一个月的时间            if (month === 1) {                const start = nowDate.getFullYear() + "-01-01";                const end = nowDate.getFullYear() + "-01-31";                return [start, end]            } else {                const start = moment(moment().month(moment().month() - 1).startOf('month').valueOf()).format('YYYY-MM-DD');                const end = moment(moment().month(moment().month() - 1).endOf('month').valueOf()).format('YYYY-MM-DD');                return [start, end]            }        })(),    },]
 |