From c06a5b40718062cc8b4b971322d7c394018cc972 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期五, 27 九月 2024 13:29:14 +0800
Subject: [PATCH] 评估

---
 src/components/search-option/FYOptionTime.vue |   52 ++++++++++++++++++----------------------------------
 1 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/src/components/search-option/FYOptionTime.vue b/src/components/search-option/FYOptionTime.vue
index 9a6ba6f..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,45 +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
-        }
-      },
-      immediate: true
-    }
+  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