diff --git a/frontend/src/views/desktop/CustomerManage.vue b/frontend/src/views/desktop/CustomerManage.vue index 0a6c5ba..c12c1dd 100644 --- a/frontend/src/views/desktop/CustomerManage.vue +++ b/frontend/src/views/desktop/CustomerManage.vue @@ -96,7 +96,21 @@ function resetForm() { existingContacts.value = [] } -function openCreate() { dialogTitle.value = '新建客户'; editId.value = ''; resetForm(); dialogVisible.value = true } +const duplicateHint = ref('') +async function checkName() { + if (!form.value.name || editId.value) { duplicateHint.value = ''; return } + try { + const res = await customersApi.checkDuplicate(form.value.name) + if (res.data?.exists) { + const dup = res.data.customers || [] + duplicateHint.value = `⚠ 已存在同名客户:${dup.map((c: any) => c.name + (c.primary_manager_name ? ` (${c.primary_manager_name})` : '')).join('、')}` + } else { + duplicateHint.value = '' + } + } catch (_) { duplicateHint.value = '' } +} + +function openCreate() { dialogTitle.value = '新建客户'; editId.value = ''; resetForm(); duplicateHint.value = ''; dialogVisible.value = true } async function openEdit(customer: any) { dialogTitle.value = '编辑客户'; editId.value = customer.id @@ -305,7 +319,7 @@ async function handleImport() { - +