Forráskód Böngészése

fix(forecast-form): 修复编辑模式下year字段类型不一致问题

yz 1 hete
szülő
commit
10f164bcae

+ 10 - 4
src/components/forecast-form/forecast-form-avue.vue

@@ -152,7 +152,10 @@ export default {
     editData: {
       handler(newData) {
         if (newData && this.isEdit) {
-          this.formData = { ...newData }
+          this.formData = { 
+            ...newData,
+            year: newData.year ? newData.year.toString() : ''
+          }
         }
       },
       immediate: true,
@@ -196,9 +199,12 @@ export default {
      * 初始化表单数据
      */
     initFormData() {
-      if (this.isEdit && this.editData) {
-        // 编辑模式:使用传入的数据
-        this.formData = { ...this.editData }
+        if (this.isEdit && this.editData) {
+          // 编辑模式:使用传入的数据,确保year字段为字符串格式
+          this.formData = { 
+            ...this.editData,
+            year: this.editData.year ? this.editData.year.toString() : ''
+          }
       } else {
         // 新增模式:使用默认数据,自动填入下个月
         const now = new Date()

+ 1 - 1
src/views/forecast/index.vue

@@ -97,7 +97,7 @@
         ref="forecastForm"
         :visible="true"
         :is-edit="editMode === 'edit'"
-        :forecast-id="currentForecastId"
+        :edit-data="form"
         @close="handleFormClose"
         @submit="handleFormSubmit"
       />