This commit is contained in:
@@ -187,7 +187,8 @@ export default {
|
||||
remark: '',
|
||||
|
||||
// 编辑模式
|
||||
editingOrderId: null
|
||||
editingOrderId: null,
|
||||
tempCustomerId: null // 临时保存编辑时的客户ID
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -195,7 +196,10 @@ export default {
|
||||
this.loadProducts()
|
||||
if (options.orderId) {
|
||||
this.editingOrderId = options.orderId
|
||||
// 编辑模式:等客户列表加载完成后再加载订单
|
||||
setTimeout(() => {
|
||||
this.loadOrder(options.orderId)
|
||||
}, 500)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -204,10 +208,8 @@ export default {
|
||||
const detail = await orderApi.getOrderDetail(orderId)
|
||||
const order = detail.order
|
||||
|
||||
// 设置订单信息
|
||||
if (order.customerId) {
|
||||
this.selectedCustomer = this.customers.find(c => c.customerId === order.customerId)
|
||||
}
|
||||
// 先保存 customerId,等 customers 加载完成后匹配
|
||||
this.tempCustomerId = order.customerId
|
||||
|
||||
this.orderItems = (detail.items || []).map(item => ({
|
||||
productId: item.productId,
|
||||
@@ -219,18 +221,29 @@ export default {
|
||||
}))
|
||||
|
||||
this.discountRate = order.discountRate
|
||||
this.discountMoney = order.discountMoney || 0
|
||||
this.remark = order.remark || ''
|
||||
this.paymentMethod = order.paymentMethod || 'cash'
|
||||
|
||||
this.calcAmount()
|
||||
|
||||
// 尝试匹配客户
|
||||
this.matchCustomer()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
matchCustomer() {
|
||||
if (this.tempCustomerId && this.customers.length > 0) {
|
||||
this.selectedCustomer = this.customers.find(c => c.customerId === this.tempCustomerId)
|
||||
}
|
||||
},
|
||||
async loadCustomers() {
|
||||
try {
|
||||
const res = await customerApi.getCustomers({ page: 1, pageSize: 100 })
|
||||
this.customers = res.records || []
|
||||
// 客户列表加载完成后,尝试匹配编辑订单的客户
|
||||
this.matchCustomer()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user