index.js 4.52 KB
import moment from '@/common/moment'

// 全部
let allDays = {
  text: '全部',
  onClick(picker) {
    picker.$emit('pick', [])
  },
}
// 本月
let currentMonth = {
  text: '本月',
  onClick(picker) {
    const start = moment().add('month', 0).format('YYYY-MM') + '-01'
    const end = moment().format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  },
}

// 今日
let currentDay = {
  text: '今日',
  onClick(picker) {
    const end = moment().format('YYYY-MM-DD')
    picker.$emit('pick', [end, end])
  },
}

// 昨日
let yesterday = {
  text: '昨日',
  onClick(picker) {
    const start = moment()
      .day(moment().day() - 1)
      .format('YYYY-MM-DD')
    const end = moment()
      .day(moment().day() - 1)
      .format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  }
}

// 近3天
let nearly3Days = {
  text: '近3天',
  onClick(picker) {
    const end = moment().format('YYYY-MM-DD')
    const start = moment()
      .day(moment().day() - 2)
      .format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  },
}

// 近7天
let nearly7Days = {
  text: '近7天',
  onClick(picker) {
    const end = moment().format('YYYY-MM-DD')
    const start = moment()
      .day(moment().day() - 6)
      .format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  }
}

// 近15天
let nearly15Days = {
  text: '近15天',
  onClick(picker) {
    const end = moment().format('YYYY-MM-DD')
    const start = moment()
      .day(moment().day() - 14)
      .format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  }
}

// 近30天
let nearly30Days = {
  text: '近30天',
  onClick(picker) {
    const end = moment().format('YYYY-MM-DD')
    const start = moment()
      .day(moment().day() - 29)
      .format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  }
}

// 上月
let lastMonth = {
  text: '上月',
  onClick(picker) {
    const end = moment()
      .month(moment().month() - 1)
      .endOf('month')
      .format('YYYY-MM-DD')
    const start = moment()
      .month(moment().month() - 1)
      .startOf('month')
      .format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  },
}

// 上周
let lastWeek = {
  text: '上周',
  onClick(picker) {
    let weekOfDay = parseInt(moment().format('E'))
    const end = moment().subtract(weekOfDay, 'days').format('YYYY-MM-DD')
    const start = moment()
      .subtract(weekOfDay + 7 - 1, 'days')
      .format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  },
}

// 本周
let currentWeek = {
  text: '本周',
  onClick(picker) {
    const end = moment().format('YYYY-MM-DD')
    const start = moment().weekday(0).format('YYYY-MM-DD')
    picker.$emit('pick', [start, end])
  },
}

// 最近一天不在线
let latelyOneDay = {
  text: "近1天不在线",
  onClick(picker) {
    const start = moment()
      .day(moment().day() - 1)
      .format("YYYY-MM-DD HH:mm:ss");
    picker.$emit("pick", start);
  },
}

// 最近三天不在线
let latelyThreeDay = {
  text: "近3天不在线",
  onClick(picker) {
    const start = moment()
      .day(moment().day() - 3)
      .format("YYYY-MM-DD HH:mm:ss");
    picker.$emit("pick", start);
  },
}

// 最近7天不在线
let latelySevenDay = {
  text: "近7天不在线",
  onClick(picker) {
    const start = moment()
      .day(moment().day() - 7)
      .format("YYYY-MM-DD HH:mm:ss");
    picker.$emit("pick", start);
  },
}

// 警情中心-围栏报警
export const fenceShortcuts = [
  allDays,
  currentDay,
  yesterday,
  nearly7Days,
  nearly15Days,
  nearly30Days
]

// 警情中心-停驶报警
export const shutDownShortcuts = [
  allDays,
  nearly3Days,
  nearly7Days,
  currentMonth,
]

// 里程统计详情
export const mileageDetailShortcuts = [
  allDays,
  yesterday,
  currentWeek,
  lastWeek,
  currentMonth,
  lastMonth
]

// 设备激活时间
export const deviceActivedShortcuts = [
  allDays,
  currentDay,
  nearly7Days,
  currentMonth,
  lastMonth,
  nearly30Days
]

// 超速报警
export const speedShortcuts = [
  allDays,
  yesterday,
  lastWeek,
  currentMonth,
  lastMonth,
]

// 运营统计报表-车辆维度
export const staticReportCarShortcuts = [
  allDays,
  yesterday,
  currentWeek,
  lastWeek,
  currentMonth,
  lastMonth
]

// 离线报警-离线时间
export const offlineShortcuts = [
  latelyOneDay,
  latelyThreeDay,
  latelySevenDay
]

// 离线报警-激活时间
export const offlineActiveShortcuts = [
  allDays,
  nearly3Days,
  nearly7Days,
  currentMonth
]

//通用防拆报警-报警时间
export const tamperAlarmShortcuts = [
  currentDay,
  yesterday,
  nearly7Days,
  currentWeek,
  currentMonth
]