gemercheung 2 anni fa
parent
commit
d64b679f4b
1 ha cambiato i file con 24 aggiunte e 5 eliminazioni
  1. 24 5
      src/views/room/edit-room/index.vue

+ 24 - 5
src/views/room/edit-room/index.vue

@@ -118,6 +118,7 @@
               :disabled="isRoomEnd"
               :disabledDate="disabledDate"
               :disabledTime="disabledTime"
+              @calendarChange="onRangeChange"
               v-model:value="current.useTimeList"
             />
           </a-form-item>
@@ -147,7 +148,7 @@
               <InfoCircleOutlined
                 @click="
                   Modal.confirm({
-                    centered:true,
+                    centered: true,
                     title: () => t('room.authTipTitle'),
                     icon: () => createVNode(ExclamationCircleOutlined),
                     //@ts-ignore
@@ -268,9 +269,10 @@ import type { FormInstance } from 'ant-design-vue'
 import { useI18n } from '@/hook/useI18n'
 import { useLocale } from '@/locales/useLocale'
 import dayjs, { Dayjs } from 'dayjs'
+import duration from 'dayjs/plugin/duration'
 import { addAuthUser } from '@/api'
-import {ExclamationCircleOutlined} from '@ant-design/icons-vue'
-
+import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
+dayjs.extend(duration)
 // const titleValidator = ref({
 //   validator: (_, value) =>
 //     !value.includes(' ')
@@ -402,14 +404,30 @@ export default defineComponent({
     const disabledDate = (current: Dayjs) => {
       return current && current < dayjs().startOf('day')
     }
+
     const disabledTime = () => {
       return {
-        disabledHours: () => [...Array(dayjs().hour()).keys()],
+        disabledHours: () => [],
         disabledMinutes: () => [],
         disabledSeconds: () => []
       }
     }
 
+    const onRangeChange = (range: Dayjs[]) => {
+      const select = range.map((i, index) => {
+        if (i) {
+          const diff = i.diff(dayjs(), 'minutes')
+         
+          if (diff < 0) {
+            // @ts-ignore
+            current.useTimeList[index] = dayjs();
+            console.log('diff', diff,index)
+          }
+        }
+      })
+      console.log('onRangeChange', event)
+    }
+
     return {
       handleNickRegex,
       returnLocale,
@@ -434,7 +452,8 @@ export default defineComponent({
       disabledTime,
       createVNode,
       Modal,
-      ExclamationCircleOutlined
+      ExclamationCircleOutlined,
+      onRangeChange
       // authTargetUser,
       // authTargetUserTime
     }