2020-09-16 14:49:21 +08:00
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import customParseFormat from 'dayjs/plugin/customParseFormat'
|
|
|
|
import { h } from 'vue'
|
|
|
|
import { DEFAULT_FORMATS_TIME } from './common/constant'
|
|
|
|
import Picker from './common/picker.vue'
|
|
|
|
import TimePickPanel from './time-picker-com/panel-time-pick.vue'
|
|
|
|
import TimeRangePanel from './time-picker-com/panel-time-range.vue'
|
2020-11-02 11:05:08 +08:00
|
|
|
|
2020-09-16 14:49:21 +08:00
|
|
|
dayjs.extend(customParseFormat)
|
2020-11-02 11:05:08 +08:00
|
|
|
|
2020-09-16 14:49:21 +08:00
|
|
|
export default {
|
|
|
|
name: 'ElTimePicker',
|
2020-11-20 20:24:16 +08:00
|
|
|
install: null,
|
2020-09-16 14:49:21 +08:00
|
|
|
props: {
|
|
|
|
isRange: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
setup(props) {
|
|
|
|
const type = props.isRange ? 'timerange' : 'time'
|
|
|
|
const panel = props.isRange ? TimeRangePanel : TimePickPanel
|
|
|
|
return () => h(Picker, {
|
|
|
|
format: DEFAULT_FORMATS_TIME,
|
|
|
|
...props,
|
|
|
|
type,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
default: scopedProps => h(panel, scopedProps),
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|