Browse Source

外来人员签出时间选择组件优化

cfort 1 year ago
parent
commit
18ada550b2
1 changed files with 15 additions and 1 deletions
  1. 15 1
      src/views/business/registrationOutsiders/checkOut.vue

+ 15 - 1
src/views/business/registrationOutsiders/checkOut.vue

@@ -24,6 +24,7 @@
                     placeholder="选择签出时间"
                     placeholder="选择签出时间"
                     value-format="yyyy-MM-dd HH:mm"
                     value-format="yyyy-MM-dd HH:mm"
                     format="yyyy-MM-dd HH:mm"
                     format="yyyy-MM-dd HH:mm"
+                    :picker-options="endPickerOptions"
                     style="width: 96%"
                     style="width: 96%"
                 />
                 />
             </el-form-item>
             </el-form-item>
@@ -50,13 +51,26 @@ export default {
         }
         }
     },
     },
     data () {
     data () {
+        const that = this
         return {
         return {
             title: '签出',
             title: '签出',
             dialogVisible: this.visible,
             dialogVisible: this.visible,
             formList: {
             formList: {
                 dataTime: this.formatDate(new Date())
                 dataTime: this.formatDate(new Date())
             },
             },
-            toolbars: [{ key: 'confirm' }, { key: 'cancel' }]
+            toolbars: [{ key: 'confirm' }, { key: 'cancel' }],
+            endPickerOptions: {
+                disabledDate (time) {
+                    const t = new Date(time)
+                    const { jin_ru_shi_jian_: startTime } = that.dataList
+                    // 禁用当前时间之后和来访时间之前的时间
+                    if (startTime) {
+                        const start = new Date(startTime)
+                        return t.getTime() < start.getTime() || t.getTime() > Date.now()
+                    }
+                    return t.getTime() > Date.now()
+                }
+            }
         }
         }
     },
     },
     watch: {
     watch: {