101 lines
3.0 KiB
HTML
101 lines
3.0 KiB
HTML
<template id="date-time-picker">
|
|
<v-row class="ma-0 pa-0">
|
|
<v-col cols="6" class="ma-0 pa-0">
|
|
<v-menu
|
|
:close-on-content-click="false"
|
|
:nudge-right="40"
|
|
transition="scale-transition"
|
|
offset-y
|
|
min-width="auto"
|
|
:disabled="disabled">
|
|
<template v-slot:activator="{ on, attrs }">
|
|
<v-text-field
|
|
class="jh-v-input"
|
|
dense
|
|
single-line
|
|
filled
|
|
v-bind="attrs"
|
|
v-on="on"
|
|
placeholder='请选择日期'
|
|
:value="date"
|
|
:readonly="disabled"
|
|
></v-text-field>
|
|
</template>
|
|
<v-date-picker no-title scrollable v-model="date"></v-date-picker>
|
|
</v-menu>
|
|
</v-col>
|
|
<v-col cols="3" class="ma-0 pa-0">
|
|
<v-select class="jh-v-input ml-1" v-model="hour" dense filled single-line :items="_.map(_.range(24), String)" label="时" :readonly="disabled"></v-select>
|
|
</v-col>
|
|
<v-col cols="3" class="ma-0 pa-0">
|
|
<v-select class="jh-v-input ml-1" v-model="minute" dense filled single-line :items="_.map(_.range(60), String)" label="分钟" :readonly="disabled"></v-select>
|
|
</v-col>
|
|
</v-row>
|
|
</template>
|
|
<script type="module">
|
|
Vue.component("date-time-picker", {
|
|
template: '#date-time-picker',
|
|
props: {
|
|
datetime: {
|
|
type: [Date, String],
|
|
default: null,
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
validationRules: {
|
|
requireRules: [
|
|
v => !!v || '必填',
|
|
],
|
|
},
|
|
constantObj: {
|
|
},
|
|
date: null,
|
|
hour: null,
|
|
minute: null
|
|
}
|
|
},
|
|
watch: {
|
|
date(){
|
|
this.saveDateTime()
|
|
},
|
|
hour(){
|
|
this.saveDateTime()
|
|
},
|
|
minute(){
|
|
this.saveDateTime()
|
|
},
|
|
},
|
|
created() {},
|
|
mounted() {
|
|
this.init()
|
|
},
|
|
methods: {
|
|
async doUiAction(uiActionId, uiActionData) {
|
|
switch (uiActionId) {
|
|
default:
|
|
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
|
break;
|
|
}
|
|
},
|
|
init(){
|
|
if (!this.datetime) {
|
|
return;
|
|
}
|
|
let datetime = dayjs(this.datetime)
|
|
this.date = `${datetime.year()}-${datetime.month()+1}-${datetime.date()}`
|
|
this.hour = `${datetime.hour()}`
|
|
this.minute = `${datetime.minute()}`
|
|
},
|
|
saveDateTime(){
|
|
this.$emit('input', `${this.date} ${this.hour<10?'0'+this.hour:this.hour}:${this.minute<10?'0'+this.minute:this.minute}`)
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style scoped></style> |