wyf 7 месяцев назад
Родитель
Сommit
3cf9bff117

+ 57 - 0
src/views/traffic/violation/act/components/ActCreate.vue

@@ -44,6 +44,63 @@
           </el-form-item>
         </div>
       </template>
+      <template #captureTime>
+        <el-date-picker
+          v-model="ruleFormData.captureTime"
+          placeholder="请选择抓拍时间"
+          type="datetime"
+          format="YYYY-MM-DD HH:mm:ss"
+          dateFormat="MMM DD YYYY"
+          timeFormat="HH:mm:ss"
+          valueFormat="YYYY-MM-DD HH:mm:ss"
+          :editable="false"
+          :disabledDate="(time) => time.getTime() > Date.now()"
+          :disabledHours="
+            (role, comparingDate) => {
+              if (!role) return [];
+              const now = new Date();
+              now.setHours(0, 0, 0, 0);
+              if (comparingDate.valueOf() < now.getTime()) return [];
+              const huors = 23 - new Date().getHours();
+              return Array.from({ length: huors }, (_, i) => 23 - i);
+            }
+          "
+          :disabledMinutes="
+            (hour, role, comparingDate) => {
+              if (!role) return [];
+              const now = new Date();
+              const nowHour = now.getHours();
+              if (hour < nowHour) return [];
+              now.setHours(0, 0, 0, 0);
+              if (comparingDate.valueOf() < now.getTime()) return [];
+              const minutes = 59 - new Date().getMinutes();
+              return Array.from({ length: minutes }, (_, i) => 59 - i);
+            }
+          "
+          :disabledSeconds="
+            (hour, minute, role, comparingDate) => {
+              if (!role) return [];
+              const now = new Date();
+              const nowHour = now.getHours();
+              const nowMinutes = now.getMinutes();
+              if (hour < nowHour) return [];
+              if (hour === nowHour && minute < nowMinutes) return [];
+              now.setHours(0, 0, 0, 0);
+              if (comparingDate.valueOf() < now.getTime()) return [];
+              const seconds = 59 - new Date().getSeconds();
+              return Array.from({ length: seconds }, (_, i) => 59 - i);
+            }
+          "
+          @change="
+            (val) => {
+              if (new Date(val).getTime() > Date.now()) {
+                ElMessage.error('抓拍时间不晚于当前时间,请重新选择');
+                ruleFormData.captureTime = '';
+              }
+            }
+          "
+        ></el-date-picker>
+      </template>
       <template #capturePhotos>
         <UploadImages :maxCount="5" ref="uploadImagesRef" @upload-success="handleUploadChange" />
       </template>

+ 59 - 2
src/views/traffic/violation/act/components/ActEdit.vue

@@ -44,6 +44,63 @@
           </el-form-item>
         </div>
       </template>
+      <template #captureTime>
+        <el-date-picker
+          v-model="ruleFormData.captureTime"
+          placeholder="请选择抓拍时间"
+          type="datetime"
+          format="YYYY-MM-DD HH:mm:ss"
+          dateFormat="MMM DD YYYY"
+          timeFormat="HH:mm:ss"
+          valueFormat="YYYY-MM-DD HH:mm:ss"
+          :editable="false"
+          :disabledDate="(time) => time.getTime() > Date.now()"
+          :disabledHours="
+            (role, comparingDate) => {
+              if (!role) return [];
+              const now = new Date();
+              now.setHours(0, 0, 0, 0);
+              if (comparingDate.valueOf() < now.getTime()) return [];
+              const huors = 23 - new Date().getHours();
+              return Array.from({ length: huors }, (_, i) => 23 - i);
+            }
+          "
+          :disabledMinutes="
+            (hour, role, comparingDate) => {
+              if (!role) return [];
+              const now = new Date();
+              const nowHour = now.getHours();
+              if (hour < nowHour) return [];
+              now.setHours(0, 0, 0, 0);
+              if (comparingDate.valueOf() < now.getTime()) return [];
+              const minutes = 59 - new Date().getMinutes();
+              return Array.from({ length: minutes }, (_, i) => 59 - i);
+            }
+          "
+          :disabledSeconds="
+            (hour, minute, role, comparingDate) => {
+              if (!role) return [];
+              const now = new Date();
+              const nowHour = now.getHours();
+              const nowMinutes = now.getMinutes();
+              if (hour < nowHour) return [];
+              if (hour === nowHour && minute < nowMinutes) return [];
+              now.setHours(0, 0, 0, 0);
+              if (comparingDate.valueOf() < now.getTime()) return [];
+              const seconds = 59 - new Date().getSeconds();
+              return Array.from({ length: seconds }, (_, i) => 59 - i);
+            }
+          "
+          @change="
+            (val) => {
+              if (new Date(val).getTime() > Date.now()) {
+                ElMessage.error('抓拍时间不晚于当前时间,请重新选择');
+                ruleFormData.captureTime = '';
+              }
+            }
+          "
+        ></el-date-picker>
+      </template>
       <template #capturePhotos>
         <UploadImages
           :maxCount="5"
@@ -108,6 +165,7 @@
     ruleFormData.creatName = actDetail.value.creatName;
 
     imageList.value = unformatImage(actDetail.value.capturePhotos)!;
+    cloneRuleFormData();
   };
 
   const imageList = ref<string[]>([]);
@@ -151,9 +209,8 @@
   };
 
   onMounted(() => {
-    getDetail();
-    cloneRuleFormData();
     beforeRouteLeave();
+    getDetail();
   });
 </script>
 

+ 1 - 40
src/views/traffic/violation/act/configs/form.ts

@@ -27,46 +27,7 @@ export const ACT_FORM_CONFIG: FormConfig[] = [
   {
     prop: 'captureTime',
     label: '抓拍时间:',
-    component: 'ElDatePicker',
-    componentProps: {
-      placeholder: '请选择抓拍时间',
-      type: 'datetime',
-      format: 'YYYY-MM-DD HH:mm:ss',
-      dateFormat: 'MMM DD, YYYY',
-      timeFormat: 'HH:mm:ss',
-      valueFormat: 'YYYY-MM-DD HH:mm:ss',
-      disabledDate: (time) => time.getTime() > Date.now(),
-      disabledHours: (role, comparingDate) => {
-        if (!role) return [];
-        const now = new Date();
-        now.setHours(0, 0, 0, 0);
-        if (comparingDate.valueOf() < now.getTime()) return [];
-        const huors = 23 - new Date().getHours();
-        return Array.from({ length: huors }, (_, i) => 23 - i);
-      },
-      disabledMinutes: (hour, role, comparingDate) => {
-        if (!role) return [];
-        const now = new Date();
-        const nowHour = now.getHours();
-        if (hour < nowHour) return [];
-        now.setHours(0, 0, 0, 0);
-        if (comparingDate.valueOf() < now.getTime()) return [];
-        const minutes = 59 - new Date().getMinutes();
-        return Array.from({ length: minutes }, (_, i) => 59 - i);
-      },
-      disabledSeconds: (hour, minute, role, comparingDate) => {
-        if (!role) return [];
-        const now = new Date();
-        const nowHour = now.getHours();
-        const nowMinutes = now.getMinutes();
-        if (hour < nowHour) return [];
-        if (hour === nowHour && minute < nowMinutes) return [];
-        now.setHours(0, 0, 0, 0);
-        if (comparingDate.valueOf() < now.getTime()) return [];
-        const seconds = 59 - new Date().getSeconds();
-        return Array.from({ length: seconds }, (_, i) => 59 - i);
-      },
-    },
+    slot: 'captureTime',
   },
   {
     prop: 'capturePhotos',