// 视图
import { getLastDate, getLastDateTimeEnd, getLastDateTimeStart, getLastMonth, getLastMonthTimeEnd } from '@/utils/index'

export const views = {
}

// 日期选择器快捷选项
export const DatePickerOptions = {
  // 默认
  DEFAULT: {
    shortcuts: [{
      text: '最近一周',
      onClick(picker) {
        const end = getLastDate(0);
        const start = getLastDate(6);
        picker.$emit('pick', [start, end]);
      }
    }, {
      text: '最近一个月',
      onClick(picker) {
        const end = getLastDate(0);
        const start = getLastMonth(1);
        picker.$emit('pick', [start, end]);
      }
    }, {
      text: '最近三个月',
      onClick(picker) {
        const end = getLastDate(0);
        const start = getLastMonth(3);
        picker.$emit('pick', [start, end]);
      }
    }]
  },
  // 未来
  FUTURE: {
    shortcuts: [{
      text: '明天',
      onClick(picker) {
        const end = getLastDateTimeEnd(-1);
        const start = getLastDateTimeStart(-1);
        picker.$emit('pick', [start, end]);
      }
    },{
      text: '未来一周',
      onClick(picker) {
        const end = getLastDateTimeEnd(-6);
        const start = getLastDateTimeStart(0);
        picker.$emit('pick', [start, end]);
      }
    }, {
      text: '未来一个月',
      onClick(picker) {
        const end = getLastMonthTimeEnd(-1);
        const start = getLastDateTimeStart(0);
        picker.$emit('pick', [start, end]);
      }
    }, {
      text: '未来三个月',
      onClick(picker) {
        const end = getLastMonthTimeEnd(-3);
        const start = getLastDateTimeStart(0);
        picker.$emit('pick', [start, end]);
      }
    }]
  },
  // 禁用未来
  DISABLE_FUTURE: {
    disabledDate(date) {
      return date.getTime() > Date.now();
    }
  }
}
