16 Commits

Author SHA1 Message Date
eeb9b0aa88 feat: 通用单位系统 — drop/ml/g/capsule,去掉硬编码
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s
Test / e2e-test (push) Failing after 3m5s
unit字段支持4种值,所有显示自动适配:
- drop: 精油(滴/drop)
- ml: 液体产品(ml)
- g: 膏霜产品(g)
- capsule: 胶囊(颗/capsule)
新增产品选单位即可,无需改代码。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 16:10:36 +00:00
7bcb1d1a5b fix: 植物空胶囊全局显示"颗"(capsule),配方卡片/编辑器/价目统一
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 51s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:31:00 +00:00
371aa74c31 fix: 植物空胶囊详情显示每颗价格
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s
Test / e2e-test (push) Successful in 49s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:29:41 +00:00
395e837de8 fix: 精油详情面板重排 — 总容量(5ml/93滴)+会员每滴+零售每滴
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 52s
精油: 总容量(Xml/X滴) → 会员价 → 每滴价格 → 零售价 → 零售每滴价格
ml产品: 总容量(Xml) → 会员价 → 每ml价格
配方列表单位跟随产品类型

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:19:32 +00:00
7abc219659 fix: 精油价目恢复原始显示(每滴/每ml/每颗),ml产品用新显示
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 52s
精油: 总滴数 + 每滴价格 + 每ml价格(和之前一样)
植物空胶囊: /颗(和之前一样)
ml产品: 总容量Xml + 每ml价格(新)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:13:37 +00:00
9beddc387a fix: 精油详情去掉每ml价格行,只保留每滴价格
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 52s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:10:38 +00:00
b28b1c7f62 fix: 导出isMlUnit函数,修复精油价目页点击报错
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s
Test / e2e-test (push) Has been cancelled
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:07:41 +00:00
9f072e48f8 feat: ml产品全局适配 — 编辑器/价目/详情统一显示ml单位
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 6s
PR Preview / deploy-preview (pull_request) Successful in 13s
Test / e2e-test (push) Successful in 50s
- 编辑器: 表头改为"成分/用量/单价",每行显示对应单位(滴/ml)
- 精油价目: ml产品显示"总容量Xml"和"每ml价格",精油保持"每滴"
- 知识卡片/配方详情: 单位跟随产品类型
- 精油的"每ml价格"行对ml产品隐藏(已是ml单位)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:57:21 +00:00
a3bf13c58d feat: 护肤品用ml单位,精油用滴,通过unit字段区分
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 53s
- 后端: oils表新增unit列(drop/ml),API返回unit字段
- 前端: 根据unit='ml'显示ml单位,精油显示滴/drop
- 护肤品drop_count改为实际ml容量,成本按用量比例计算
  如玫瑰护手霜100ml ¥135,配方用30ml → 成本¥40.5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:48:11 +00:00
fba66b42c2 feat: 含护肤品的配方卡片显示容量(从备注提取ml/克,否则显示"调配")
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 50s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:42:42 +00:00
67d268bc92 feat: 非精油产品(drop_count=1)显示"份"而非"滴"
All checks were successful
Test / unit-test (push) Successful in 5s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Test / e2e-test (push) Successful in 54s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s
oils store新增 unitLabel/unitLabelPlural,根据 dropCount 判断:
- 精油(dropCount>1): 滴/drop
- 护肤品等(dropCount=1): 份/portion
影响: 配方卡片、个人配方、库存匹配、去重提示

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:25:41 +00:00
abc54f2d6a test: PR#29测试 — 拼音匹配扩展、viewer标签可见性
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 5s
Test / unit-test (push) Successful in 5s
PR Preview / teardown-preview (pull_request) Successful in 13s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 6s
Test / e2e-test (push) Successful in 51s
新增14个单元测试:
- 拼音匹配: mlk→麦卢卡、tx→檀香等11个用例
- viewer标签可见性: 只看自己diary标签、不看公共标签

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:43:15 +00:00
6d1ae6e682 fix: 补全88个精油名拼音映射,修复mlk无法匹配麦卢卡等问题
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 49s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:40:56 +00:00
1790ab3b44 fix: viewer只能看到和管理自己个人配方的标签,不显示公共库标签
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s
Test / e2e-test (push) Successful in 49s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:36:09 +00:00
36862a4dbe fix: 用户管理筛选去掉管理员加企业用户,管理员不可换角色和删除
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 49s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:19:58 +00:00
eae9d507f2 fix: 商业认证图标逻辑反转 — 认证用户点亮,未认证灰色
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 8s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 14s
Test / e2e-test (push) Successful in 53s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:17:25 +00:00
12 changed files with 284 additions and 56 deletions

View File

@@ -227,6 +227,8 @@ def init_db():
c.execute("ALTER TABLE oils ADD COLUMN is_active INTEGER DEFAULT 1")
if "en_name" not in oil_cols:
c.execute("ALTER TABLE oils ADD COLUMN en_name TEXT DEFAULT ''")
if "unit" not in oil_cols:
c.execute("ALTER TABLE oils ADD COLUMN unit TEXT DEFAULT 'drop'")
# Migration: add new columns to category_modules if missing
cat_cols = [row[1] for row in c.execute("PRAGMA table_info(category_modules)").fetchall()]

View File

@@ -87,6 +87,7 @@ class OilIn(BaseModel):
retail_price: Optional[float] = None
en_name: Optional[str] = None
is_active: Optional[int] = None
unit: Optional[str] = None
class IngredientIn(BaseModel):
@@ -715,7 +716,7 @@ def impersonate(body: dict, user=Depends(require_role("admin"))):
@app.get("/api/oils")
def list_oils():
conn = get_db()
rows = conn.execute("SELECT name, bottle_price, drop_count, retail_price, is_active, en_name FROM oils ORDER BY name").fetchall()
rows = conn.execute("SELECT name, bottle_price, drop_count, retail_price, is_active, en_name, unit FROM oils ORDER BY name").fetchall()
conn.close()
return [dict(r) for r in rows]
@@ -724,11 +725,11 @@ def list_oils():
def upsert_oil(oil: OilIn, user=Depends(require_role("admin", "senior_editor"))):
conn = get_db()
conn.execute(
"INSERT INTO oils (name, bottle_price, drop_count, retail_price, en_name, is_active) VALUES (?, ?, ?, ?, ?, ?) "
"INSERT INTO oils (name, bottle_price, drop_count, retail_price, en_name, is_active, unit) VALUES (?, ?, ?, ?, ?, ?, ?) "
"ON CONFLICT(name) DO UPDATE SET bottle_price=excluded.bottle_price, drop_count=excluded.drop_count, "
"retail_price=excluded.retail_price, en_name=COALESCE(excluded.en_name, oils.en_name), "
"is_active=COALESCE(excluded.is_active, oils.is_active)",
(oil.name, oil.bottle_price, oil.drop_count, oil.retail_price, title_case(oil.en_name) if oil.en_name else oil.en_name, oil.is_active),
"is_active=COALESCE(excluded.is_active, oils.is_active), unit=COALESCE(excluded.unit, oils.unit)",
(oil.name, oil.bottle_price, oil.drop_count, oil.retail_price, title_case(oil.en_name) if oil.en_name else oil.en_name, oil.is_active, oil.unit),
)
log_audit(conn, user["id"], "upsert_oil", "oil", oil.name, oil.name,
json.dumps({"bottle_price": oil.bottle_price, "drop_count": oil.drop_count}))

View File

@@ -1,5 +1,6 @@
import { describe, it, expect } from 'vitest'
import { recipeNameEn, oilEn } from '../composables/useOilTranslation'
import { matchesPinyinInitials, getPinyinInitials } from '../composables/usePinyinMatch'
// ---------------------------------------------------------------------------
// EDITOR_ONLY_TAGS includes '已下架'
@@ -283,3 +284,95 @@ describe('one-time username change guard', () => {
expect(!!user.username_changed).toBe(false)
})
})
// ---------------------------------------------------------------------------
// Pinyin matching — PR29 extended coverage
// ---------------------------------------------------------------------------
describe('pinyin matching — extended oil names', () => {
it('matches mlk → 麦卢卡', () => {
expect(matchesPinyinInitials('麦卢卡', 'mlk')).toBe(true)
})
it('matches tx → 檀香', () => {
expect(matchesPinyinInitials('檀香', 'tx')).toBe(true)
})
it('matches xm → 香茅', () => {
expect(matchesPinyinInitials('香茅', 'xm')).toBe(true)
})
it('matches gbxz → 古巴香脂', () => {
expect(matchesPinyinInitials('古巴香脂', 'gbxz')).toBe(true)
})
it('matches my → 没药', () => {
expect(matchesPinyinInitials('没药', 'my')).toBe(true)
})
it('matches xhx → 小茴香', () => {
expect(matchesPinyinInitials('小茴香', 'xhx')).toBe(true)
})
it('matches jybh → 椒样薄荷', () => {
expect(matchesPinyinInitials('椒样薄荷', 'jybh')).toBe(true)
})
it('matches xbynz → 西班牙牛至', () => {
expect(matchesPinyinInitials('西班牙牛至', 'xbynz')).toBe(true)
})
it('matches sc → 顺畅呼吸 prefix', () => {
expect(matchesPinyinInitials('顺畅呼吸', 'sc')).toBe(true)
})
it('does not match wrong initials', () => {
expect(matchesPinyinInitials('麦卢卡', 'abc')).toBe(false)
})
it('getPinyinInitials returns correct string', () => {
expect(getPinyinInitials('麦卢卡')).toBe('mlk')
expect(getPinyinInitials('檀香')).toBe('tx')
expect(getPinyinInitials('没药')).toBe('my')
})
})
// ---------------------------------------------------------------------------
// Viewer tag visibility — PR29
// ---------------------------------------------------------------------------
describe('viewer tag visibility logic', () => {
const EDITOR_ONLY_TAGS_VAL = ['已审核', '已下架']
it('editor sees all tags', () => {
const allTags = ['美容', '儿童', '已审核', '已下架']
const canEdit = true
const visible = canEdit ? allTags : []
expect(visible).toEqual(allTags)
})
it('viewer sees no public tags', () => {
const canEdit = false
const myDiary = [
{ tags: ['我的标签'] },
{ tags: ['我的标签', '另一个'] },
]
// Viewer: collect tags from own diary only
const myTags = new Set()
for (const d of myDiary) {
for (const t of (d.tags || [])) myTags.add(t)
}
const visible = canEdit ? ['美容', '已审核'] : [...myTags]
expect(visible).toContain('我的标签')
expect(visible).toContain('另一个')
expect(visible).not.toContain('美容')
expect(visible).not.toContain('已审核')
})
it('viewer with no diary tags sees empty', () => {
const myDiary = []
const myTags = new Set()
for (const d of myDiary) {
for (const t of (d.tags || [])) myTags.add(t)
}
expect([...myTags]).toHaveLength(0)
})
})

View File

@@ -50,11 +50,21 @@ const isFav = computed(() => recipesStore.isFavorite(props.recipe))
const volumeLabel = computed(() => {
const ings = props.recipe.ingredients || []
const coco = ings.find(i => i.oil === '椰子油')
if (!coco || !coco.drops) return ''
const totalDrops = ings.reduce((s, i) => s + (i.drops || 0), 0)
const ml = totalDrops / 18.6
if (ml <= 2) return '单次'
return `${Math.round(ml)}ml`
if (coco && coco.drops) {
const totalDrops = ings.reduce((s, i) => s + (i.drops || 0), 0)
const ml = totalDrops / 18.6
if (ml <= 2) return '单次'
return `${Math.round(ml)}ml`
}
// Non-coconut: check if has portion product, extract volume from note
const hasPortion = ings.some(i => oilsStore.isPortionUnit(i.oil))
if (hasPortion) {
const note = props.recipe.note || ''
const m = note.match(/(\d+)\s*(ml|毫升|克|g)/i)
if (m) return `${m[1]}${m[2].toLowerCase()}`
return '调配'
}
return ''
})
</script>

View File

@@ -64,7 +64,7 @@
<ul style="list-style:none;margin-bottom:20px;padding:0">
<li v-for="(ing, i) in cardIngredients" :key="i" class="ec-ing">
<span class="ec-oil-name">{{ getCardOilName(ing.oil) }}</span>
<span class="ec-drops">{{ ing.drops }} {{ cardLang === 'en' ? (ing.drops === 1 ? 'drop' : 'drops') : '滴' }}</span>
<span class="ec-drops">{{ ing.drops }} {{ oilsStore.unitLabelPlural(ing.oil, ing.drops, cardLang) }}</span>
<span class="ec-cost">{{ oilsStore.fmtPrice(oilsStore.pricePerDrop(ing.oil) * ing.drops) }}</span>
<span v-if="hasRetailForOil(ing.oil) && retailPerDrop(ing.oil) > oilsStore.pricePerDrop(ing.oil)" class="ec-retail">{{ oilsStore.fmtPrice(retailPerDrop(ing.oil) * ing.drops) }}</span>
</li>
@@ -170,7 +170,7 @@
<div class="editor-section">
<table class="editor-table">
<thead>
<tr><th>精油</th><th>滴数</th><th>单价/</th><th>小计</th><th></th></tr>
<tr><th>成分</th><th>用量</th><th>单价</th><th>小计</th><th></th></tr>
</thead>
<tbody>
<tr v-for="(ing, i) in editEoIngredients" :key="'eo-'+i">
@@ -180,8 +180,13 @@
<option v-for="name in oilsStore.oilNames" :key="name" :value="name">{{ name }}</option>
</select>
</td>
<td><input v-model.number="ing.drops" type="number" min="0.5" step="0.5" class="editor-drops" /></td>
<td class="ing-ppd">{{ ing.oil ? oilsStore.fmtPrice(oilsStore.pricePerDrop(ing.oil)) : '-' }}</td>
<td>
<div class="drops-with-unit">
<input v-model.number="ing.drops" type="number" min="0.5" step="0.5" class="editor-drops" />
<span class="unit-hint">{{ oilsStore.unitLabel(ing.oil) }}</span>
</div>
</td>
<td class="ing-ppd">{{ ing.oil ? oilsStore.fmtPrice(oilsStore.pricePerDrop(ing.oil)) : '-' }}/{{ oilsStore.unitLabel(ing.oil) }}</td>
<td class="ing-cost">{{ ing.oil ? oilsStore.fmtPrice(oilsStore.pricePerDrop(ing.oil) * (ing.drops || 0)) : '-' }}</td>
<td><button class="remove-row-btn" @click="editIngredients.splice(editIngredients.indexOf(ing), 1)"></button></td>
</tr>
@@ -1703,6 +1708,8 @@ async function saveRecipe() {
.editor-drops:focus {
border-color: var(--sage, #7a9e7e);
}
.drops-with-unit { display: flex; align-items: center; gap: 2px; }
.unit-hint { font-size: 11px; color: #b0aab5; white-space: nowrap; }
.ing-ppd {
font-size: 12px;

View File

@@ -57,6 +57,25 @@ const PINYIN_MAP = {
'触': 'c', '修': 'x', '养': 'y', '滋': 'z', '润': 'r',
'呼': 'h', '吸': 'x', '消': 'x', '化': 'h', '排': 'p',
'毒': 'd', '净': 'j', '纤': 'x', '体': 't', '塑': 's',
// Extended: all oil name chars
'麦': 'm', '卢': 'l', '卡': 'k', '檀': 't', '橘': 'j',
'茅': 'm', '茴': 'h', '芹': 'q', '菜': 'c', '蕾': 'l',
'蜂': 'f', '蓍': 's', '莱': 'l', '姆': 'm', '莎': 's',
'穗': 's', '醇': 'c', '郁': 'y', '没': 'm', '脂': 'z',
'巴': 'b', '样': 'y', '班': 'b', '牙': 'y', '鸡': 'j',
'苍': 'c', '卫': 'w', '畅': 'c', '顺': 's', '释': 's',
'悦': 'y', '柔': 'r', '压': 'y', '定': 'd', '情': 'q',
'绪': 'x', '神': 's', '气': 'q', '宽': 'k', '容': 'r',
'恬': 't', '家': 'j', '欢': 'h', '欣': 'x', '舞': 'w',
'鼓': 'g', '赋': 'f', '谧': 'm', '睡': 's', '烂': 'l',
'绚': 'x', '焕': 'h', '肤': 'f', '年': 'n', '华': 'h',
'完': 'w', '理': 'l', '注': 'z', '贯': 'g', '全': 'q',
'仕': 's', '女': 'nv', '伯': 'b', '斯': 's', '道': 'd',
'格': 'g', '拉': 'l', '元': 'y', '肌': 'j', '栀': 'z',
'鹅': 'e', '掌': 'z', '柴': 'c', '胶': 'j', '囊': 'n',
'空': 'k', '风': 'f', '文': 'w', '月': 'y', '云': 'y',
'五': 'w', '味': 'w', '愈': 'y', '创': 'c', '慰': 'w',
'扁': 'b', '广': 'g', '州': 'z', '热': 'r',
}
/**

View File

@@ -70,6 +70,7 @@ export const useOilsStore = defineStore('oils', () => {
retailPrice: oil.retail_price ?? null,
isActive: oil.is_active !== 0,
enName: oil.en_name ?? null,
unit: oil.unit || 'drop',
}
}
oils.value = newOils
@@ -93,6 +94,41 @@ export const useOilsStore = defineStore('oils', () => {
delete oilsMeta.value[name]
}
const UNIT_LABELS = {
drop: { zh: '滴', en: 'drop', enPlural: 'drops' },
ml: { zh: 'ml', en: 'ml', enPlural: 'ml' },
g: { zh: 'g', en: 'g', enPlural: 'g' },
capsule: { zh: '颗', en: 'capsule', enPlural: 'capsules' },
}
function getUnit(name) {
const meta = oilsMeta.value[name]
return (meta && meta.unit) || 'drop'
}
function isDropUnit(name) {
return getUnit(name) === 'drop'
}
function isMlUnit(name) {
return getUnit(name) === 'ml'
}
function isPortionUnit(name) {
return !isDropUnit(name)
}
function unitLabel(name, lang = 'zh') {
const u = UNIT_LABELS[getUnit(name)] || UNIT_LABELS.drop
return lang === 'en' ? u.en : u.zh
}
function unitLabelPlural(name, count, lang = 'zh') {
const u = UNIT_LABELS[getUnit(name)] || UNIT_LABELS.drop
if (lang === 'en') return count === 1 ? u.en : u.enPlural
return u.zh
}
return {
oils,
oilsMeta,
@@ -105,5 +141,11 @@ export const useOilsStore = defineStore('oils', () => {
loadOils,
saveOil,
deleteOil,
getUnit,
isDropUnit,
isMlUnit,
isPortionUnit,
unitLabel,
unitLabelPlural,
}
})

View File

@@ -76,7 +76,7 @@
class="match-ing"
:class="{ missing: !ownedSet.has(ing.oil) }"
>
{{ ing.oil }} {{ ing.drops }}
{{ ing.oil }} {{ ing.drops }}{{ oils.unitLabel(ing.oil) }}
</span>
</div>
<div class="match-meta">

View File

@@ -31,7 +31,7 @@
<div class="diary-name">{{ d.name || '未命名' }}</div>
<div class="diary-ings">
<span v-for="ing in (d.ingredients || []).slice(0, 3)" :key="ing.oil" class="diary-ing">
{{ ing.oil }} {{ ing.drops }}
{{ ing.oil }} {{ ing.drops }}{{ oils.unitLabel(ing.oil) }}
</span>
<span v-if="(d.ingredients || []).length > 3" class="diary-more">+{{ (d.ingredients || []).length - 3 }}</span>
</div>

View File

@@ -146,9 +146,9 @@
<div v-if="getMeta(name)?.retailPrice" class="oil-retail-line">¥{{ getMeta(name).retailPrice }}/</div>
</template>
<template v-else>
<div class="oil-price-line">¥{{ oils.pricePerDrop(name).toFixed(2) }}<span class="oil-price-unit">{{ name === '植物空胶囊' ? '/颗' : '/滴' }}</span></div>
<div class="oil-price-line">¥{{ oils.pricePerDrop(name).toFixed(2) }}<span class="oil-price-unit">/{{ oilPriceUnit(name) }}</span></div>
<div v-if="getMeta(name)?.retailPrice && getMeta(name)?.dropCount" class="oil-retail-line">
¥{{ (getMeta(name).retailPrice / getMeta(name).dropCount).toFixed(2) }}{{ name === '植物空胶囊' ? '/' : '/' }}
¥{{ (getMeta(name).retailPrice / getMeta(name).dropCount).toFixed(2) }}/{{ oilPriceUnit(name) }}
</div>
</template>
</div>
@@ -172,7 +172,7 @@
<div class="oil-card-price-info" v-if="getMeta(activeCardName)">
¥ {{ (getMeta(activeCardName).bottlePrice || 0).toFixed(2) }}
<span v-if="oils.pricePerDrop(activeCardName)">
&middot; ¥ {{ oils.pricePerDrop(activeCardName).toFixed(4) }}/
&middot; ¥ {{ oils.pricePerDrop(activeCardName).toFixed(4) }}/{{ oilPriceUnit(activeCardName) }}
</span>
</div>
</div>
@@ -226,32 +226,58 @@
<button class="btn-close" @click="selectedOilName = null"></button>
</div>
<div class="detail-body">
<div class="detail-row">
<span class="detail-label">会员价</span>
<span class="detail-value">{{ getMeta(selectedOilName)?.bottlePrice != null ? ('¥ ' + getMeta(selectedOilName).bottlePrice.toFixed(2)) : '--' }}</span>
</div>
<div class="detail-row">
<span class="detail-label">总滴数</span>
<span class="detail-value">{{ getMeta(selectedOilName)?.dropCount || '--' }}</span>
</div>
<div class="detail-row">
<span class="detail-label">每滴价格</span>
<span class="detail-value">{{ oils.pricePerDrop(selectedOilName) ? ('¥ ' + oils.pricePerDrop(selectedOilName).toFixed(4)) : '--' }}</span>
</div>
<div class="detail-row" v-if="getMeta(selectedOilName)?.retailPrice">
<span class="detail-label">零售价</span>
<span class="detail-value">¥ {{ getMeta(selectedOilName).retailPrice.toFixed(2) }}</span>
</div>
<div class="detail-row">
<span class="detail-label">每ml价格</span>
<span class="detail-value">{{ oils.pricePerDrop(selectedOilName) ? ('¥ ' + (oils.pricePerDrop(selectedOilName) * DROPS_PER_ML).toFixed(2)) : '--' }}</span>
</div>
<!-- 精油非ml产品 -->
<template v-if="oils.isDropUnit(selectedOilName)">
<div class="detail-row">
<span class="detail-label">总容量</span>
<span class="detail-value">{{ volumeWithDrops(selectedOilName) }}</span>
</div>
<div class="detail-row">
<span class="detail-label">会员价</span>
<span class="detail-value">{{ getMeta(selectedOilName)?.bottlePrice != null ? ('¥ ' + getMeta(selectedOilName).bottlePrice.toFixed(2)) : '--' }}</span>
</div>
<div class="detail-row">
<span class="detail-label">{{ oilPriceUnit(selectedOilName) }}价格</span>
<span class="detail-value">{{ oils.pricePerDrop(selectedOilName) ? ('¥ ' + oils.pricePerDrop(selectedOilName).toFixed(4)) : '--' }}</span>
</div>
<div class="detail-row" v-if="getMeta(selectedOilName)?.retailPrice">
<span class="detail-label">零售价</span>
<span class="detail-value">¥ {{ getMeta(selectedOilName).retailPrice.toFixed(2) }}</span>
</div>
<div class="detail-row" v-if="getMeta(selectedOilName)?.retailPrice && getMeta(selectedOilName)?.dropCount">
<span class="detail-label">{{ oilPriceUnit(selectedOilName) }}价格</span>
<span class="detail-value">¥ {{ (getMeta(selectedOilName).retailPrice / getMeta(selectedOilName).dropCount).toFixed(4) }}</span>
</div>
</template>
<!-- ml产品 -->
<template v-else>
<div class="detail-row">
<span class="detail-label">总容量</span>
<span class="detail-value">{{ getMeta(selectedOilName)?.dropCount || '--' }}{{ oils.unitLabel(selectedOilName) }}</span>
</div>
<div class="detail-row">
<span class="detail-label">会员价</span>
<span class="detail-value">{{ getMeta(selectedOilName)?.bottlePrice != null ? ('¥ ' + getMeta(selectedOilName).bottlePrice.toFixed(2)) : '--' }}</span>
</div>
<div class="detail-row">
<span class="detail-label">{{ oils.unitLabel(selectedOilName) }}价格</span>
<span class="detail-value">{{ oils.pricePerDrop(selectedOilName) ? ('¥ ' + oils.pricePerDrop(selectedOilName).toFixed(2)) : '--' }}</span>
</div>
<div class="detail-row" v-if="getMeta(selectedOilName)?.retailPrice">
<span class="detail-label">零售价</span>
<span class="detail-value">¥ {{ getMeta(selectedOilName).retailPrice.toFixed(2) }}</span>
</div>
<div class="detail-row" v-if="getMeta(selectedOilName)?.retailPrice && getMeta(selectedOilName)?.dropCount">
<span class="detail-label">{{ oils.unitLabel(selectedOilName) }}价格</span>
<span class="detail-value">¥ {{ (getMeta(selectedOilName).retailPrice / getMeta(selectedOilName).dropCount).toFixed(2) }}</span>
</div>
</template>
<h4 style="margin:16px 0 8px">含此精油的配方</h4>
<h4 style="margin:16px 0 8px">含此{{ oils.isDropUnit(selectedOilName) ? '精油' : '产品' }}的配方</h4>
<div v-if="recipesWithOil.length" class="detail-recipes">
<div v-for="r in recipesWithOil" :key="r._id" class="detail-recipe-item">
<span class="dr-name">{{ r.name }}</span>
<span class="dr-drops">{{ getDropsForOil(r, selectedOilName) }}</span>
<span class="dr-drops">{{ getDropsForOil(r, selectedOilName) }}{{ oils.unitLabel(selectedOilName) }}</span>
</div>
</div>
<div v-else class="empty-hint">暂无使用此精油的配方</div>
@@ -472,11 +498,24 @@ for (const [ml, drops] of Object.entries(VOLUME_OPTIONS)) {
DROPS_TO_VOLUME[drops] = ml + 'ml'
}
function oilPriceUnit(name) {
return oils.unitLabel(name)
}
function volumeLabel(dropCount, name) {
if (dropCount === 160) return '160颗'
if (!oils.isDropUnit(name)) return dropCount + oils.unitLabel(name)
return DROPS_TO_VOLUME[dropCount] || (dropCount + '滴')
}
function volumeWithDrops(name) {
const meta = getMeta(name)
if (!meta || !meta.dropCount) return '--'
if (!oils.isDropUnit(name)) return meta.dropCount + oils.unitLabel(name)
const ml = DROPS_TO_VOLUME[meta.dropCount]
if (ml) return `${ml}/${meta.dropCount}`
return meta.dropCount + '滴'
}
function chipStyle(name) {
const hasCard = !!getOilCard(name)
if (hasCard) return 'cursor:pointer;border-left:3px solid var(--sage);background:linear-gradient(90deg,var(--sage-mist),white)'

View File

@@ -83,7 +83,7 @@
</div>
<div class="candidate-tags">
<span
v-for="tag in recipeStore.allTags.filter(t => !batchTagsSelected.includes(t))"
v-for="tag in visibleAllTags.filter(t => !batchTagsSelected.includes(t))"
:key="tag"
class="candidate-tag"
@click="batchTagsSelected.push(tag)"
@@ -271,7 +271,7 @@
<div class="editor-section">
<table class="editor-table">
<thead>
<tr><th>精油</th><th>滴数</th><th>单价/</th><th>小计</th><th></th></tr>
<tr><th>成分</th><th>用量</th><th>单价</th><th>小计</th><th></th></tr>
</thead>
<tbody>
<tr v-for="(ing, i) in formEoIngredients" :key="'eo-'+i">
@@ -296,8 +296,13 @@
</div>
</div>
</td>
<td><input v-model.number="ing.drops" type="number" min="0.5" step="0.5" class="editor-drops" /></td>
<td class="ing-ppd">{{ ing.oil ? oils.fmtPrice(oils.pricePerDrop(ing.oil)) : '-' }}</td>
<td>
<div class="drops-with-unit">
<input v-model.number="ing.drops" type="number" min="0.5" step="0.5" class="editor-drops" />
<span class="unit-hint">{{ oils.unitLabel(ing.oil) }}</span>
</div>
</td>
<td class="ing-ppd">{{ ing.oil ? oils.fmtPrice(oils.pricePerDrop(ing.oil)) : '-' }}/{{ oils.unitLabel(ing.oil) }}</td>
<td class="ing-cost">{{ ing.oil && ing.drops ? oils.fmtPrice(oils.pricePerDrop(ing.oil) * ing.drops) : '-' }}</td>
<td><button class="remove-row-btn" @click="removeEoRow(i)"></button></td>
</tr>
@@ -1019,8 +1024,8 @@ async function checkDupName(name, ings, target = 'diary') {
return false
}
const existIngs = dupIngs.map(i => `${i.oil}${i.drops}`).join('、')
const newIngs = myIngs.map(i => `${i.oil}${i.drops}`).join('、')
const existIngs = dupIngs.map(i => `${i.oil}${i.drops}${oils.unitLabel(i.oil)}`).join('、')
const newIngs = myIngs.map(i => `${i.oil}${i.drops}${oils.unitLabel(i.oil)}`).join('、')
const ok = await showConfirm(
`${where}中已有同名配方「${currentName}」,内容不同:\n\n已有${existIngs}\n新的${newIngs}\n\n请改名后保存`,
{ okText: '改名', cancelText: '取消' }
@@ -1308,9 +1313,13 @@ const previewRecipeIndex = ref(null)
const previewRecipeData = ref(null)
const showBatchMenu = ref(false)
const visibleAllTags = computed(() => {
const tags = recipeStore.allTags
if (auth.canEdit) return tags
return tags.filter(t => !EDITOR_ONLY_TAGS.includes(t))
if (auth.canEdit) return recipeStore.allTags
// Viewer: only show tags from their own diary recipes
const myTags = new Set()
for (const d of diaryStore.userDiary) {
for (const t of (d.tags || [])) myTags.add(t)
}
return [...myTags].sort((a, b) => a.localeCompare(b, 'zh'))
})
const showBatchTagPicker = ref(false)
const batchTagsSelected = ref([])
@@ -2077,6 +2086,8 @@ watch(() => recipeStore.recipes, () => {
.editor-table td { padding: 6px 4px; border-bottom: 1px solid #f5f5f5; }
.editor-drops { width: 65px; padding: 6px 8px; border: 1.5px solid #d4cfc7; border-radius: 8px; font-size: 13px; text-align: center; outline: none; font-family: inherit; }
.editor-drops:focus { border-color: #7ec6a4; }
.drops-with-unit { display: flex; align-items: center; gap: 2px; }
.unit-hint { font-size: 11px; color: #b0aab5; white-space: nowrap; }
.editor-input { padding: 8px 10px; border: 1.5px solid #d4cfc7; border-radius: 8px; font-size: 13px; outline: none; font-family: inherit; width: 100%; box-sizing: border-box; }
.editor-input:focus { border-color: #7ec6a4; }
.editor-textarea { width: 100%; padding: 8px 10px; border: 1.5px solid #d4cfc7; border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; resize: vertical; box-sizing: border-box; }

View File

@@ -91,18 +91,18 @@
</div>
<div class="user-actions">
<select
v-if="u.role !== 'admin'"
:value="u.role"
class="role-select"
@change="changeRole(u, $event.target.value)"
:disabled="u.role === 'admin'"
>
<option value="viewer">查看者</option>
<option value="editor">编辑</option>
<option value="senior_editor">高级编辑</option>
</select>
<button v-if="!u.business_verified" class="btn-sm btn-outline" @click="grantBusiness(u)" title="开通商业认证">💼</button>
<button v-else class="btn-sm btn-outline" @click="revokeBusiness(u)" title="撤销商业认证" style="opacity:0.5">💼</button>
<button class="btn-sm btn-delete" @click="removeUser(u)" title="删除用户">🗑</button>
<button v-if="u.business_verified" class="btn-sm btn-outline" @click="revokeBusiness(u)" title="撤销商业认证">💼</button>
<button v-else class="btn-sm btn-outline" @click="grantBusiness(u)" title="开通商业认证" style="opacity:0.3">💼</button>
<button class="btn-sm btn-delete" @click="removeUser(u)" :disabled="u.role === 'admin'" title="删除用户">🗑</button>
</div>
</div>
<div v-if="filteredUsers.length === 0" class="empty-hint">未找到用户</div>
@@ -162,10 +162,10 @@ function formatDate(d) {
}
const roles = [
{ value: 'admin', label: '管理员' },
{ value: 'senior_editor', label: '高级编辑' },
{ value: 'editor', label: '编辑' },
{ value: 'viewer', label: '查看者' },
{ value: 'business', label: '企业用户' },
]
const filteredUsers = computed(() => {
@@ -178,7 +178,11 @@ const filteredUsers = computed(() => {
)
}
if (filterRole.value) {
list = list.filter(u => u.role === filterRole.value)
if (filterRole.value === 'business') {
list = list.filter(u => u.business_verified)
} else {
list = list.filter(u => u.role === filterRole.value)
}
}
return list
})