浏览代码

DatePicker: fix time range

qingwei.li 8 年之前
父节点
当前提交
58c19ebaf0
共有 2 个文件被更改,包括 2 次插入3 次删除
  1. 1 1
      packages/date-picker/src/panel/time.vue
  2. 1 2
      packages/date-picker/src/util/index.js

+ 1 - 1
packages/date-picker/src/panel/time.vue

@@ -134,7 +134,7 @@
 
       handleConfirm(visible = false, first) {
         if (first) return;
-        const date = new Date(limitRange(this.currentDate, this.selectableRange));
+        const date = new Date(limitRange(this.currentDate, this.selectableRange, 'HH:mm:ss'));
         this.$emit('pick', date, visible, first);
       },
 

+ 1 - 2
packages/date-picker/src/util/index.js

@@ -141,11 +141,10 @@ export const getRangeHours = function(ranges) {
   return hours;
 };
 
-export const limitRange = function(date, ranges) {
+export const limitRange = function(date, ranges, format = 'yyyy-MM-dd HH:mm:ss') {
   if (!ranges || !ranges.length) return date;
 
   const len = ranges.length;
-  const format = 'HH:mm:ss';
 
   date = dateUtil.parse(dateUtil.format(date, format), format);
   for (let i = 0; i < len; i++) {