feat: 精油价目新增「智能识别」,粘贴产品信息自动填充字段
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 7s
Test / build-check (push) Successful in 5s
PR Preview / test (pull_request) Successful in 6s
PR Preview / deploy-preview (pull_request) Successful in 25s
Test / e2e-test (push) Failing after 6m4s
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 7s
Test / build-check (push) Successful in 5s
PR Preview / test (pull_request) Successful in 6s
PR Preview / deploy-preview (pull_request) Successful in 25s
Test / e2e-test (push) Failing after 6m4s
识别优惠顾客价/零售价/规格/中英文名,自动切精油或其他产品 tab。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -110,6 +110,14 @@
|
||||
<div class="add-type-tabs">
|
||||
<button class="add-type-tab" :class="{ active: addType === 'oil' }" @click="addType = 'oil'">精油</button>
|
||||
<button class="add-type-tab" :class="{ active: addType === 'product' }" @click="addType = 'product'">其他</button>
|
||||
<button class="add-type-tab" :class="{ active: showSmartPaste }" @click="showSmartPaste = !showSmartPaste" style="margin-left:auto">🪄 智能识别</button>
|
||||
</div>
|
||||
<div v-if="showSmartPaste" class="form-row" style="flex-direction:column;align-items:stretch;gap:6px">
|
||||
<textarea v-model="smartPasteText" rows="4" class="form-input-sm" placeholder="粘贴产品信息,例如: 优惠顾客价:¥310 零售价:¥465 规格:100毫升 花样年华焕颜精华水 Salubelle Rejuvenating Essence" style="width:100%;resize:vertical;font-family:inherit"></textarea>
|
||||
<div style="display:flex;gap:8px">
|
||||
<button class="btn btn-primary btn-sm" @click="runSmartPaste" :disabled="!smartPasteText.trim()">识别并填入</button>
|
||||
<button class="btn btn-sm" @click="smartPasteText = ''">清空</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 新增精油 -->
|
||||
<div v-if="addType === 'oil'" class="form-row">
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user