Преглед изворни кода

DateTimePicker: limit timepicker (#6076)

* fix: #5045

* fix: #5045
Dreamacro пре 8 година
родитељ
комит
a1324324a2
2 измењених фајлова са 9 додато и 2 уклоњено
  1. 5 0
      packages/date-picker/src/panel/date.vue
  2. 4 2
      packages/date-picker/src/panel/time.vue

+ 5 - 0
packages/date-picker/src/panel/date.vue

@@ -265,6 +265,11 @@
           oldDate.setHours(hour);
           oldDate.setMinutes(minute);
           oldDate.setSeconds(second);
+          if (typeof this.disabledDate === 'function' && this.disabledDate(oldDate)) {
+            this.$refs.timepicker.disabled = true;
+            return;
+          }
+          this.$refs.timepicker.disabled = false;
           this.date = new Date(oldDate.getTime());
         }
 

+ 4 - 2
packages/date-picker/src/panel/time.vue

@@ -23,7 +23,8 @@
           @click="handleCancel">{{ t('el.datepicker.cancel') }}</button>
         <button
           type="button"
-          class="el-time-panel__btn confirm"
+          class="el-time-panel__btn"
+          :class="{confirm: !disabled}"
           @click="handleConfirm()">{{ t('el.datepicker.confirm') }}</button>
       </div>
     </div>
@@ -101,7 +102,8 @@
         currentDate: this.$options.defaultValue || this.date || new Date(),
         currentVisible: this.visible || false,
         width: this.pickerWidth || 0,
-        selectionRange: [0, 2]
+        selectionRange: [0, 2],
+        disabled: false
       };
     },