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

36 lines
874 B
JavaScript
Raw Normal View History

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'
},
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
}
}
this.panel = getPanel(this.type);
2016-12-26 14:50:39 +08:00
}
};