fix bug: 时间日期选择器

This commit is contained in:
ChenXinXin committed 2024-05-09 16:01:48 +08:00
1 parent d4932fa7a8
commit fbbf5a88d4
1 file changed
+9 -8
@@ -36,9 +36,9 @@
Vue.component("date-time-picker", { Vue.component("date-time-picker", {
template: '#date-time-picker', template: '#date-time-picker',
props: { props: {
datetime: { value: {
type: [Date, String], type: String,
default: null, default: ''
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
@@ -52,8 +52,6 @@ Vue.component("date-time-picker", {
v => !!v || '必填', v => !!v || '必填',
], ],
}, },
constantObj: {
},
date: null, date: null,
hour: null, hour: null,
minute: null minute: null
@@ -72,21 +70,24 @@ Vue.component("date-time-picker", {
}, },
created() {}, created() {},
mounted() { mounted() {
this.init() this.doUiAction('init')
}, },
methods: { methods: {
async doUiAction(uiActionId, uiActionData) { async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) { switch (uiActionId) {
case 'init':
await this.init();
break;
default: default:
console.error("[doUiAction] uiActionId not find", {uiActionId}); console.error("[doUiAction] uiActionId not find", {uiActionId});
break; break;
} }
}, },
init(){ init(){
if (!this.datetime) { if (!this.value) {
return; return;
} }
let datetime = dayjs(this.datetime) let datetime = dayjs(this.value)
this.date = `${datetime.year()}-${datetime.month()+1}-${datetime.date()}` this.date = `${datetime.year()}-${datetime.month()+1}-${datetime.date()}`
this.hour = `${datetime.hour()}` this.hour = `${datetime.hour()}`
this.minute = `${datetime.minute()}` this.minute = `${datetime.minute()}`