Compare commits
22 Commits
feat/kit-c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| fef28330f0 | |||
| 27418695a5 | |||
| 1053cf9140 | |||
| 1613b54bc6 | |||
| 9fc89cdb74 | |||
| cca7dd4471 | |||
| 7fbf5586b5 | |||
| f8d368a03a | |||
| 317ea3a2b6 | |||
| 18a74df083 | |||
| 2330ce1f2c | |||
| c9af05219b | |||
| e30891d3d2 | |||
| 9e11270fbf | |||
| cccf0091ba | |||
| 5ebffb8da4 | |||
| 3953218e41 | |||
| c7d86b909a | |||
| 06b29e6446 | |||
| 3043d4d6c4 | |||
| 9ba0f6e9b5 | |||
| 8a49938929 |
@@ -12,7 +12,7 @@ jobs:
|
||||
e2e-test:
|
||||
runs-on: test
|
||||
needs: unit-test
|
||||
timeout-minutes: 8
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -62,23 +62,37 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run all specs except demo-walkthrough (too slow for CI)
|
||||
# Run all specs in 3 batches to avoid Electron memory crashes
|
||||
cd frontend
|
||||
timeout 420 npx cypress run \
|
||||
--spec "cypress/e2e/!(demo-walkthrough).cy.js" \
|
||||
--config "video=false,defaultCommandTimeout=5000,pageLoadTimeout=10000,requestTimeout=5000,responseTimeout=10000,baseUrl=http://localhost:$FE_PORT,experimentalMemoryManagement=true,numTestsKeptInMemory=0" \
|
||||
--env "ADMIN_TOKEN=$ADMIN_TOKEN"
|
||||
EXIT_CODE=$?
|
||||
CYPRESS_CFG="video=false,defaultCommandTimeout=5000,pageLoadTimeout=10000,requestTimeout=5000,responseTimeout=10000,baseUrl=http://localhost:$FE_PORT,experimentalMemoryManagement=true,numTestsKeptInMemory=0"
|
||||
|
||||
echo "=== Batch 1: API & data tests ==="
|
||||
timeout 300 npx cypress run \
|
||||
--spec "cypress/e2e/api-crud.cy.js,cypress/e2e/api-health.cy.js,cypress/e2e/oil-data-integrity.cy.js,cypress/e2e/recipe-cost-parity.cy.js,cypress/e2e/endpoint-parity.cy.js,cypress/e2e/registration-flow.cy.js,cypress/e2e/pr27-features.cy.js,cypress/e2e/kit-export.cy.js" \
|
||||
--config "$CYPRESS_CFG" --env "ADMIN_TOKEN=$ADMIN_TOKEN"
|
||||
B1=$?
|
||||
|
||||
echo "=== Batch 2: UI flow tests ==="
|
||||
timeout 300 npx cypress run \
|
||||
--spec "cypress/e2e/auth-flow.cy.js,cypress/e2e/admin-flow.cy.js,cypress/e2e/navigation.cy.js,cypress/e2e/recipe-detail.cy.js,cypress/e2e/recipe-search.cy.js,cypress/e2e/manage-recipes.cy.js,cypress/e2e/diary-flow.cy.js,cypress/e2e/favorites.cy.js,cypress/e2e/inventory-flow.cy.js,cypress/e2e/demo-walkthrough.cy.js" \
|
||||
--config "$CYPRESS_CFG" --env "ADMIN_TOKEN=$ADMIN_TOKEN"
|
||||
B2=$?
|
||||
|
||||
echo "=== Batch 3: Remaining tests ==="
|
||||
timeout 300 npx cypress run \
|
||||
--spec "cypress/e2e/app-load.cy.js,cypress/e2e/account-settings.cy.js,cypress/e2e/audit-log-advanced.cy.js,cypress/e2e/batch-operations.cy.js,cypress/e2e/bug-tracker-flow.cy.js,cypress/e2e/category-modules.cy.js,cypress/e2e/notification-flow.cy.js,cypress/e2e/oil-reference.cy.js,cypress/e2e/oil-smart-paste.cy.js,cypress/e2e/performance.cy.js,cypress/e2e/price-display.cy.js,cypress/e2e/projects-flow.cy.js,cypress/e2e/responsive.cy.js,cypress/e2e/search-advanced.cy.js,cypress/e2e/user-management-flow.cy.js,cypress/e2e/visual-check.cy.js" \
|
||||
--config "$CYPRESS_CFG" --env "ADMIN_TOKEN=$ADMIN_TOKEN"
|
||||
B3=$?
|
||||
|
||||
# Cleanup
|
||||
kill $BE_PID $FE_PID 2>/dev/null
|
||||
pkill -f "Cypress" 2>/dev/null || true
|
||||
rm -f "$DB_FILE"
|
||||
if [ $EXIT_CODE -eq 124 ]; then
|
||||
echo "ERROR: Cypress timed out after 7 minutes"
|
||||
|
||||
echo "Results: Batch1=$B1 Batch2=$B2 Batch3=$B3"
|
||||
if [ $B1 -ne 0 ] || [ $B2 -ne 0 ] || [ $B3 -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
exit $EXIT_CODE
|
||||
|
||||
build-check:
|
||||
runs-on: test
|
||||
|
||||
@@ -5,82 +5,26 @@ describe('doTERRA 精油配方计算器 - 功能演示', () => {
|
||||
cy.getAdminToken().then(token => { adminToken = token })
|
||||
})
|
||||
|
||||
it('完整功能演示', { defaultCommandTimeout: 20000 }, () => {
|
||||
// ===== 开场:首页加载 =====
|
||||
cy.visit('/', {
|
||||
onBeforeLoad(win) {
|
||||
win.localStorage.setItem('oil_auth_token', adminToken)
|
||||
}
|
||||
})
|
||||
cy.get('.app-header').should('be.visible')
|
||||
cy.wait(1000)
|
||||
|
||||
// ===== 配方卡片列表 =====
|
||||
cy.get('.recipe-card', { timeout: 15000 }).should('have.length.gte', 1)
|
||||
cy.wait(500)
|
||||
|
||||
// ===== 搜索框输入 =====
|
||||
cy.get('input[placeholder*="搜索"]').should('be.visible').click()
|
||||
cy.get('input[placeholder*="搜索"]').type('薰衣草', { delay: 100 })
|
||||
cy.wait(500)
|
||||
cy.get('input[placeholder*="搜索"]').clear()
|
||||
cy.wait(500)
|
||||
|
||||
// ===== 点击配方卡片 =====
|
||||
cy.get('.recipe-card', { timeout: 10000 }).first().click()
|
||||
cy.wait(1000)
|
||||
|
||||
// ===== 查看详情 =====
|
||||
cy.get('[class*="overlay"], [class*="detail"]', { timeout: 10000 }).should('be.visible')
|
||||
cy.get('.detail-close-btn').first().click({ force: true })
|
||||
cy.wait(500)
|
||||
|
||||
// ===== 切换精油价目 =====
|
||||
cy.get('.nav-tab').contains('精油价目').click()
|
||||
cy.wait(1000)
|
||||
|
||||
// ===== 精油页面 =====
|
||||
cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
|
||||
|
||||
// ===== 管理配方 =====
|
||||
cy.get('.nav-tab').contains('管理配方').click()
|
||||
cy.wait(1000)
|
||||
|
||||
// ===== 个人库存 =====
|
||||
cy.get('.nav-tab').contains('个人库存').click()
|
||||
cy.wait(1000)
|
||||
|
||||
// ===== Admin pages via direct URL =====
|
||||
cy.visit('/audit', {
|
||||
onBeforeLoad(win) {
|
||||
win.localStorage.setItem('oil_auth_token', adminToken)
|
||||
}
|
||||
})
|
||||
cy.contains('操作日志', { timeout: 10000 }).should('be.visible')
|
||||
cy.wait(500)
|
||||
|
||||
cy.visit('/bugs', {
|
||||
onBeforeLoad(win) {
|
||||
win.localStorage.setItem('oil_auth_token', adminToken)
|
||||
}
|
||||
})
|
||||
cy.contains('Bug', { timeout: 10000 }).should('be.visible')
|
||||
cy.wait(500)
|
||||
|
||||
cy.visit('/users', {
|
||||
onBeforeLoad(win) {
|
||||
win.localStorage.setItem('oil_auth_token', adminToken)
|
||||
}
|
||||
})
|
||||
cy.contains('用户管理', { timeout: 10000 }).should('be.visible')
|
||||
cy.wait(500)
|
||||
|
||||
// ===== 回到首页 =====
|
||||
cy.visit('/', {
|
||||
onBeforeLoad(win) {
|
||||
win.localStorage.setItem('oil_auth_token', adminToken)
|
||||
}
|
||||
})
|
||||
it('首页和搜索', { defaultCommandTimeout: 10000 }, () => {
|
||||
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||
cy.get('input[placeholder*="搜索"]').type('薰衣草')
|
||||
cy.get('input[placeholder*="搜索"]').clear()
|
||||
cy.get('.recipe-card').should('have.length.gte', 1)
|
||||
})
|
||||
|
||||
it('页面导航', { defaultCommandTimeout: 10000 }, () => {
|
||||
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.get('.nav-tab').contains('精油价目').click()
|
||||
cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
|
||||
cy.get('.nav-tab').contains('管理配方').click()
|
||||
cy.get('.nav-tab').contains('个人库存').click()
|
||||
})
|
||||
|
||||
it('管理页面可访问', { defaultCommandTimeout: 10000 }, () => {
|
||||
cy.visit('/audit', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.contains('操作日志', { timeout: 10000 }).should('be.visible')
|
||||
cy.visit('/users', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.contains('用户管理', { timeout: 10000 }).should('be.visible')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -16,12 +16,22 @@ describe('Oil Reference Page', () => {
|
||||
it('filters oils by search', () => {
|
||||
cy.get('.oil-chip').then($chips => {
|
||||
const initial = $chips.length
|
||||
cy.get('input[placeholder*="搜索精油"]').type('薰衣草')
|
||||
cy.get('input[placeholder*="搜索"]').type('薰衣草')
|
||||
cy.wait(300)
|
||||
cy.get('.oil-chip').should('have.length.lt', initial)
|
||||
})
|
||||
})
|
||||
|
||||
it('filters oils by english name', () => {
|
||||
cy.get('.oil-chip').then($chips => {
|
||||
const initial = $chips.length
|
||||
cy.get('input[placeholder*="搜索"]').type('Lavender')
|
||||
cy.wait(300)
|
||||
cy.get('.oil-chip').should('have.length.lt', initial)
|
||||
cy.get('.oil-chip').should('exist')
|
||||
})
|
||||
})
|
||||
|
||||
it('toggles between bottle and drop price view', () => {
|
||||
cy.get('.oil-chip').first().invoke('text').then(textBefore => {
|
||||
cy.contains('滴价').click()
|
||||
|
||||
51
frontend/cypress/e2e/oil-smart-paste.cy.js
Normal file
51
frontend/cypress/e2e/oil-smart-paste.cy.js
Normal file
@@ -0,0 +1,51 @@
|
||||
describe('Oil Reference Smart Paste', () => {
|
||||
let adminToken
|
||||
|
||||
before(() => {
|
||||
cy.getAdminToken().then(token => { adminToken = token })
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
cy.visit('/oils', {
|
||||
onBeforeLoad(win) {
|
||||
win.localStorage.setItem('oil_auth_token', adminToken)
|
||||
}
|
||||
})
|
||||
cy.get('.oil-chip, .oils-grid', { timeout: 10000 }).should('exist')
|
||||
})
|
||||
|
||||
it('smart paste fills product form fields', () => {
|
||||
cy.contains('button', '+ 新增').click()
|
||||
cy.contains('button', '🪄 智能识别').click()
|
||||
|
||||
const sample = [
|
||||
'优惠顾客价:¥310PT:41',
|
||||
'',
|
||||
'零售价:¥465',
|
||||
'',
|
||||
'点数:37 规格:100毫升',
|
||||
'',
|
||||
'花样年华焕颜精华水 Salubelle Rejuvenating Essence',
|
||||
].join('\n')
|
||||
|
||||
cy.get('textarea').type(sample, { parseSpecialCharSequences: false, delay: 0 })
|
||||
cy.contains('button', '识别并填入').click()
|
||||
|
||||
cy.get('.add-type-tab.active').should('contain', '其他')
|
||||
cy.get('input[placeholder="产品名称"]').should('have.value', '花样年华焕颜精华水')
|
||||
cy.get('input[placeholder="英文名"]').should('have.value', 'Salubelle Rejuvenating Essence')
|
||||
cy.get('input[placeholder="会员价 ¥"]').should('have.value', '310')
|
||||
cy.get('input[placeholder="零售价 ¥"]').should('have.value', '465')
|
||||
cy.get('input[placeholder="容量"]').should('have.value', '100')
|
||||
})
|
||||
|
||||
it('smart paste detects standard ml volume as essential oil', () => {
|
||||
cy.contains('button', '+ 新增').click()
|
||||
cy.contains('button', '🪄 智能识别').click()
|
||||
const sample = '会员价:¥200\n零售价:¥267\n规格:15毫升\n薰衣草测试 LavenderTest'
|
||||
cy.get('textarea').type(sample, { parseSpecialCharSequences: false, delay: 0 })
|
||||
cy.contains('button', '识别并填入').click()
|
||||
cy.get('.add-type-tab.active').should('contain', '精油')
|
||||
cy.get('input[placeholder="精油名称"]').should('have.value', '薰衣草测试')
|
||||
})
|
||||
})
|
||||
@@ -29,16 +29,14 @@ describe('Price Display Regression', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('recipe detail shows non-zero total cost', () => {
|
||||
it('recipe cards show price in correct format', () => {
|
||||
cy.visit('/')
|
||||
cy.get('.recipe-card', { timeout: 10000 }).first().click()
|
||||
cy.wait(1000)
|
||||
|
||||
// Look for any ¥ amount > 0 in the detail overlay
|
||||
cy.get('[class*="overlay"], [class*="detail"]').invoke('text').then(text => {
|
||||
const prices = [...text.matchAll(/¥\s*(\d+\.?\d*)/g)].map(m => parseFloat(m[1]))
|
||||
const nonZero = prices.filter(p => p > 0)
|
||||
expect(nonZero.length, 'Detail should show at least one non-zero price').to.be.gte(1)
|
||||
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||
// Verify multiple cards have prices
|
||||
cy.get('.recipe-card-price').should('have.length.gte', 1)
|
||||
cy.get('.recipe-card-price').each($el => {
|
||||
const text = $el.text()
|
||||
expect(text).to.match(/¥|💰/)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,57 +1,44 @@
|
||||
describe('Visual Check - Screenshots', () => {
|
||||
describe('Visual Check', () => {
|
||||
let adminToken
|
||||
|
||||
before(() => {
|
||||
cy.getAdminToken().then(token => { adminToken = token })
|
||||
})
|
||||
|
||||
it('homepage with recipes', () => {
|
||||
it('homepage loads with recipes', () => {
|
||||
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||
cy.wait(1000)
|
||||
cy.screenshot('01-homepage')
|
||||
})
|
||||
|
||||
it('recipe detail overlay', () => {
|
||||
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.get('.recipe-card', { timeout: 10000 }).first().click()
|
||||
cy.wait(1000)
|
||||
cy.screenshot('02-recipe-detail')
|
||||
})
|
||||
|
||||
it('oil reference page', () => {
|
||||
it('oil reference loads with chips', () => {
|
||||
cy.visit('/oils', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
|
||||
cy.wait(500)
|
||||
cy.screenshot('03-oil-reference')
|
||||
})
|
||||
|
||||
it('manage recipes page', () => {
|
||||
it('manage recipes page loads', () => {
|
||||
cy.visit('/manage', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.wait(2000)
|
||||
cy.screenshot('04-manage-recipes')
|
||||
cy.get('.recipe-manager', { timeout: 10000 }).should('exist')
|
||||
})
|
||||
|
||||
it('inventory page', () => {
|
||||
it('inventory page loads', () => {
|
||||
cy.visit('/inventory', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.wait(1500)
|
||||
cy.screenshot('05-inventory')
|
||||
cy.get('.inventory-page', { timeout: 10000 }).should('exist')
|
||||
})
|
||||
|
||||
it('check if recipe cards show price > 0', () => {
|
||||
it('recipe cards show price > 0', () => {
|
||||
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||
// Check if any card shows a non-zero price
|
||||
cy.get('.recipe-card').first().invoke('text').then(text => {
|
||||
cy.log('First card text: ' + text)
|
||||
const priceMatch = text.match(/¥\s*(\d+\.?\d*)/)
|
||||
if (priceMatch) {
|
||||
cy.log('Price found: ¥' + priceMatch[1])
|
||||
const price = parseFloat(priceMatch[1])
|
||||
expect(price, 'Recipe card should show price > 0').to.be.gt(0)
|
||||
} else {
|
||||
cy.log('WARNING: No price found on recipe card')
|
||||
expect(parseFloat(priceMatch[1])).to.be.gt(0)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('recipe detail overlay opens', () => {
|
||||
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||
cy.get('.recipe-card', { timeout: 10000 }).first().click()
|
||||
cy.get('.detail-overlay', { timeout: 10000 }).should('exist')
|
||||
})
|
||||
})
|
||||
|
||||
73
frontend/src/__tests__/oilProductPaste.test.js
Normal file
73
frontend/src/__tests__/oilProductPaste.test.js
Normal file
@@ -0,0 +1,73 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { parseOilProductPaste } from '../composables/useOilProductPaste'
|
||||
|
||||
describe('parseOilProductPaste', () => {
|
||||
it('returns empty shape for empty input', () => {
|
||||
const r = parseOilProductPaste('')
|
||||
expect(r.cn).toBe('')
|
||||
expect(r.en).toBe('')
|
||||
expect(r.memberPrice).toBeNull()
|
||||
expect(r.retailPrice).toBeNull()
|
||||
})
|
||||
|
||||
it('parses the 花样年华 sample as product with 100ml', () => {
|
||||
const sample = `优惠顾客价:¥310PT:41
|
||||
|
||||
零售价:¥465
|
||||
|
||||
点数:37 规格:100毫升
|
||||
|
||||
花样年华焕颜精华水 Salubelle Rejuvenating Essence`
|
||||
const r = parseOilProductPaste(sample)
|
||||
expect(r.type).toBe('product')
|
||||
expect(r.memberPrice).toBe(310)
|
||||
expect(r.retailPrice).toBe(465)
|
||||
expect(r.productAmount).toBe(100)
|
||||
expect(r.productUnit).toBe('ml')
|
||||
expect(r.cn).toBe('花样年华焕颜精华水')
|
||||
expect(r.en).toBe('Salubelle Rejuvenating Essence')
|
||||
})
|
||||
|
||||
it('detects essential oil when volume is standard ml', () => {
|
||||
const sample = `会员价:¥200\n零售价:¥267\n规格:15毫升\n薰衣草 Lavender`
|
||||
const r = parseOilProductPaste(sample)
|
||||
expect(r.type).toBe('oil')
|
||||
expect(r.volume).toBe('15')
|
||||
expect(r.cn).toBe('薰衣草')
|
||||
expect(r.en).toBe('Lavender')
|
||||
})
|
||||
|
||||
it('handles half-width colon and dollar variant', () => {
|
||||
const r = parseOilProductPaste('优惠顾客价: ¥99\n零售价: ¥150\n规格: 5ml\n柠檬 Lemon')
|
||||
expect(r.memberPrice).toBe(99)
|
||||
expect(r.retailPrice).toBe(150)
|
||||
expect(r.type).toBe('oil')
|
||||
expect(r.volume).toBe('5')
|
||||
})
|
||||
|
||||
it('parses capsule spec as product', () => {
|
||||
const r = parseOilProductPaste('优惠顾客价:¥200\n规格:60粒\n深海鱼油 Omega')
|
||||
expect(r.type).toBe('product')
|
||||
expect(r.productAmount).toBe(60)
|
||||
expect(r.productUnit).toBe('capsule')
|
||||
})
|
||||
|
||||
it('parses gram spec as product', () => {
|
||||
const r = parseOilProductPaste('优惠顾客价:¥80\n规格:120克\n洁面乳 Face Wash')
|
||||
expect(r.productUnit).toBe('g')
|
||||
expect(r.productAmount).toBe(120)
|
||||
})
|
||||
|
||||
it('non-standard ml volume falls to product', () => {
|
||||
const r = parseOilProductPaste('优惠顾客价:¥310\n规格:100毫升\n精华 Essence')
|
||||
expect(r.type).toBe('product')
|
||||
expect(r.productAmount).toBe(100)
|
||||
expect(r.productUnit).toBe('ml')
|
||||
})
|
||||
|
||||
it('name without english part keeps cn only', () => {
|
||||
const r = parseOilProductPaste('优惠顾客价:¥50\n规格:5毫升\n某国产品')
|
||||
expect(r.cn).toBe('某国产品')
|
||||
expect(r.en).toBe('')
|
||||
})
|
||||
})
|
||||
@@ -499,3 +499,149 @@ describe('volume field in recipe mapping — PR31', () => {
|
||||
expect(labels['']).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// PR33: Oil card branding logic
|
||||
// ---------------------------------------------------------------------------
|
||||
describe('oil card branding — PR33', () => {
|
||||
it('brand data determines card display elements', () => {
|
||||
const brand = { qr_code: 'data:image/png;base64,abc', brand_bg: 'data:image/png;base64,bg', brand_logo: null, brand_name: '测试品牌', brand_align: 'center' }
|
||||
expect(!!brand.qr_code).toBe(true)
|
||||
expect(!!brand.brand_bg).toBe(true)
|
||||
expect(!!brand.brand_logo).toBe(false)
|
||||
expect(!!brand.brand_name).toBe(true)
|
||||
})
|
||||
|
||||
it('empty brand shows plain card', () => {
|
||||
const brand = {}
|
||||
expect(!!brand.qr_code).toBe(false)
|
||||
expect(!!brand.brand_bg).toBe(false)
|
||||
expect(!!brand.brand_logo).toBe(false)
|
||||
})
|
||||
|
||||
it('volumeLabel with name parameter works for drops and ml', () => {
|
||||
// Simulates the fix: volumeLabel(dropCount, name) needs both params
|
||||
const DROPS_TO_VOLUME = { 93: '5ml', 280: '15ml' }
|
||||
function volumeLabel(dropCount, name) {
|
||||
if (name === '无香乳液') return dropCount + 'ml' // ml unit
|
||||
return DROPS_TO_VOLUME[dropCount] || (dropCount + '滴')
|
||||
}
|
||||
expect(volumeLabel(280, '薰衣草')).toBe('15ml')
|
||||
expect(volumeLabel(200, '无香乳液')).toBe('200ml')
|
||||
expect(volumeLabel(93, '茶树')).toBe('5ml')
|
||||
})
|
||||
|
||||
it('PDF export price unit adapts to product type', () => {
|
||||
function oilPriceUnit(name) {
|
||||
if (name === '无香乳液') return 'ml'
|
||||
if (name === '植物空胶囊') return '颗'
|
||||
return '滴'
|
||||
}
|
||||
expect(oilPriceUnit('薰衣草')).toBe('滴')
|
||||
expect(oilPriceUnit('无香乳液')).toBe('ml')
|
||||
expect(oilPriceUnit('植物空胶囊')).toBe('颗')
|
||||
})
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// PR34: Product edit UI — unit-based form switching
|
||||
// ---------------------------------------------------------------------------
|
||||
describe('product edit UI logic — PR34', () => {
|
||||
it('drop unit shows standard volume selector', () => {
|
||||
const unit = 'drop'
|
||||
expect(unit === 'drop').toBe(true)
|
||||
})
|
||||
|
||||
it('non-drop unit shows amount + unit selector', () => {
|
||||
for (const u of ['ml', 'g', 'capsule']) {
|
||||
expect(u !== 'drop').toBe(true)
|
||||
}
|
||||
})
|
||||
|
||||
it('edit form initializes correct unit from meta', () => {
|
||||
const meta = { unit: 'g', dropCount: 80 }
|
||||
const editUnit = meta.unit || 'drop'
|
||||
const editProductAmount = editUnit !== 'drop' ? meta.dropCount : null
|
||||
const editProductUnit = editUnit !== 'drop' ? editUnit : 'ml'
|
||||
expect(editUnit).toBe('g')
|
||||
expect(editProductAmount).toBe(80)
|
||||
expect(editProductUnit).toBe('g')
|
||||
})
|
||||
|
||||
it('edit form defaults to drop for oils', () => {
|
||||
const meta = { unit: 'drop', dropCount: 280 }
|
||||
const editUnit = meta.unit || 'drop'
|
||||
expect(editUnit).toBe('drop')
|
||||
})
|
||||
|
||||
it('edit form defaults to drop when unit is undefined', () => {
|
||||
const meta = { dropCount: 280 }
|
||||
const editUnit = meta.unit || 'drop'
|
||||
expect(editUnit).toBe('drop')
|
||||
})
|
||||
|
||||
it('save uses product amount and unit for non-drop', () => {
|
||||
const editUnit = 'ml'
|
||||
const editProductAmount = 200
|
||||
const editProductUnit = 'ml'
|
||||
const dropCount = 280 // from standard volume selector
|
||||
const finalDropCount = editUnit !== 'drop' ? editProductAmount : dropCount
|
||||
const finalUnit = editUnit !== 'drop' ? editProductUnit : null
|
||||
expect(finalDropCount).toBe(200)
|
||||
expect(finalUnit).toBe('ml')
|
||||
})
|
||||
|
||||
it('save uses standard drop count for oils', () => {
|
||||
const editUnit = 'drop'
|
||||
const editProductAmount = null
|
||||
const dropCount = 280
|
||||
const finalDropCount = editUnit !== 'drop' ? editProductAmount : dropCount
|
||||
const finalUnit = editUnit !== 'drop' ? 'ml' : null
|
||||
expect(finalDropCount).toBe(280)
|
||||
expect(finalUnit).toBeNull()
|
||||
})
|
||||
|
||||
it('label adapts: 精油名称 for oils, 产品名称 for products', () => {
|
||||
const labelForDrop = 'drop' === 'drop' ? '精油名称' : '产品名称'
|
||||
const labelForMl = 'ml' === 'drop' ? '精油名称' : '产品名称'
|
||||
expect(labelForDrop).toBe('精油名称')
|
||||
expect(labelForMl).toBe('产品名称')
|
||||
})
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// PR34: Share text and consumption analysis use dynamic unit
|
||||
// ---------------------------------------------------------------------------
|
||||
describe('share text and consumption use dynamic unit — PR34', () => {
|
||||
const UNIT_MAP = { drop: '滴', ml: 'ml', g: 'g', capsule: '颗' }
|
||||
function unitLabel(name, unitMap) { return UNIT_MAP[unitMap[name] || 'drop'] }
|
||||
|
||||
it('share text uses unitLabel for each ingredient', () => {
|
||||
const units = { '薰衣草': 'drop', '无香乳液': 'ml', '植物空胶囊': 'capsule' }
|
||||
const ings = [
|
||||
{ oil: '薰衣草', drops: 3 },
|
||||
{ oil: '无香乳液', drops: 30 },
|
||||
{ oil: '植物空胶囊', drops: 2 },
|
||||
]
|
||||
const lines = ings.map(i => `${i.oil} ${i.drops}${unitLabel(i.oil, units)}`)
|
||||
expect(lines[0]).toBe('薰衣草 3滴')
|
||||
expect(lines[1]).toBe('无香乳液 30ml')
|
||||
expect(lines[2]).toBe('植物空胶囊 2颗')
|
||||
})
|
||||
|
||||
it('consumption analysis uses unitLabel per oil', () => {
|
||||
const units = { '薰衣草': 'drop', '活力磨砂膏': 'g' }
|
||||
const data = [
|
||||
{ oil: '薰衣草', drops: 15, bottleDrops: 280 },
|
||||
{ oil: '活力磨砂膏', drops: 30, bottleDrops: 70 },
|
||||
]
|
||||
const display = data.map(c => ({
|
||||
usage: `${c.drops}${unitLabel(c.oil, units)}`,
|
||||
capacity: `${c.bottleDrops}${unitLabel(c.oil, units)}`,
|
||||
}))
|
||||
expect(display[0].usage).toBe('15滴')
|
||||
expect(display[0].capacity).toBe('280滴')
|
||||
expect(display[1].usage).toBe('30g')
|
||||
expect(display[1].capacity).toBe('70g')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -483,7 +483,7 @@ function copyText() {
|
||||
const ings = cardIngredients.value
|
||||
const lines = ings.map(ing => {
|
||||
const cost = oilsStore.pricePerDrop(ing.oil) * ing.drops
|
||||
return `${ing.oil} ${ing.drops}滴 ${oilsStore.fmtPrice(cost)}`
|
||||
return `${ing.oil} ${ing.drops}${oilsStore.unitLabel(ing.oil)} ${oilsStore.fmtPrice(cost)}`
|
||||
})
|
||||
const total = priceInfo.value.cost
|
||||
const text = [
|
||||
@@ -829,7 +829,7 @@ onMounted(() => {
|
||||
else { selectedVolume.value = 'custom'; customVolumeValue.value = Math.round(ml) }
|
||||
|
||||
loadBrand()
|
||||
nextTick(() => generateCardImage())
|
||||
// Don't auto-generate card image on mount — generate on demand when saving
|
||||
})
|
||||
|
||||
function addIngredient() {
|
||||
|
||||
52
frontend/src/composables/useOilProductPaste.js
Normal file
52
frontend/src/composables/useOilProductPaste.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const OIL_VOLUMES = new Set(['2.5', '5', '10', '15', '115'])
|
||||
|
||||
export function parseOilProductPaste(raw) {
|
||||
const result = {
|
||||
type: 'product',
|
||||
cn: '',
|
||||
en: '',
|
||||
memberPrice: null,
|
||||
retailPrice: null,
|
||||
volume: null,
|
||||
customDrops: null,
|
||||
productAmount: null,
|
||||
productUnit: null,
|
||||
}
|
||||
if (!raw || !raw.trim()) return result
|
||||
|
||||
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|颗|粒|片)/)
|
||||
|
||||
if (memberMatch) result.memberPrice = Number(memberMatch[1])
|
||||
if (retailMatch) result.retailPrice = Number(retailMatch[1])
|
||||
|
||||
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) { result.cn = m[1].trim(); result.en = m[2].trim() } else { result.cn = s }
|
||||
break
|
||||
}
|
||||
|
||||
if (specMatch) {
|
||||
const amount = specMatch[1]
|
||||
const unitRaw = specMatch[2].toLowerCase()
|
||||
const isMl = unitRaw === '毫升' || unitRaw === 'ml'
|
||||
if (isMl && OIL_VOLUMES.has(String(Number(amount)))) {
|
||||
result.type = 'oil'
|
||||
result.volume = String(Number(amount))
|
||||
} else {
|
||||
result.type = 'product'
|
||||
result.productAmount = Number(amount)
|
||||
result.productUnit = (unitRaw === '克' || unitRaw === 'g') ? 'g'
|
||||
: (unitRaw === '颗' || unitRaw === '粒' || unitRaw === '片') ? 'capsule'
|
||||
: 'ml'
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -91,7 +91,7 @@
|
||||
<!-- Search + View Toggle + Add + PDF -->
|
||||
<div style="display:flex;gap:6px;align-items:center;margin-bottom:12px;flex-wrap:nowrap">
|
||||
<div class="search-box" style="flex:1;min-width:140px;margin-bottom:0">
|
||||
<input class="search-input" v-model="searchQuery" placeholder="搜索精油名称…" style="width:100%" />
|
||||
<input class="search-input" v-model="searchQuery" placeholder="搜索中文或英文名…" style="width:100%" />
|
||||
</div>
|
||||
<div style="display:flex;border:1.5px solid var(--border);border-radius:10px;overflow:hidden;flex-shrink:0">
|
||||
<button @click="viewMode = 'bottle'" :style="viewMode === 'bottle' ? 'background:var(--sage);color:white' : 'background:white;color:var(--text-mid)'" style="border:none;border-radius:0;font-size:12px;padding:6px 12px;cursor:pointer">每瓶价</button>
|
||||
@@ -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">
|
||||
@@ -181,9 +189,16 @@
|
||||
|
||||
<!-- Oil Knowledge Card Modal -->
|
||||
<div v-if="activeCard && activeCardName" class="modal-overlay" @mousedown.self="closeOilModal">
|
||||
<div class="oil-card-modal">
|
||||
<div class="oil-card-header">
|
||||
<div class="oil-card-header-content">
|
||||
<div class="oil-card-modal" style="position:relative;overflow:hidden">
|
||||
<!-- Brand background -->
|
||||
<div v-if="brand.brand_bg" style="position:absolute;inset:0;width:100%;height:100%;background-size:cover;background-position:center;opacity:0.08;pointer-events:none;z-index:0" :style="{ backgroundImage: `url('${brand.brand_bg}')` }"></div>
|
||||
<!-- QR code -->
|
||||
<div v-if="brand.qr_code" style="position:absolute;top:16px;right:16px;display:flex;flex-direction:column;gap:3px;z-index:3" :style="{ alignItems: (brand.brand_align === 'left' ? 'flex-start' : brand.brand_align === 'right' ? 'flex-end' : 'center') }">
|
||||
<img :src="brand.qr_code" crossorigin="anonymous" style="width:48px;height:48px;object-fit:cover;border-radius:6px;box-shadow:0 2px 6px rgba(0,0,0,0.1)" />
|
||||
<div v-if="brand.brand_name" style="font-size:7px;color:rgba(255,255,255,0.8);line-height:1.3;max-width:60px;white-space:pre-line;text-align:center">{{ brand.brand_name }}</div>
|
||||
</div>
|
||||
<div class="oil-card-header" style="position:relative;z-index:1">
|
||||
<div class="oil-card-header-content" :style="brand.qr_code ? 'padding-right:70px' : ''">
|
||||
<span class="oil-card-emoji">{{ activeCard.emoji }}</span>
|
||||
<div>
|
||||
<h2 class="oil-card-title">{{ activeCardName }}</h2>
|
||||
@@ -196,7 +211,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn-close btn-close-light" @click="closeOilModal">✕</button>
|
||||
<button class="btn-close btn-close-light" @click="closeOilModal" style="z-index:4">✕</button>
|
||||
</div>
|
||||
<!-- Method badges -->
|
||||
<div class="oil-card-methods">
|
||||
@@ -227,6 +242,10 @@
|
||||
<h4 class="oil-card-caution-title">⚠️ 注意事项</h4>
|
||||
<p>{{ activeCard.caution }}</p>
|
||||
</div>
|
||||
<!-- Logo -->
|
||||
<div v-if="brand.brand_logo" style="padding-top:8px">
|
||||
<img :src="brand.brand_logo" crossorigin="anonymous" style="height:24px;opacity:0.7" />
|
||||
</div>
|
||||
<div style="text-align:center;padding-top:12px">
|
||||
<button class="btn btn-outline btn-sm" @click="saveCardImage(activeCardName)">💾 保存图片</button>
|
||||
</div>
|
||||
@@ -316,13 +335,15 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>精油名称</label>
|
||||
<input v-model="editOilDisplayName" class="form-input" type="text" placeholder="精油名称" />
|
||||
<label>{{ editUnit === 'drop' ? '精油名称' : '产品名称' }}</label>
|
||||
<input v-model="editOilDisplayName" class="form-input" type="text" :placeholder="editUnit === 'drop' ? '精油名称' : '产品名称'" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>英文名</label>
|
||||
<input v-model="editOilEnName" class="form-input" type="text" placeholder="English name" />
|
||||
</div>
|
||||
<!-- 精油容量 -->
|
||||
<template v-if="editUnit === 'drop'">
|
||||
<div class="form-group">
|
||||
<label>容量</label>
|
||||
<select v-model="editVolume" class="form-select">
|
||||
@@ -338,6 +359,21 @@
|
||||
<label>自定义滴数</label>
|
||||
<input v-model.number="editDropCount" class="form-input" type="number" />
|
||||
</div>
|
||||
</template>
|
||||
<!-- 其他产品容量 -->
|
||||
<template v-else>
|
||||
<div class="form-group">
|
||||
<label>容量</label>
|
||||
<div style="display:flex;gap:6px;align-items:center">
|
||||
<input v-model.number="editProductAmount" class="form-input" type="number" min="1" style="flex:1" />
|
||||
<select v-model="editProductUnit" class="form-select" style="width:70px">
|
||||
<option value="ml">ml</option>
|
||||
<option value="g">g</option>
|
||||
<option value="capsule">颗</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="form-group">
|
||||
<label>会员价 (¥)</label>
|
||||
<input v-model.number="editBottlePrice" class="form-input" type="number" />
|
||||
@@ -408,12 +444,20 @@ import { useRecipesStore } from '../stores/recipes'
|
||||
import { oilEn } from '../composables/useOilTranslation'
|
||||
import { getOilCard, setOilCard } from '../composables/useOilCards'
|
||||
import { showConfirm } from '../composables/useDialog'
|
||||
import { api } from '../composables/useApi'
|
||||
import { parseOilProductPaste } from '../composables/useOilProductPaste'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const oils = useOilsStore()
|
||||
const recipeStore = useRecipesStore()
|
||||
const ui = useUiStore()
|
||||
|
||||
// Brand data for card
|
||||
const brand = ref({})
|
||||
async function loadBrand() {
|
||||
try { brand.value = await api.get('/api/brand') } catch {}
|
||||
}
|
||||
|
||||
// Modal states
|
||||
const showDilution = ref(false)
|
||||
const showContra = ref(false)
|
||||
@@ -433,6 +477,28 @@ const activeCard = ref(null)
|
||||
|
||||
// Add oil form
|
||||
const addType = ref('oil')
|
||||
const showSmartPaste = ref(false)
|
||||
const smartPasteText = ref('')
|
||||
|
||||
function runSmartPaste() {
|
||||
const raw = smartPasteText.value || ''
|
||||
if (!raw.trim()) return
|
||||
const parsed = parseOilProductPaste(raw)
|
||||
if (parsed.memberPrice != null) newBottlePrice.value = parsed.memberPrice
|
||||
if (parsed.retailPrice != null) newRetailPrice.value = parsed.retailPrice
|
||||
if (parsed.cn) newOilName.value = parsed.cn
|
||||
if (parsed.en) newOilEnName.value = parsed.en
|
||||
addType.value = parsed.type
|
||||
if (parsed.type === 'oil') {
|
||||
if (parsed.volume) newVolume.value = parsed.volume
|
||||
newCustomDrops.value = null
|
||||
} else {
|
||||
if (parsed.productAmount != null) newProductAmount.value = parsed.productAmount
|
||||
if (parsed.productUnit) newProductUnit.value = parsed.productUnit
|
||||
}
|
||||
ui.showToast('已识别并填入,请检查后点添加')
|
||||
}
|
||||
|
||||
const newOilName = ref('')
|
||||
const newOilEnName = ref('')
|
||||
const newBottlePrice = ref(null)
|
||||
@@ -450,6 +516,9 @@ const editVolume = ref('5')
|
||||
const editDropCount = ref(0)
|
||||
const editRetailPrice = ref(null)
|
||||
const editOilEnName = ref('')
|
||||
const editUnit = ref('drop')
|
||||
const editProductAmount = ref(null)
|
||||
const editProductUnit = ref('ml')
|
||||
const editCardEmoji = ref('')
|
||||
const editCardEffects = ref('')
|
||||
const editCardUsage = ref('')
|
||||
@@ -576,8 +645,14 @@ const filteredOilNames = computed(() => {
|
||||
if (!searchQuery.value.trim()) return oils.oilNames
|
||||
const q = searchQuery.value.trim().toLowerCase()
|
||||
return oils.oilNames.filter(n => {
|
||||
const en = getEnglishName(n).toLowerCase()
|
||||
return n.toLowerCase().includes(q) || en.includes(q)
|
||||
if (n.toLowerCase().includes(q)) return true
|
||||
const card = getOilCard(n)
|
||||
if (card?.en && card.en.toLowerCase().includes(q)) return true
|
||||
const meta = oils.oilsMeta[n]
|
||||
if (meta?.enName && meta.enName.toLowerCase().includes(q)) return true
|
||||
const fallback = oilEn(n)
|
||||
if (fallback && fallback.toLowerCase().includes(q)) return true
|
||||
return false
|
||||
})
|
||||
})
|
||||
|
||||
@@ -637,12 +712,9 @@ async function openOilDetail(name) {
|
||||
activeCardName.value = name
|
||||
activeCard.value = card
|
||||
selectedOilName.value = null
|
||||
// Pre-generate card image for instant save
|
||||
loadBrand()
|
||||
// Generate image on demand when saving, not on open
|
||||
oilCardImageUrl.value = null
|
||||
await nextTick()
|
||||
await new Promise(r => setTimeout(r, 300))
|
||||
const el = document.querySelector('.oil-card-modal')
|
||||
if (el) await generateImageFromRef({ value: el }, oilCardImageUrl)
|
||||
} else {
|
||||
activeCard.value = null
|
||||
activeCardName.value = null
|
||||
@@ -712,6 +784,11 @@ function editOil(name) {
|
||||
editDropCount.value = dc
|
||||
editRetailPrice.value = meta?.retailPrice || null
|
||||
editOilEnName.value = meta?.enName || getEnglishName(name) || ''
|
||||
editUnit.value = meta?.unit || 'drop'
|
||||
if (editUnit.value !== 'drop') {
|
||||
editProductAmount.value = dc
|
||||
editProductUnit.value = editUnit.value
|
||||
}
|
||||
// Load knowledge card if exists
|
||||
const card = getOilCard(name)
|
||||
editCardEmoji.value = card?.emoji || ''
|
||||
@@ -737,12 +814,15 @@ async function saveEditOil() {
|
||||
if (newName && newName !== oldName) {
|
||||
await oils.deleteOil(oldName)
|
||||
}
|
||||
const finalDropCount = editUnit.value !== 'drop' ? editProductAmount.value : dropCount
|
||||
const finalUnit = editUnit.value !== 'drop' ? editProductUnit.value : null
|
||||
await oils.saveOil(
|
||||
newName || oldName,
|
||||
editBottlePrice.value,
|
||||
dropCount,
|
||||
finalDropCount,
|
||||
editRetailPrice.value,
|
||||
editOilEnName.value.trim() || null
|
||||
editOilEnName.value.trim() || null,
|
||||
finalUnit
|
||||
)
|
||||
// Save knowledge card if any content provided
|
||||
const finalName = newName || oldName
|
||||
@@ -825,8 +905,9 @@ function exportPDF() {
|
||||
const en = getEnglishName(name)
|
||||
const bp = meta.bottlePrice != null ? '¥' + meta.bottlePrice.toFixed(0) : '--'
|
||||
const rp = meta.retailPrice != null ? '¥' + meta.retailPrice.toFixed(0) : '--'
|
||||
const vol = volumeLabel(meta.dropCount)
|
||||
const ppd = oils.pricePerDrop(name) ? '¥' + oils.pricePerDrop(name).toFixed(2) : '--'
|
||||
const vol = volumeLabel(meta.dropCount, name)
|
||||
const unit = oilPriceUnit(name)
|
||||
const ppd = oils.pricePerDrop(name) ? '¥' + oils.pricePerDrop(name).toFixed(2) + '/' + unit : '--'
|
||||
rows += `<tr>
|
||||
<td>${name}</td>
|
||||
<td>${en}</td>
|
||||
@@ -858,7 +939,7 @@ function exportPDF() {
|
||||
<h1>doTERRA 精油价目表 ${dateStr}</h1>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>精油</th><th>英文名</th><th>会员价</th><th>零售价</th><th>容量</th><th>单价/滴</th></tr>
|
||||
<tr><th>精油</th><th>英文名</th><th>会员价</th><th>零售价</th><th>容量</th><th>单价</th></tr>
|
||||
</thead>
|
||||
<tbody>${rows}</tbody>
|
||||
</table>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<tr>
|
||||
<th>精油</th>
|
||||
<th>用量</th>
|
||||
<th>每滴</th>
|
||||
<th>单价</th>
|
||||
<th>小计</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -133,8 +133,8 @@
|
||||
<tbody>
|
||||
<tr v-for="c in consumptionData" :key="c.oil" :class="{ 'limit-oil': c.isLimit }">
|
||||
<td>{{ c.oil }}</td>
|
||||
<td>{{ c.drops }}滴</td>
|
||||
<td>{{ c.bottleDrops }}滴</td>
|
||||
<td>{{ c.drops }}{{ oils.unitLabel(c.oil) }}</td>
|
||||
<td>{{ c.bottleDrops }}{{ oils.unitLabel(c.oil) }}</td>
|
||||
<td>{{ c.sessions }}次</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
<!-- Action buttons -->
|
||||
<div class="action-bar">
|
||||
<button class="action-chip" @click="showAddOverlay = true">新增</button>
|
||||
<button class="action-chip" @click="oils.loadOils(); showAddOverlay = true">新增</button>
|
||||
<button class="action-chip" :class="{ active: isAllSelected }" @click="toggleSelectAll">
|
||||
全选<span v-if="totalSelected > 0" class="chip-count">{{ totalSelected }}</span>
|
||||
</button>
|
||||
@@ -808,6 +808,7 @@ function editRecipe(recipe) {
|
||||
}
|
||||
formNote.value = recipe.note || ''
|
||||
formTags.value = [...(recipe.tags || [])]
|
||||
oils.loadOils()
|
||||
showAddOverlay.value = true
|
||||
}
|
||||
|
||||
@@ -1698,7 +1699,7 @@ async function exportExcel() {
|
||||
}
|
||||
|
||||
const today = new Date().toISOString().slice(0, 10)
|
||||
XLSX.writeFile(wb, `精油配方${today}.xlsx`)
|
||||
XLSX.writeFile(wb, `精油配方备份${today}.xlsx`)
|
||||
ui.showToast('导出成功')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user