From 1613b54bc6d67e61ab3f4567393d2065a97839db Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Tue, 14 Apr 2026 20:20:18 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B2=BE=E6=B2=B9=E4=BB=B7=E7=9B=AE?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=8C=E6=99=BA=E8=83=BD=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E3=80=8D=EF=BC=8C=E7=B2=98=E8=B4=B4=E4=BA=A7=E5=93=81=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=85=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 识别优惠顾客价/零售价/规格/中英文名,自动切精油或其他产品 tab。 Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/views/OilReference.vue | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/frontend/src/views/OilReference.vue b/frontend/src/views/OilReference.vue index df6d129..2ab510c 100644 --- a/frontend/src/views/OilReference.vue +++ b/frontend/src/views/OilReference.vue @@ -110,6 +110,14 @@
+ +
+
+ +
+ + +
@@ -468,6 +476,56 @@ const activeCard = ref(null) // Add oil form const addType = ref('oil') +const showSmartPaste = ref(false) +const smartPasteText = ref('') +const OIL_VOLUMES = new Set(['2.5', '5', '10', '15', '115']) + +function runSmartPaste() { + const raw = smartPasteText.value || '' + if (!raw.trim()) return + const text = raw.replace(/[::]/g, ':').replace(/[¥¥]/g, '') + + const memberMatch = text.match(/(?:优惠顾客价|会员价|批发价)\s*:?\s*(\d+(?:\.\d+)?)/) + const retailMatch = text.match(/零售价\s*:?\s*(\d+(?:\.\d+)?)/) + const specMatch = text.match(/规格\s*:?\s*(\d+(?:\.\d+)?)\s*(毫升|ml|ML|克|g|G|颗|粒|片)/) + + let cn = '', en = '' + for (const line of raw.split(/\r?\n/)) { + const s = line.trim() + if (!s) continue + if (/优惠顾客价|会员价|零售价|点数|规格|PT\s*:|批发价/i.test(s)) continue + const m = s.match(/^([^A-Za-z]+?)\s+([A-Za-z].*)$/) + if (m) { cn = m[1].trim(); en = m[2].trim() } else { cn = s } + break + } + + if (memberMatch) newBottlePrice.value = Number(memberMatch[1]) + if (retailMatch) newRetailPrice.value = Number(retailMatch[1]) + if (cn) newOilName.value = cn + if (en) newOilEnName.value = en + + if (specMatch) { + const amount = specMatch[1] + const unitRaw = specMatch[2].toLowerCase() + const isMl = unitRaw === '毫升' || unitRaw === 'ml' + if (isMl && OIL_VOLUMES.has(String(Number(amount)))) { + addType.value = 'oil' + newVolume.value = String(Number(amount)) + newCustomDrops.value = null + } else { + addType.value = 'product' + newProductAmount.value = Number(amount) + newProductUnit.value = (unitRaw === '克' || unitRaw === 'g') ? 'g' + : (unitRaw === '颗' || unitRaw === '粒' || unitRaw === '片') ? 'capsule' + : 'ml' + } + } else { + addType.value = 'product' + } + + ui.showToast('已识别并填入,请检查后点添加') +} + const newOilName = ref('') const newOilEnName = ref('') const newBottlePrice = ref(null)