feat: 套装方案对比与导出功能 #32
@@ -41,7 +41,7 @@
|
||||
<th class="th-name">配方名</th>
|
||||
<th class="th-times">可做次数</th>
|
||||
<th class="th-cost">套装成本</th>
|
||||
<th class="th-cost">原价成本</th>
|
||||
<th class="th-cost">单买成本</th>
|
||||
<th class="th-price">售价</th>
|
||||
<th class="th-profit">利润率</th>
|
||||
</tr>
|
||||
@@ -238,15 +238,15 @@ async function exportExcel(mode) {
|
||||
const ws = wb.addWorksheet(ka.name)
|
||||
|
||||
// Kit info header
|
||||
ws.mergeCells('A1:F1')
|
||||
ws.mergeCells(mode === 'full' ? 'A1:H1' : 'A1:F1')
|
||||
const titleCell = ws.getCell('A1')
|
||||
titleCell.value = `${ka.name} — ¥${ka.price} — ${ka.oils.length}种精油 — 可做${ka.recipeCount}个配方`
|
||||
titleCell.font = { bold: true, size: 13 }
|
||||
titleCell.alignment = { horizontal: 'center' }
|
||||
|
||||
if (mode === 'full') {
|
||||
// Full version: recipe name, tags, ingredients detail, kit cost, original cost, selling price, margin
|
||||
const headers = ['配方名', '标签', '精油成分', '套装成本', '原价成本', '售价', '利润率']
|
||||
// Full version: recipe name, tags, ingredients, times, kit cost, original cost, selling price, margin
|
||||
const headers = ['配方名', '标签', '精油成分', '可做次数', '套装成本', '单买成本', '售价', '利润率']
|
||||
const headerRow = ws.addRow(headers)
|
||||
applyHeaderStyle(headerRow)
|
||||
|
||||
@@ -261,6 +261,7 @@ async function exportExcel(mode) {
|
||||
r.name,
|
||||
(r.tags || []).join('/'),
|
||||
ingredientStr,
|
||||
calcMaxTimes(r),
|
||||
Number(r.kitCost.toFixed(2)),
|
||||
Number(r.originalCost.toFixed(2)),
|
||||
price || '',
|
||||
@@ -268,8 +269,8 @@ async function exportExcel(mode) {
|
||||
])
|
||||
}
|
||||
} else {
|
||||
// Simple version: recipe name, kit cost, selling price, margin
|
||||
const headers = ['配方名', '套装成本', '售价', '利润率']
|
||||
// Simple version: recipe name, times, kit cost, original cost, selling price, margin
|
||||
const headers = ['配方名', '可做次数', '套装成本', '单买成本', '售价', '利润率']
|
||||
const headerRow = ws.addRow(headers)
|
||||
applyHeaderStyle(headerRow)
|
||||
|
||||
@@ -278,7 +279,9 @@ async function exportExcel(mode) {
|
||||
const margin = calcMargin(r.kitCost, price)
|
||||
ws.addRow([
|
||||
r.name,
|
||||
calcMaxTimes(r),
|
||||
Number(r.kitCost.toFixed(2)),
|
||||
Number(r.originalCost.toFixed(2)),
|
||||
price || '',
|
||||
price ? `${margin.toFixed(1)}%` : '',
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user