Forráskód Böngészése

修改日期快捷

zero 1 hónapja
szülő
commit
00b183559a

+ 21 - 8
src/views/news/components/dialog/oneClickExportReport.vue

@@ -73,19 +73,32 @@ const shortcuts = [
   {
     text: '上周',
     value: () => {
-      const end = new Date()
-      const start = new Date()
-      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
-      return [start, end]
+      const end = new Date();
+      // 设置为上周日(结束日期)
+      end.setDate(end.getDate() - end.getDay()); // 本周日
+      end.setHours(23, 59, 59, 999); // 设置为当天最后一刻
+      
+      const start = new Date(end);  
+      start.setDate(start.getDate() - 6); // 上周一
+      start.setHours(0, 0, 0, 0); // 设置为当天最开始
+      
+      return [start, end];
     },
   },
   {
     text: '上个月',
     value: () => {
-      const end = new Date()
-      const start = new Date()
-      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
-      return [start, end]
+      const end = new Date();
+      // 设置为上个月最后一天
+      end.setDate(0); // 当前月第0天 = 上个月最后一天
+      end.setHours(23, 59, 59, 999);
+      
+      const start = new Date(end);
+      start.setMonth(start.getMonth() - 1); // 上个月
+      start.setDate(1); // 上个月第1天
+      start.setHours(0, 0, 0, 0);
+      
+      return [start, end];
     },
   },
 ]