Преглед изворни кода

fix(attendance): 调整周数组合,确保周一为一周起始,修正日期计算逻辑

xieyong пре 4 дана
родитељ
комит
ee00ed2f8e
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      src/pages/attendance/index.vue

+ 5 - 2
src/pages/attendance/index.vue

@@ -128,7 +128,7 @@ import { extractTime } from "@/utils/format";
 useAuthGuard();
 
 const currentUser = useCurrentUser();
-const weeks = ["日", "一", "二", "三", "四", "五", "六"];
+const weeks = ["一", "二", "三", "四", "五", "六", "日"];
 
 const currentMonth = ref(formatMonth(new Date()));
 const monthList = ref([]); // ESS 月度返回数组
@@ -173,7 +173,10 @@ const summary = computed(() => {
 
 const grid = computed(() => {
   const [y, m] = currentMonth.value.split("-").map(Number);
-  const firstDay = new Date(y, m - 1, 1).getDay();
+  // 周一作为一周的起始:JS getDay() 周日=0、周一=1...周六=6,
+  // 转成周一=0、周日=6 的偏移,便于和上面 weeks 数组对位
+  const jsDay = new Date(y, m - 1, 1).getDay();
+  const firstDay = (jsDay + 6) % 7;
   const totalDays = new Date(y, m, 0).getDate();
   const todayStr = formatDate(new Date());
   const byDate = new Map();