Rap 原分销系统代码Web
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

77 wiersze
2.3KB

  1. import Date from './datetime.js'
  2. export const calendarBaseShortcuts = [{
  3. text: '今天',
  4. onClick(picker) {
  5. const startTime = new Date(new Date().setHours(0, 0, 0))
  6. const endTime = new Date(new Date().setHours(23, 59, 59))
  7. picker.$emit('pick', [startTime, endTime])
  8. }
  9. }, {
  10. text: '昨天',
  11. onClick(picker) {
  12. const startTime = new Date(new Date().daysAgo(1).setHours(0, 0, 0))
  13. const endTime = new Date(new Date().daysAgo(1).setHours(23, 59, 59))
  14. picker.$emit('pick', [startTime, endTime])
  15. }
  16. }, {
  17. text: '本周',
  18. onClick(picker) {
  19. const startTime = new Date(new Date().daysAgo(new Date().getDay() - 1).setHours(0, 0, 0))
  20. const endTime = new Date(new Date().setHours(23, 59, 59))
  21. picker.$emit('pick', [startTime, endTime])
  22. }
  23. }, {
  24. text: '这个月',
  25. onClick(picker) {
  26. const startTime = new Date(new Date().monthBegin().setHours(0, 0, 0))
  27. const endTime = new Date(new Date().setHours(23, 59, 59))
  28. picker.$emit('pick', [startTime, endTime])
  29. }
  30. }, {
  31. text: '当前季度',
  32. onClick(picker) {
  33. const startTime = new Date(new Date().quarterBegin().setHours(0, 0, 0))
  34. const endTime = new Date(new Date().setHours(23, 59, 59))
  35. picker.$emit('pick', [startTime, endTime])
  36. }
  37. }, {
  38. text: '最近30天',
  39. onClick(picker) {
  40. const startTime = new Date(new Date().daysAgo(30).setHours(0, 0, 0))
  41. const endTime = new Date(new Date().setHours(23, 59, 59))
  42. picker.$emit('pick', [startTime, endTime])
  43. }
  44. }]
  45. export const calendarMoveShortcuts = [{
  46. text: '‹ 往前一天 ',
  47. onClick(picker) {
  48. let startTime = new Date(new Date().setHours(0, 0, 0))
  49. let endTime = new Date(new Date().setHours(23, 59, 59))
  50. if (!picker.value) {
  51. picker.value = [startTime, endTime]
  52. }
  53. startTime = picker.value[0].daysAgo(1)
  54. endTime = picker.value[1].daysAgo(1)
  55. picker.$emit('pick', [startTime, endTime])
  56. }
  57. }, {
  58. text: ' 往后一天 ›',
  59. onClick(picker) {
  60. let startTime = new Date(new Date().setHours(0, 0, 0))
  61. let endTime = new Date(new Date().setHours(23, 59, 59))
  62. if (!picker.value) {
  63. picker.value = [startTime, endTime]
  64. }
  65. startTime = picker.value[0].daysAgo(-1)
  66. endTime = picker.value[1].daysAgo(-1)
  67. picker.$emit('pick', [startTime, endTime])
  68. }
  69. }]
  70. export const calendarShortcuts = [
  71. ...calendarBaseShortcuts,
  72. ...calendarMoveShortcuts
  73. ]