From 0e3bbf3ba79cf0730d1aca6620913f7495340494 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Tue, 14 Apr 2026 12:30:06 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=BC=E5=87=BA=E5=88=97=E5=AE=BD=20?= =?UTF-8?q?=E2=80=94=20=E9=85=8D=E6=96=B9=E5=90=8D=E8=87=AA=E9=80=82?= =?UTF-8?q?=E5=BA=94=EF=BC=8C=E5=85=B6=E4=BB=96=E5=88=97=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E7=AA=84=E5=AE=BD=E5=BA=A6=EF=BC=8C=E6=88=90=E5=88=86=E5=88=97?= =?UTF-8?q?35?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/views/KitExport.vue | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/frontend/src/views/KitExport.vue b/frontend/src/views/KitExport.vue index ff1a8e9..e8e4a41 100644 --- a/frontend/src/views/KitExport.vue +++ b/frontend/src/views/KitExport.vue @@ -222,14 +222,23 @@ async function exportExcel(mode) { row.height = 24 } - function autoCols(ws, minWidth = 10) { - ws.columns.forEach(col => { - let max = minWidth - col.eachCell({ includeEmpty: true }, cell => { - const len = cell.value ? String(cell.value).length * 1.5 : 0 - if (len > max) max = len - }) - col.width = Math.min(max + 2, 40) + function autoCols(ws, ingredientCol = -1) { + ws.columns.forEach((col, i) => { + if (i === 0) { + // First column (配方名): fit longest content + let max = 8 + col.eachCell({ includeEmpty: true }, cell => { + const len = cell.value ? String(cell.value).length * 1.8 : 0 + if (len > max) max = len + }) + col.width = Math.min(max + 2, 30) + } else if (i === ingredientCol) { + // Ingredient column: wider + col.width = 35 + } else { + // All other columns: uniform narrow width + col.width = 10 + } }) } @@ -288,7 +297,7 @@ async function exportExcel(mode) { } } - autoCols(ws) + autoCols(ws, mode === 'full' ? 2 : -1) // Style cost columns ws.eachRow((row, rowNum) => { @@ -335,7 +344,9 @@ async function exportExcel(mode) { }) } - autoCols(csWs) + // Cross sheet: ingredient is last column in full mode + const csIngCol = mode === 'full' ? csHeaders.length - 1 : -1 + autoCols(csWs, csIngCol) // Download const buf = await wb.xlsx.writeBuffer()