From 49774b6f258cf4a348b60fe7aaf610d0ffd5b5f4 Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期五, 27 九月 2024 15:22:17 +0800 Subject: [PATCH] 评估修改后的提交 --- src/components/search-option/FYOptionTime.vue | 51 ++++++++++++++++++--------------------------------- 1 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/components/search-option/FYOptionTime.vue b/src/components/search-option/FYOptionTime.vue index fdea90c..ac1292c 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,10 @@ </template> <script> -import dayjs from 'dayjs' +import dayjs from 'dayjs'; -const MONTH = 'month' +const MONTH = 'month'; +const DATE = 'date'; export default { props: { @@ -26,44 +28,27 @@ 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: { - timeFormat() { - switch (this.type) { - case MONTH: - return 'YYYY-MM' - default: - return 'YYYY-MM' - } - } + handleChange(value) { + this.$emit('update:value', value); + }, }, mounted() { if (this.initValue) { - this.selectedOptions = new Date() + this.date = new Date() + this.handleChange(this.date); } } -} +}; </script> -- Gitblit v1.9.3