diff --git a/src/pages/home/QuickSignInPage.vue b/src/pages/home/QuickSignInPage.vue index 35df740..0a80769 100644 --- a/src/pages/home/QuickSignInPage.vue +++ b/src/pages/home/QuickSignInPage.vue @@ -30,6 +30,16 @@ @status-change="handleScanStatusChange" /> + + + + + + ([]); const eventList = ref([]); const selectedOptionSelectionMap = reactive({}); @@ -243,8 +255,13 @@ const scanCode = ref(""); const scanStatus = ref("正在启动扫码预览"); const scannerSessionKey = ref(0); const matchedCustomer = ref(); +const registeredCustomerIdSet = new Set(); let latestDecodedText = ""; +watch(autoRegisterEnabled, value => { + Storage.setString(AutoRegisterStorageKey, value); +}); + async function handleDecodedText(rawText: string): Promise { const normalizedText = rawText.trim(); if (!normalizedText || normalizedText === latestDecodedText) { @@ -254,8 +271,16 @@ async function handleDecodedText(rawText: string): Promise { scanCode.value = normalizedText; await settingStore.playScanSuccessSound(); await loadCustomer(normalizedText); - if (matchedCustomer.value) { + const customer = matchedCustomer.value; + if (customer) { + if (customer.id && registeredCustomerIdSet.has(customer.id)) { + scanStatus.value = `客户 ${customer.name || customer.code || normalizedText} 已在本页面登记`; + return; + } scanStatus.value = `已识别 ${normalizedText},可直接登记`; + if (autoRegisterEnabled.value) { + await doSubmit(); + } return; } scanStatus.value = `已识别 ${normalizedText},但未匹配客户档案`; @@ -404,6 +429,14 @@ async function doSubmit(): Promise { if (!customer) { return; } + const customerId = customer.id; + if (!customerId) { + return; + } + if (registeredCustomerIdSet.has(customerId)) { + Message.warning("该客户已在本页面登记,请勿重复登记"); + return; + } if (!selectedEventIdList.value.length) { Message.warning("请至少选择一个登记事件"); return; @@ -425,12 +458,13 @@ async function doSubmit(): Promise { try { await EventRecordAPI.createBatch(selectedEventIdList.value.map(eventId => ({ eventId, - customerId: customer.id, + customerId, selectedOptionGroupList: resolveRecordOptionGroupList(eventId), numberValue: resolveNumberValue(eventId), remark: "客户快速扫码登记", attachmentList: buildPhotoAttachmentList() }))); + registeredCustomerIdSet.add(customerId); scanStatus.value = `登记成功:${customer.name || customer.code || scanCode.value}。`; scanCode.value = ""; matchedCustomer.value = undefined;