From ce51d7719b4d908da5577751f0c840fab5d1a39e Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期五, 19 四月 2024 17:45:54 +0800 Subject: [PATCH] 20240419 --- src/components/search-option/FYOptionTime.vue | 46 +++++++++++++++++++--------------------------- 1 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/components/search-option/FYOptionTime.vue b/src/components/search-option/FYOptionTime.vue index fdea90c..801fbde 100644 --- a/src/components/search-option/FYOptionTime.vue +++ b/src/components/search-option/FYOptionTime.vue @@ -1,8 +1,9 @@ <template> - <el-form-item label="鏃堕棿"> + <el-form-item label="鏃堕棿" :prop="prop"> <el-date-picker - v-model="selectedOptions" - type="month" + v-model="date" + @change="handleChange" + :type="type" placeholder="閫夋嫨鏃堕棿" style="width: 150px" /> @@ -10,9 +11,9 @@ </template> <script> -import dayjs from 'dayjs' +import dayjs from 'dayjs'; -const MONTH = 'month' +const MONTH = 'month'; export default { props: { @@ -26,44 +27,35 @@ initValue: { type: Boolean, default: true - } + }, + prop: String }, emits: ['update:value'], data() { return { - selectedOptions: '' - } + date: this.value + }; }, - watch: { - selectedOptions: { - handler(nVal, oVal) { - if (nVal != oVal) { - this.$emit('update:value', nVal) - } - } - }, - value: { - handler(nVal, oVal) { - if (nVal != oVal) { - this.selectedOptions = nVal - } - } - } + computed:{ }, methods: { + handleChange(value) { + this.$emit('update:value', value); + }, timeFormat() { switch (this.type) { case MONTH: - return 'YYYY-MM' + return 'YYYY-MM'; default: - return 'YYYY-MM' + return 'YYYY-MM'; } } }, mounted() { if (this.initValue) { - this.selectedOptions = new Date() + this.date = new Date() + this.handleChange(this.date); } } -} +}; </script> -- Gitblit v1.9.3