import * as dayjs from 'dayjs'

export default {
  data() {
    return {
      parmValue: this.getSearchDate()
    }
  },
  methods: {
    getStartDate() {
      const myDate = new Date()
      myDate.setDate(myDate.getDate() - 7)
      return myDate
    },
    getSearchDate() {
      return {
        start_date: dayjs(this.getStartDate()).format('YYYY-MM-DD'), // 起始时间
        end_date: dayjs(new Date()).format('YYYY-MM-DD') // 结束时间
      }
    },
    getDiffDay(date_1, date_2) {
      let totalDays, diffDate
      const myDate_1 = Date.parse(date_1)
      const myDate_2 = Date.parse(date_2)
      // eslint-disable-next-line prefer-const
      diffDate = Math.abs(myDate_1 - myDate_2)
      // eslint-disable-next-line prefer-const
      totalDays = Math.floor(diffDate / (1000 * 3600 * 24))
      return totalDays // 相差的天数
    }
  }
}
