Explorar o código

fix: 修复交通事故管理bug(重置清空时间+创建限制时间选择范围)

bxy hai 7 meses
pai
achega
f3a6300f7d

+ 1 - 0
src/views/traffic/accident/Accident.vue

@@ -197,6 +197,7 @@
   const handleReset = () => {
     searchSelectedType.value = FIELDTYPE.LOCATION;
     searchKeyword.value = '';
+    queryTimes.value = ['', ''];
     getTableData();
   };
 

+ 25 - 36
src/views/traffic/accident/components/ManageAccidentItem.vue

@@ -81,7 +81,9 @@
               placeholder="请选择事故发生时间"
               style="width: 100%"
               :disabled-date="disabledDate"
-              :disabled-time="disabledTime"
+              :disabled-hours="disabledHours"
+              :disabled-minutes="disabledMinutes"
+              :disabled-seconds="disabledSeconds"
             />
           </el-form-item>
         </el-col>
@@ -209,42 +211,29 @@
   const disabledDate = (time: Date) => {
     return time.getTime() > Date.now();
   };
-
-  // 禁用未来时间
-  const disabledTime = (date: Date) => {
-    const now = new Date();
-    if (date.toDateString() === now.toDateString()) {
-      return {
-        disabledHours: () => {
-          const hours: number[] = [];
-          for (let i = now.getHours() + 1; i < 24; i++) {
-            hours.push(i);
-          }
-          return hours;
-        },
-        disabledMinutes: (hour: number) => {
-          if (hour === now.getHours()) {
-            const minutes: number[] = [];
-            for (let i = now.getMinutes() + 1; i < 60; i++) {
-              minutes.push(i);
-            }
-            return minutes;
-          }
-          return [];
-        },
-        disabledSeconds: (hour: number, minute: number) => {
-          if (hour === now.getHours() && minute === now.getMinutes()) {
-            const seconds: number[] = [];
-            for (let i = now.getSeconds() + 1; i < 60; i++) {
-              seconds.push(i);
-            }
-            return seconds;
-          }
-          return [];
-        },
-      };
+  const disabledHours = () => {
+    const arrs: number[] = [];
+    for (let i = 0; i < 24; i++) {
+      if (new Date().getHours() >= i) continue;
+      arrs.push(i);
+    }
+    return arrs;
+  };
+  const disabledMinutes = () => {
+    const arrs: number[] = [];
+    for (let i = 0; i < 60; i++) {
+      if (new Date().getMinutes() >= i) continue;
+      arrs.push(i);
+    }
+    return arrs;
+  };
+  const disabledSeconds = () => {
+    const arrs: number[] = [];
+    for (let i = 0; i < 60; i++) {
+      if (new Date().getSeconds() >= i) continue;
+      arrs.push(i);
     }
-    return {};
+    return arrs;
   };
 
   // 事故图片