tangning 1 år sedan
förälder
incheckning
5c1c547c4b
1 ändrade filer med 45 tillägg och 6 borttagningar
  1. 45 6
      src/views/productOperation/modal/detailModal.vue

+ 45 - 6
src/views/productOperation/modal/detailModal.vue

@@ -45,6 +45,39 @@
       const { createMessage } = useMessage();
       const title = ref('新增客户');
       const optionsName = ref([]);
+      const range = (start, end) => {
+        const result = [];
+        for (let i = start; i < end; i++) {
+          result.push(i);
+        }
+        return result;
+      };
+
+      const disabledTime = (date) => {
+        const hour = dayjs().hour(); // 获取当前的小时
+        const min = dayjs().minute(); // 获取当前的分钟
+        const second = dayjs().second(); // 获取当前秒
+        if (dayjs(date).format('YYYY-MM-DD') === dayjs().format('YYYY-MM-DD')) {
+          if (dayjs(date).format('HH') === dayjs().format('HH')) {
+            if (dayjs(date).format('mm') === dayjs().format('mm')) {
+              return {
+                disabledHours: () => range(0, 24).splice(0, hour),
+                disabledMinutes: () => range(0, 60).splice(0, min),
+                disabledSeconds: () => range(0, 60).splice(0, second),
+              };
+            } else {
+              return {
+                disabledHours: () => range(0, 24).splice(0, hour),
+                disabledMinutes: () => range(0, 60).splice(0, min),
+              };
+            }
+          } else {
+            return {
+              disabledHours: () => range(0, 24).splice(0, hour),
+            };
+          }
+        }
+      };
       const schemas: FormSchema[] = [
         {
           field: 'num',
@@ -139,14 +172,15 @@
             type: 'datetime',
             format: 'YYYY-MM-DD HH:mm',
             disabledDate: (current) => {
-              return current && current < dayjs();
+              return current && current < dayjs().startOf('day');
             },
+            disabledTime: disabledTime,
             onChange: (value) => {
               updateSchema({
                 field: 'lookEndTime',
                 componentProps: {
                   disabledDate: (current) => {
-                    return current && (current < dayjs().endOf('day') || current > dayjs(value));
+                    return current && (current < dayjs().startOf('day') || current > dayjs(value));
                   },
                 },
               });
@@ -187,6 +221,7 @@
             },
             valueFormat: 'YYYY-MM-DD HH:mm',
             format: 'YYYY-MM-DD HH:mm',
+            disabledTime: disabledTime,
             disabledDate: (current) => {
               console.log('current', current);
               return current && current < dayjs();
@@ -284,10 +319,11 @@
                 if (checkAuthOther.editEndTime) {
                   return (
                     current &&
-                    (current < dayjs().endOf('day') || current > dayjs(checkAuthOther.editEndTime))
+                    (current < dayjs().startOf('day') ||
+                      current > dayjs(checkAuthOther.editEndTime))
                   );
                 } else {
-                  return current && current < dayjs().endOf('day');
+                  return current && current < dayjs().startOf('day');
                 }
               },
             },
@@ -300,10 +336,11 @@
                 if (checkAuthOther.lookEndTime) {
                   return (
                     current &&
-                    (current < dayjs().endOf('day') || current > dayjs(checkAuthOther.lookEndTime))
+                    (current < dayjs().startOf('day') ||
+                      current > dayjs(checkAuthOther.lookEndTime))
                   );
                 } else {
-                  return current && current < dayjs().endOf('day');
+                  return current && current < dayjs().startOf('day');
                 }
               },
             },
@@ -317,6 +354,7 @@
         }
         // return option.value.indexOf(inputText.toUpperCase()) >= 0;
       }
+
       async function onSearch(searchText) {
         const list = await getByRyId({ ryId: searchText });
         optionsName.value =
@@ -418,6 +456,7 @@
         resetFields,
         title,
         t,
+        disabledTime,
       };
     },
   });