|
@@ -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()
|
|
|
},
|
|
|
/**
|