iview/src/components/date-picker/picker/time-picker.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

import Vue from 'vue';
2016-12-26 14:50:39 +08:00
import Picker from '../picker.vue';
import TimePanel from '../panel/time.vue';
2016-12-28 15:21:25 +08:00
import TimeRangePanel from '../panel/time-range.vue';
2016-12-26 15:04:02 +08:00
import Options from '../time-mixins';
2016-12-26 14:50:39 +08:00
2016-12-28 15:21:25 +08:00
const getPanel = function (type) {
if (type === 'timerange') {
return TimeRangePanel;
}
return TimePanel;
};
import { oneOf } from '../../../utils/assist';
2016-12-26 14:50:39 +08:00
export default {
2016-12-26 15:04:02 +08:00
mixins: [Picker, Options],
2016-12-26 14:50:39 +08:00
props: {
2016-12-28 15:21:25 +08:00
type: {
validator (value) {
return oneOf(value, ['time', 'timerange']);
},
default: 'time'
},
steps: {
type: Array,
default: () => []
},
2016-12-26 15:04:02 +08:00
value: {}
2016-12-26 14:50:39 +08:00
},
created () {
if (!this.currentValue) {
2016-12-28 15:21:25 +08:00
if (this.type === 'timerange') {
this.currentValue = ['',''];
2016-12-28 15:21:25 +08:00
} else {
this.currentValue = '';
2016-12-28 15:21:25 +08:00
}
}
const Panel = Vue.extend(getPanel(this.type));
this.Panel = new Panel({
propsData: {
steps: this.steps
}
});
2016-12-26 14:50:39 +08:00
}
};