表单设置
This commit is contained in:
1 parent
61235c6ec2
commit
7751704fe7
3 files changed
+167
-34
No files matched your search
@@ -0,0 +1,104 @@
|
||||
<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"
|
||||
:disabled="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="时" :disabled="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="分钟" :disabled="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.$emit('save-date-time', `${this.date} ${this.hour<10?'0'+this.hour:this.hour}:${this.minute<10?'0'+this.minute:this.minute}`)
|
||||
},
|
||||
hour(){
|
||||
this.$emit('save-date-time', `${this.date} ${this.hour<10?'0'+this.hour:this.hour}:${this.minute<10?'0'+this.minute:this.minute}`)
|
||||
},
|
||||
minute(){
|
||||
this.$emit('save-date-time', `${this.date} ${this.hour<10?'0'+this.hour:this.hour}:${this.minute<10?'0'+this.minute:this.minute}`)
|
||||
},
|
||||
},
|
||||
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)
|
||||
console.log(datetime);
|
||||
this.date = `${datetime.year()}-${datetime.month()+1}-${datetime.date()}`
|
||||
this.hour = `${datetime.hour()}`
|
||||
this.minute = `${datetime.minute()}`
|
||||
console.log(this.hour, this.minute);
|
||||
// this.time = `${date.hour()<10?'0'+date.hour():date.hour()}:${date.minute()<10?'0'+date.minute():date.minute()}`
|
||||
},
|
||||
saveDateTime(){
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
Reference in new issue
Block a user