fix event record
This commit is contained in:
@@ -254,9 +254,9 @@ async function applyIntroducer(code: string): Promise<void> {
|
||||
const matched = await CustomerAPI.findByCode(code);
|
||||
if (!matched?.id) {
|
||||
formData.introducerCustomerId = "";
|
||||
formData.introducerCustomer = undefined;
|
||||
introducerCustomerId.value = "";
|
||||
scannerVisible.value = false;
|
||||
scannerVisible.value = false;
|
||||
Toast.warning(`未匹配到 ${code} 编码介绍人,请选择或扫码已有客户`);
|
||||
return;
|
||||
}
|
||||
@@ -267,8 +267,9 @@ async function applyIntroducer(code: string): Promise<void> {
|
||||
}
|
||||
|
||||
async function handleIntroducerChange(id: string): Promise<void> {
|
||||
const customer = await CustomerAPI.findById(id);
|
||||
introducerCustomerId.value = customer!.id!;
|
||||
const customer = id ? await CustomerAPI.findById(id) : undefined;
|
||||
introducerCustomerId.value = customer?.id || "";
|
||||
formData.introducerCustomerId = customer?.id || "";
|
||||
formData.introducerCustomer = customer;
|
||||
}
|
||||
|
||||
@@ -349,7 +350,7 @@ async function loadDetail() {
|
||||
Object.assign(formData, customer);
|
||||
formData.storeId = customer.storeId || formData.storeId;
|
||||
selectedAreas.value = normalizeBodyAreaValue(customer.conditioningPart);
|
||||
introducerCustomerId.value = customer.introducerCustomer?.id || "";
|
||||
introducerCustomerId.value = customer.introducerCustomerId || customer.introducerCustomer?.id || "";
|
||||
} catch (err) {
|
||||
console.warn("客户详情加载失败", err);
|
||||
Toast.error("客户详情加载失败");
|
||||
@@ -411,18 +412,23 @@ async function doSubmit(): Promise<void> {
|
||||
|
||||
isSubmitting.value = true;
|
||||
try {
|
||||
formData.conditioningPart = selectedAreas.value;
|
||||
formData.attachmentList = photoTempFileId.value ? [{
|
||||
const payload: Customer = { ...formData };
|
||||
payload.conditioningPart = selectedAreas.value;
|
||||
payload.introducerCustomerId = introducerCustomerId.value || "";
|
||||
payload.attachmentList = photoTempFileId.value ? [{
|
||||
attachType: "PHOTO",
|
||||
tempFileId: photoTempFileId.value
|
||||
}] : undefined;
|
||||
delete payload.introducerCustomer;
|
||||
|
||||
if (isCreateMode.value) {
|
||||
const id = await CustomerAPI.create(formData);
|
||||
await CustomerAPI.create(payload);
|
||||
Toast.success("创建成功");
|
||||
await router.replace(`/management/customers/${id}`);
|
||||
const redirect = String(route.query.redirect || "");
|
||||
await router.replace(redirect || "/management/customers");
|
||||
return;
|
||||
} else {
|
||||
await CustomerAPI.update(formData);
|
||||
await CustomerAPI.update(payload);
|
||||
Toast.success("保存成功");
|
||||
const redirect = String(route.query.redirect || "");
|
||||
if (redirect) {
|
||||
|
||||
Reference in New Issue
Block a user