import { dateformat } from '@/utils/formatTime';
const curMonth = new Date().getMonth() + 1;
const halfBefore = new Date().setMonth(curMonth - (6 + 1));
const datePrickerBegin = new Date(halfBefore).setHours(24);
export default {
  data() {
    return {
      // 四个时间选择器的初始值
      time: [new Date(datePrickerBegin), new Date()],
      // 四个页面选择器的禁用规则
        pickerOptions: {
          disabledDate: val => {
            // 只能筛选半年之内得数据,并且最大跨度为六个月
            const timeArea = new Date().setMonth(curMonth - (6 + 1));
            if (this.minDate) {
              const curTime = this.minDate.getTime();
              const min = curTime - timeArea > halfBefore ? curTime - timeArea : halfBefore;
              return val.getTime() > curTime + timeArea || val.getTime() < min || val.getTime() > this.maxDate;
            }
            return val.getTime() <= halfBefore || val.getTime() > this.maxDate.getTime();
          },
          onPick: ({ maxDate, minDate }) => {
            this.minDate = minDate;
          }
        },
        minDate: null,
        maxDate: new Date(),
        dateformat: dateformat
    }
  }
}
