소스 검색

refactor(forecast-form): 重构表单提交逻辑并移除调试日志

yz 1 주 전
부모
커밋
5bacc6a42d
3개의 변경된 파일16개의 추가작업 그리고 8개의 파일을 삭제
  1. 14 6
      src/components/forecast-form/forecast-form-avue.vue
  2. 1 1
      src/components/forecast-form/index.js
  3. 1 1
      src/views/forecast/forecastIndex.js

+ 14 - 6
src/components/forecast-form/forecast-form-avue.vue

@@ -344,13 +344,21 @@ export default {
     /**
      * 表单提交处理
      */
-    async handleSubmit() {
-      try {
-        // 表单验证
-        const valid = await this.$refs.forecastForm.validate()
+    handleSubmit() {
+      // 表单验证
+      this.$refs.forecastForm.validate((valid) => {
         if (!valid) {
           return
         }
+        this.submitForm()
+      })
+    },
+
+    /**
+     * 执行表单提交
+     */
+    async submitForm() {
+      try {
 
         // 提交数据
         const submitData = { ...this.formData }
@@ -363,8 +371,8 @@ export default {
           this.$message.success('新增销售预测成功')
         }
 
-        // 触发成功事件
-        this.$emit('success', submitData)
+        // 触发提交成功事件
+        this.$emit('submit', submitData)
       } catch (error) {
         console.error('提交表单失败:', error)
         this.$message.error(error.message || '操作失败,请重试')

+ 1 - 1
src/components/forecast-form/index.js

@@ -361,7 +361,7 @@ export default {
       try {
         // customer-select组件会自动处理回显,我们只需要确保formData中有正确的值
         // 组件的watch会监听value变化并调用loadCustomerById方法
-        console.log('客户回显数据:', { customerId, customerName })
+    
       } catch (error) {
         console.error('加载客户选项失败:', error)
       }

+ 1 - 1
src/views/forecast/forecastIndex.js

@@ -615,7 +615,7 @@ export default {
     handleSave() {
       if (this.$refs.forecastForm) {
         this.saveLoading = true
-        this.$refs.forecastForm.handleSave()
+        this.$refs.forecastForm.handleSubmit()
       }
     },