Explorar el Código

feat(attendance): 将开始和结束日期默认设置为今天的日期

xieyong hace 4 días
padre
commit
72601166a2
Se han modificado 1 ficheros con 8 adiciones y 5 borrados
  1. 8 5
      src/pages/apply/form.vue

+ 8 - 5
src/pages/apply/form.vue

@@ -165,12 +165,14 @@ import { getServerConfig } from "@/utils/auth";
 const type = ref("leave");
 const type = ref("leave");
 useAuthGuard();
 useAuthGuard();
 const currentUser = useCurrentUser();
 const currentUser = useCurrentUser();
+// 今天日期(在 reactive() 之前声明,供初始默认值使用)
+const todayStr = new Date().toISOString().slice(0, 10);
 const form = reactive({
 const form = reactive({
   leaveType: "",
   leaveType: "",
   certificateType: "",
   certificateType: "",
-  startDate: "2026-08-06",
+  startDate: todayStr,
   startTime: "08:30",
   startTime: "08:30",
-  endDate: "2026-08-06",
+  endDate: todayStr,
   endTime: "17:30",
   endTime: "17:30",
   reason: "",
   reason: "",
   attachments: [],
   attachments: [],
@@ -222,6 +224,8 @@ function syncType(o = {}) {
   //   - 跨会话遗留的 uploading 状态 → 视为失败(upload 早已中断)
   //   - 跨会话遗留的 uploading 状态 → 视为失败(upload 早已中断)
   if (!form.startTime) form.startTime = "08:30";
   if (!form.startTime) form.startTime = "08:30";
   if (!form.endTime) form.endTime = "17:30";
   if (!form.endTime) form.endTime = "17:30";
+  // 补卡:兜底老草稿里 startDate 为空的情况(resetForm 已默认填今天)
+  if (next === "check" && !form.startDate) form.startDate = todayStr;
   if (!Array.isArray(form.attachments)) {
   if (!Array.isArray(form.attachments)) {
     form.attachments = [];
     form.attachments = [];
   } else if (form.attachments.some((a) => typeof a === "string")) {
   } else if (form.attachments.some((a) => typeof a === "string")) {
@@ -257,9 +261,9 @@ function resetForm() {
   Object.assign(form, {
   Object.assign(form, {
     leaveType: "",
     leaveType: "",
     certificateType: "",
     certificateType: "",
-    startDate: "2026-08-06",
+    startDate: todayStr,
     startTime: "08:30",
     startTime: "08:30",
-    endDate: "2026-08-06",
+    endDate: todayStr,
     endTime: "17:30",
     endTime: "17:30",
     reason: "",
     reason: "",
     attachments: [],
     attachments: [],
@@ -297,7 +301,6 @@ function chooseRepairType() {
   });
   });
 }
 }
 
 
-const todayStr = new Date().toISOString().slice(0, 10);
 const assetReturnOptions = ['工牌', '门禁卡', '办公电脑', '测量仪器', '其他'];
 const assetReturnOptions = ['工牌', '门禁卡', '办公电脑', '测量仪器', '其他'];
 
 
 function toggleAssetReturn(opt) {
 function toggleAssetReturn(opt) {