Bladeren bron

refactor(订单): 提取清除客户数据逻辑到独立方法

yz 1 week geleden
bovenliggende
commit
7b5953aad4
1 gewijzigde bestanden met toevoegingen van 20 en 18 verwijderingen
  1. 20 18
      src/views/order/order/index.vue

+ 20 - 18
src/views/order/order/index.vue

@@ -309,31 +309,17 @@ export default {
               if (value) {
                 const selectedCustomer = this.customerOptions.find(option => option.value === value)
                 if (selectedCustomer) {
-                  // 自动填充客户名称
+                  // Auto-fill customer information
                   this.form.customerId = selectedCustomer.customerId
                   this.form.customerCode = selectedCustomer.customerCode
                   this.form.customerName = selectedCustomer.customerName
-                  // 加载客户地址
+                  // Load customer addresses
                   this.loadCustomerAddresses(value)
                 } else {
-                  this.form.customerName = ''
-                  this.form.customerId = ''
-                  this.addressOptions = []
-                  this.form.addressId = ''
-                  this.form.receiverName = ''
-                  this.form.receiverPhone = ''
-                  this.form.receiverAddress = ''
-                  this.form.receiverRegion = ''
+                  this.clearCustomerData()
                 }
               } else {
-                this.form.customerName = ''
-                this.form.customerId = ''
-                this.addressOptions = []
-                this.form.addressId = ''
-                this.form.receiverName = ''
-                this.form.receiverPhone = ''
-                this.form.receiverAddress = ''
-                this.form.receiverRegion = ''
+                this.clearCustomerData()
               }
             }
           },
@@ -761,6 +747,22 @@ export default {
     },
 
     /**
+     * 清除客户相关数据
+     * @returns {void}
+     */
+    clearCustomerData() {
+      this.form.customerName = ''
+      this.form.customerId = ''
+      this.addressOptions = []
+      this.form.addressId = ''
+      this.form.receiverName = ''
+      this.form.receiverPhone = ''
+      this.form.receiverAddress = ''
+      this.form.receiverRegion = ''
+      this.updateAddressOptions()
+    },
+
+    /**
      * 处理明细管理
      * @param {OrderItem} row - 订单行数据
      */