| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 | 
							- <?php namespace Manage\Lib;
 
- use Dever;
 
- # 配置一些常用的数据
 
- class Data
 
- {
 
-     public function getShortcuts($type)
 
-     {
 
-         if (strstr($type, 'range')) {
 
-             return [
 
-                 [
 
-                     'text' => '今天',
 
-                     'func' => 'return [new Date(new Date().setHours(0,0,0,0)), new Date()]',
 
-                 ],
 
-                 [
 
-                     'text' => '昨天',
 
-                     'func' => 'const now = new Date(); const start = new Date(now.setDate(now.getDate() - 1)); start.setHours(0,0,0,0); const end = new Date(start); end.setHours(23,59,59,999); return [start, end]',
 
-                 ],
 
-                 [
 
-                     'text' => '本周',
 
-                     'func' => 'const now = new Date(); const day = now.getDay() || 7; const start = new Date(now); start.setDate(now.getDate() - day + 1); start.setHours(0,0,0,0); return [start, new Date()]',
 
-                 ],
 
-                 [
 
-                     'text' => '上周',
 
-                     'func' => 'const now = new Date(); const day = now.getDay() || 7; const end = new Date(now); end.setDate(now.getDate() - day); end.setHours(23,59,59,999); const start = new Date(end); start.setDate(end.getDate() - 6); start.setHours(0,0,0,0); return [start, end]',
 
-                 ],
 
-                 [
 
-                     'text' => '本月',
 
-                     'func' => 'const now = new Date(); const start = new Date(now.getFullYear(), now.getMonth(), 1); return [start, new Date()]',
 
-                 ],
 
-                 [
 
-                     'text' => '上月',
 
-                     'func' => 'const now = new Date(); const start = new Date(now.getFullYear(), now.getMonth() - 1, 1); const end = new Date(now.getFullYear(), now.getMonth(), 0); end.setHours(23,59,59,999); return [start, end]',
 
-                 ],
 
-                 [
 
-                     'text' => '最近7天',
 
-                     'func' => 'const start = new Date(); start.setDate(start.getDate() - 6); start.setHours(0,0,0,0); return [start, new Date()]',
 
-                 ],
 
-                 [
 
-                     'text' => '最近30天',
 
-                     'func' => 'const start = new Date(); start.setDate(start.getDate() - 29); start.setHours(0,0,0,0); return [start, new Date()]',
 
-                 ],
 
-                 [
 
-                     'text' => '最近90天',
 
-                     'func' => 'const start = new Date(); start.setDate(start.getDate() - 89); start.setHours(0,0,0,0); return [start, new Date()]',
 
-                 ],
 
-                 [
 
-                     'text' => '最近1年',
 
-                     'func' => 'const start = new Date(); start.setFullYear(start.getFullYear() - 1); start.setDate(start.getDate() + 1); start.setHours(0,0,0,0); return [start, new Date()]',
 
-                 ],
 
-                 [
 
-                     'text' => '本年',
 
-                     'func' => 'const now = new Date(); const start = new Date(now.getFullYear(), 0, 1); return [start, new Date()]',
 
-                 ],
 
-                 [
 
-                     'text' => '去年',
 
-                     'func' => 'const now = new Date(); const start = new Date(now.getFullYear() - 1, 0, 1); const end = new Date(now.getFullYear() - 1, 11, 31, 23, 59, 59, 999); return [start, end]',
 
-                 ],
 
-             ];
 
-         } else {
 
-             return [
 
-                 // --- 过去 ---
 
-                 [
 
-                     'text' => '今天',
 
-                     'func' => 'return new Date()',
 
-                 ],
 
-                 [
 
-                     'text' => '昨天',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() - 1); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '前天',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() - 2); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '三天前',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() - 3); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '五天前',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() - 5); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '一周前',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() - 7); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '一个月前',
 
-                     'func' => 'const d = new Date(); d.setMonth(d.getMonth() - 1); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '一年前',
 
-                     'func' => 'const d = new Date(); d.setFullYear(d.getFullYear() - 1); return d',
 
-                 ],
 
-                 // --- 未来 ---
 
-                 [
 
-                     'text' => '明天',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() + 1); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '后天',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() + 2); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '三天后',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() + 3); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '五天后',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() + 5); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '一周后',
 
-                     'func' => 'const d = new Date(); d.setDate(d.getDate() + 7); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '一个月后',
 
-                     'func' => 'const d = new Date(); d.setMonth(d.getMonth() + 1); return d',
 
-                 ],
 
-                 [
 
-                     'text' => '一年后',
 
-                     'func' => 'const d = new Date(); d.setFullYear(d.getFullYear() + 1); return d',
 
-                 ],
 
-             ];
 
-         }
 
-     }
 
- }
 
 
  |