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

fix(订单): 修复客户数据回显问题并新增时清除客户数据

yz 1 hónapja
szülő
commit
70c038b09d
1 módosított fájl, 35 hozzáadás és 0 törlés
  1. 35 0
      src/views/order/lead/index.vue

+ 35 - 0
src/views/order/lead/index.vue

@@ -489,10 +489,45 @@ export default {
                 try {
                     const res = await getDetail(this.form.id)
                     this.form = res.data.data
+
+                    // 处理客户数据回显
+                    if (this.form.customerId) {
+                        // 检查当前客户是否在选项列表中
+                        const existingCustomer = this.customerOptions.find(option =>
+                            option.value === this.form.customerId ||
+                            option.customerId === this.form.customerId.toString()
+                        )
+
+
+                        // 如果客户不在选项列表中,添加当前客户到选项列表
+                        if (!existingCustomer && this.form.customerCode && this.form.customerName) {
+                            const currentCustomerOption = {
+                                value: this.form.customerId,
+                                label: `${this.form.customerCode} - ${this.form.customerName}`,
+                                customerCode: this.form.customerCode,
+                                customerName: this.form.customerName,
+                                customerId: this.form.customerId.toString()
+                            }
+
+                            // 将当前客户添加到选项列表开头
+                            // this.customerOptions.unshift(currentCustomerOption)
+
+                            // 更新表格配置中的选项数据
+                            await this.updateCustomerOptionsInColumn()
+                        }
+                        // 选中当前客户
+                        this.form.customerId = existingCustomer ? existingCustomer.value : this.form.customerId
+                        this.form.customerCode = existingCustomer ? existingCustomer.customerCode : this.form.customerCode
+                        this.form.customerName = existingCustomer ? existingCustomer.customerName : this.form.customerName
+                    }
                 } catch (error) {
                     console.error('获取详情失败:', error)
                 }
+            } else if (type === 'add') {
+                // 新增时清除客户相关数据
+                this.clearCustomerData()
             }
+
             done()
         },
         /**