diff --git a/src/components/date-picker/base/time-spinner.vue b/src/components/date-picker/base/time-spinner.vue
index f243fe5..cbb8359 100644
--- a/src/components/date-picker/base/time-spinner.vue
+++ b/src/components/date-picker/base/time-spinner.vue
@@ -1,18 +1,18 @@
-
- - {{ formatTime(item.text) }}
+
+ - {{ formatTime(item.text) }}
-
- - {{ formatTime(item.text) }}
+
+ - {{ formatTime(item.text) }}
-
- - {{ formatTime(item.text) }}
+
+ - {{ formatTime(item.text) }}
@@ -41,10 +41,15 @@
showSeconds: {
type: Boolean,
default: true
+ },
+ steps: {
+ type: Array,
+ default: () => []
}
},
data () {
return {
+ spinerSteps: [1, 1, 1].map((one, i) => Math.abs(this.steps[i]) || one),
prefixCls: prefixCls,
compiled: false
};
@@ -60,6 +65,7 @@
},
hoursList () {
let hours = [];
+ const step = this.spinerSteps[0];
const hour_tmpl = {
text: 0,
selected: false,
@@ -67,7 +73,7 @@
hide: false
};
- for (let i = 0; i < 24; i++) {
+ for (let i = 0; i < 24; i += step) {
const hour = deepCopy(hour_tmpl);
hour.text = i;
@@ -83,6 +89,7 @@
},
minutesList () {
let minutes = [];
+ const step = this.spinerSteps[1];
const minute_tmpl = {
text: 0,
selected: false,
@@ -90,7 +97,7 @@
hide: false
};
- for (let i = 0; i < 60; i++) {
+ for (let i = 0; i < 60; i += step) {
const minute = deepCopy(minute_tmpl);
minute.text = i;
@@ -101,11 +108,11 @@
if (this.minutes === i) minute.selected = true;
minutes.push(minute);
}
-
return minutes;
},
secondsList () {
let seconds = [];
+ const step = this.spinerSteps[2];
const second_tmpl = {
text: 0,
selected: false,
@@ -113,7 +120,7 @@
hide: false
};
- for (let i = 0; i < 60; i++) {
+ for (let i = 0; i < 60; i += step) {
const second = deepCopy(second_tmpl);
second.text = i;
@@ -138,24 +145,11 @@
}
];
},
- handleClickHours (event) {
- this.handleClick('hours', event);
- },
- handleClickMinutes (event) {
- this.handleClick('minutes', event);
- },
- handleClickSeconds (event) {
- this.handleClick('seconds', event);
- },
- handleClick (type, event) {
- const target = event.target;
- if (target.tagName === 'LI') {
- const cell = this[`${type}List`][parseInt(event.target.getAttribute('index'))];
- if (cell.disabled) return;
- const data = {};
- data[type] = cell.text;
- this.$emit('on-change', data);
- }
+ handleClick (type, cell) {
+ if (cell.disabled) return;
+ const data = {};
+ data[type] = cell.text;
+ this.$emit('on-change', data);
this.$emit('on-pick-click');
},
scroll (type, index) {
@@ -183,20 +177,24 @@
},
formatTime (text) {
return text < 10 ? '0' + text : text;
+ },
+ getItemIndex(type, val){
+ const item = this[`${type}List`].find(obj => obj.text == val);
+ return this[`${type}List`].indexOf(item);
}
},
watch: {
hours (val) {
if (!this.compiled) return;
- this.scroll('hours', val);
+ this.scroll('hours', this.getItemIndex('hours', val));
},
minutes (val) {
if (!this.compiled) return;
- this.scroll('minutes', val);
+ this.scroll('minutes', this.getItemIndex('minutes', val));
},
seconds (val) {
if (!this.compiled) return;
- this.scroll('seconds', val);
+ this.scroll('seconds', this.getItemIndex('seconds', val));
}
},
mounted () {
@@ -204,4 +202,4 @@
this.$nextTick(() => this.compiled = true);
}
};
-
\ No newline at end of file
+
diff --git a/src/components/date-picker/panel/time.vue b/src/components/date-picker/panel/time.vue
index fd7c13f..4cd6397 100644
--- a/src/components/date-picker/panel/time.vue
+++ b/src/components/date-picker/panel/time.vue
@@ -6,6 +6,7 @@
[]
+ }
+ },
data () {
return {
prefixCls: prefixCls,
@@ -113,4 +120,4 @@
if (this.$parent && this.$parent.$options.name === 'DatePicker') this.showDate = true;
}
};
-
\ No newline at end of file
+
diff --git a/src/components/date-picker/picker.vue b/src/components/date-picker/picker.vue
index 9f03d55..c9ccce3 100644
--- a/src/components/date-picker/picker.vue
+++ b/src/components/date-picker/picker.vue
@@ -32,7 +32,6 @@