yz преди 3 месеца
родител
ревизия
c7a9de3a17
променени са 1 файла, в които са добавени 0 реда и са изтрити 103 реда
  1. 0 103
      src/components/forecast-form/forecast-form-mixin.js

+ 0 - 103
src/components/forecast-form/forecast-form-mixin.js

@@ -364,40 +364,29 @@ export default {
        * @param {boolean} val - 新的可见性值
        */
       handler(/** @type {boolean} */ val) {
-        console.log('👁️ [DEBUG] visible watcher 触发,值:', val);
         if (val) {
-          console.log('✅ [DEBUG] 表单显示,开始初始化');
           this.$nextTick(() => {
-            console.log('🔄 [DEBUG] $nextTick 回调执行');
-
             // 表单显示时,初始化表单数据
             if (this.initialFormData) {
-              console.log('📋 [DEBUG] 使用初始表单数据');
               this.formData = this.cleanAndFormatFormData(this.initialFormData)
             } else {
-              console.log('🆕 [DEBUG] 使用默认表单数据');
               // 使用 initFormData,确保新增模式默认填入"下个月"而不是当前月
               this.initFormData()
             }
 
             // 如果是编辑模式且有ID,则加载详情数据
             if (this.isEdit && this.formData.id) {
-              console.log('✏️ [DEBUG] 编辑模式,加载详情数据');
               this.loadForecastDetail(this.formData.id)
             }
 
             // 如果不是编辑模式,则生成预测编码
             if (!this.isEdit && !this.formData.forecastCode) {
             //   this.generateForecastCode()
-              console.log('🔢 [DEBUG] 新增模式,生成预测编码(已注释)');
             }
 
             // 新增模式下,自动获取并填充客户信息
             if (!this.isEdit) {
-              console.log('👤 [DEBUG] 新增模式,加载客户信息');
               this.loadCurrentCustomerInfo()
-            } else {
-              console.log('✏️ [DEBUG] 编辑模式,跳过客户信息加载');
             }
 
             // 新增模式下进行年月预测存在性检查(默认年月)
@@ -406,7 +395,6 @@ export default {
             }
           })
         } else {
-          console.log('❌ [DEBUG] 表单隐藏');
           // 弹窗关闭:编辑态下清空选择,防止跨会话污染
           if (this.isEdit) {
             this.selectedRowKeys = []
@@ -426,7 +414,6 @@ export default {
      * @this {ForecastFormMixinComponent & Vue}
      */
     initialFormData(/** @type {ForecastFormModel} */ val) {
-      console.log('📋 [DEBUG] initialFormData 变化:', { val, hasValue: !!val });
       if (val) {
         this.formData = this.cleanAndFormatFormData(val)
       }
@@ -442,13 +429,6 @@ export default {
        * @param {ForecastFormModel} newData
        */
       handler(/** @type {ForecastFormModel} */ newData) {
-        console.log('📝 [DEBUG] editData 变化:', {
-          newData,
-          hasData: !!newData,
-          isEdit: this.isEdit,
-          newDataKeys: newData ? Object.keys(newData) : []
-        });
-
         if (newData && this.isEdit) {
           this.formData = {
             ...newData,
@@ -544,21 +524,6 @@ export default {
         }
       },
       immediate: true
-    },
-
-    /**
-     * 监听物料选项变化
-     * @param {Array} val - 新的物料选项数组
-     * @this {ForecastFormMixinComponent & Vue}
-     */
-    stockSelectOptions: {
-      handler(/** @type {Array} */ val) {
-        console.log('📋 [DEBUG] stockSelectOptions 变化:', {
-          length: val?.length,
-          options: val?.slice(0, 3) // 只显示前3个,避免console过长
-        });
-      },
-      immediate: true
     }
   },
 
@@ -567,12 +532,6 @@ export default {
    * @this {ForecastFormMixinComponent & Vue}
    */
   created() {
-    console.log('🏗️ [DEBUG] 组件 created 生命周期:', {
-      isEdit: this.isEdit,
-      hasEditData: !!this.editData,
-      props: this.$props
-    });
-
     this.initFormOption()
     this.initFormData()
   },
@@ -629,11 +588,8 @@ export default {
           }
         })
 
-        console.log('materialMap', materialMap)
         // 过滤掉已在表格中的物料
         return source.filter(item => {
-          console.log('item', item)
-          console.log('materialMap', materialMap)
           if (item?.id != null && materialMap.has(`id:${String(item.id)}`)) return false
           if (item?.goodsId != null && materialMap.has(`goods:${String(item.goodsId)}`)) return false
           if (item?.code && materialMap.has(`code:${String(item.code)}`)) return false
@@ -865,45 +821,27 @@ export default {
      * @returns {Promise<void>}
      */
     async loadCurrentCustomerInfo() {
-      console.log('👤 [DEBUG] loadCurrentCustomerInfo 开始执行')
-      console.log('🔧 [DEBUG] 当前模式:', this.isEdit ? '编辑模式' : '新增模式');
-
       try {
-        console.log('📡 [DEBUG] 正在调用 getCustomerInfo API');
         const response = await getCustomerInfo()
         const ok = response && response.data && response.data.success
         const data = ok ? response.data.data : null
-
-        console.log('📦 [DEBUG] 客户信息API返回:', { ok, data });
-
         if (ok && data) {
           // 根据接口common.d.ts中的CustomerInfoData结构进行赋值
           this.formData.customerId = data.Customer_ID ? data.Customer_ID.toString() : null
           this.formData.customerCode = data.Customer_CODE || ''
           this.formData.customerName = data.Customer_NAME || ''
-          console.log('✅ [DEBUG] 客户信息设置完成:', this.formData);
         }
       } catch (e) {
         console.error('获取客户信息失败:', e)
       } finally {
         // 新增模式下,无论客户信息是否获取成功,都应确保物料明细加载一次。
         // 使用表格是否为空作为幂等保护,避免重复加载。
-        console.log('🔍 [DEBUG] 检查是否需要加载物料:', {
-          isEdit: this.isEdit,
-          stockTableDataLength: this.stockTableData?.length,
-          isArray: Array.isArray(this.stockTableData)
-        });
-
         if (!this.isEdit && Array.isArray(this.stockTableData) && this.stockTableData.length === 0) {
-          console.log('📋 [DEBUG] 条件满足,调用 loadUserLinkGoods');
           try {
             await this.loadUserLinkGoods()
           } catch (err) {
             // loadUserLinkGoods 内部已做错误提示,这里静默即可
-            console.error('❌ [DEBUG] loadUserLinkGoods 调用失败:', err)
           }
-        } else {
-          console.log('⏭️ [DEBUG] 跳过 loadUserLinkGoods,条件不满足');
         }
       }
     },
@@ -1028,16 +966,8 @@ export default {
      * @this {ForecastFormMixinComponent & Vue}
      */
     initFormData() {
-      console.log('🔧 [DEBUG] initFormData 执行:', {
-        isEdit: this.isEdit,
-        hasEditData: !!this.editData,
-        editDataId: this.editData?.id,
-        formDataId: this.formData?.id
-      });
-
       if (this.isEdit && this.editData) {
         // 编辑模式:使用传入的数据,确保year字段为字符串格式
-        console.log('✏️ [DEBUG] 使用编辑模式初始化数据');
         this.formData = {
           ...this.editData,
           year: this.editData.year ? this.editData.year.toString() : ''
@@ -1155,7 +1085,6 @@ export default {
         // 先结束 Avue 内置的按钮loading,避免未调用 done 导致一直loading
         if (typeof done === 'function') done()
 
-            console.log(this.formData)
         // 采用旧实现风格:通过 this.$refs.forecastForm.validate 回调进行校验
         if (this.$refs && this.$refs.forecastForm && typeof this.$refs.forecastForm.validate === 'function') {
           this.$refs.forecastForm.validate((valid) => {
@@ -1169,9 +1098,7 @@ export default {
                   console.groupEnd && console.groupEnd()
                 }
               }
-              // 校验失败时,如存在 loading 回调(部分版本提供),尝试恢复按钮状态
               if (typeof loading === 'function') loading()
-              // 通知父组件校验失败,便于父侧重置保存按钮loading
               this.$emit && this.$emit(FORECAST_FORM_EVENTS.SUBMIT_ERROR, { message: '表单校验未通过' })
               return
             }
@@ -1355,7 +1282,6 @@ export default {
      * @this {ForecastFormMixinComponent & Vue}
      */
     async loadUserLinkGoods() {
-      console.log('🚀 [DEBUG] loadUserLinkGoods 开始执行')
       try {
         this.tableLoading = true
         // 初始化容器
@@ -1367,26 +1293,17 @@ export default {
         // 重置选择状态
         this.selectedRowKeys = []
 
-        console.log('📡 [DEBUG] 正在调用 getUserLinkGoods API')
         const res = await getUserLinkGoods()
         const payload = res && res.data && res.data.data ? res.data.data : null
         const brandList = (payload && payload.pjpfBrandDescList) || []
         const stockList = (payload && payload.pjpfStockDescList) || []
 
-        console.log('📦 [DEBUG] API返回数据:', {
-          brandCount: brandList.length,
-          stockCount: stockList.length,
-          payload: payload
-        })
-
         this.brandDescList = brandList
         // 存储库存列表供选择用,不直接展示到表格
         this.stockDescList = stockList
         // 默认显示全部物料至下方表格,预测数量默认 1,用户可手动删除不需要的物料
         this.stockTableData = stockList.map(item => ({ ...item, forecastQuantity: 1 }))
 
-        console.log('📋 [DEBUG] 设置表格数据后,stockTableData长度:', this.stockTableData.length)
-
         // 根据表格中已有的物料,过滤下拉选项
         this.updateStockSelectOptions()
         // 规范化分页并回显选择(新增模式首次加载)
@@ -1396,7 +1313,6 @@ export default {
         this.$message.error(e.message || '加载用户关联商品失败')
       } finally {
         this.tableLoading = false
-        console.log('✅ [DEBUG] loadUserLinkGoods 执行完成')
       }
     },
 
@@ -1561,17 +1477,11 @@ export default {
      * @returns {void}
      */
     updateStockSelectOptions() {
-      console.log('🔄 [DEBUG] updateStockSelectOptions 被调用')
-      console.log('📊 [DEBUG] stockTableData 长度:', this.stockTableData?.length)
-      console.log('📊 [DEBUG] stockDescList 长度:', this.stockDescList?.length)
-
       try {
         // 使用优化的过滤算法
         const options = this.optimizeStockSelectOptions(this.stockTableData, this.stockDescList)
         this.stockSelectOptions = options
 
-        console.log('✅ [DEBUG] 过滤后的选项数量:', options.length)
-
         // 如果当前选中不在可选项中,则清空
         const hasSelected = options.some(opt => opt && opt.value === this.selectedStockId)
         if (!hasSelected) {
@@ -1721,27 +1631,18 @@ export default {
      * @returns {Promise<void>}
      */
     async mergeEchoStoreInventory() {
-      console.log('🔄 [DEBUG] mergeEchoStoreInventory 开始执行');
       try {
         if (!Array.isArray(this.stockTableData) || this.stockTableData.length === 0) {
-          console.log('⏭️ [DEBUG] 表格数据为空,跳过库存合并');
           return
         }
 
-        console.log('📡 [DEBUG] 调用 getUserLinkGoods API');
         const res = await getUserLinkGoods()
         const payload = res && res.data && res.data.data ? res.data.data : null
         const stockList = (payload && payload.pjpfStockDescList) || []
         if (!Array.isArray(stockList) || stockList.length === 0) {
-          console.log('⚠️ [DEBUG] API返回的物料列表为空');
           return
         }
 
-        console.log('📦 [DEBUG] 获取到物料列表:', {
-          stockCount: stockList.length,
-          tableCount: this.stockTableData.length
-        });
-
         // 在编辑模式下,确保"导入物料"的选择器有数据可选
         // 不修改现有表格数据,仅补齐选择来源
         this.stockDescList = stockList
@@ -1749,8 +1650,6 @@ export default {
         // ✅ 修复:使用优化的过滤方法,正确过滤已在表格中的物料
         this.updateStockSelectOptions()
 
-        console.log('✅ [DEBUG] 更新物料选择选项完成');
-
         // 构建基于 goodsId 与 code 的索引映射
         /** @type {Map<string, string|undefined>} */
         const invByGoodsId = new Map()
@@ -1773,8 +1672,6 @@ export default {
           const value = (fromGoods !== undefined && fromGoods !== null && fromGoods !== '') ? fromGoods : ((fromCode !== undefined && fromCode !== null && fromCode !== '') ? fromCode : '0')
           return { ...row, storeInventory: String(value) }
         })
-
-        console.log('✅ [DEBUG] 库存合并完成');
       } catch (e) {
         console.warn('回显库存合并失败:', e)
       }