diff --git a/.workbuddy/memory/2026-07-28.md b/.workbuddy/memory/2026-07-28.md new file mode 100644 index 0000000..c4174b7 --- /dev/null +++ b/.workbuddy/memory/2026-07-28.md @@ -0,0 +1,6 @@ +# 2026-07-28 工作日志 + +## 货物类型导入模板美化 +- 文件:`src/views/base/cargo-type.vue` 的 `handleTemplate()` +- 改动:表头行加主色底色 `#409EFF`(argb `FF409EFF`)+ 白色加粗字体 + 居中对齐 + 自动换行;表头与数据区统一加细边框(`FFD0D7E2`);表头行高设为 42;编码列保持文本格式(`numFmt='@'`)。 +- 验证:Node + exceljs 4.4.0 跑通生成逻辑,确认表头 fill/font/alignment/border 与行高正确。 diff --git a/src/views/base/cargo-type.vue b/src/views/base/cargo-type.vue index c0ce5e8..ee377e5 100644 --- a/src/views/base/cargo-type.vue +++ b/src/views/base/cargo-type.vue @@ -585,10 +585,42 @@ export default { const col = ws.getColumn(idx); if (col) col.numFmt = '@'; }); - // 表头自动换行,长说明完整显示 - ws.getRow(1).eachCell(cell => { - cell.alignment = { wrapText: true, vertical: 'middle' }; + // 表头与数据区样式美化:主色底色表头 + 白字加粗居中 + 细边框 + const headerFill = { + type: 'pattern', + pattern: 'solid', + fgColor: { argb: 'FF409EFF' }, + }; + const thinBorder = { + top: { style: 'thin', color: { argb: 'FFD0D7E2' } }, + left: { style: 'thin', color: { argb: 'FFD0D7E2' } }, + bottom: { style: 'thin', color: { argb: 'FFD0D7E2' } }, + right: { style: 'thin', color: { argb: 'FFD0D7E2' } }, + }; + ws.eachRow(row => { + row.eachCell(cell => { + cell.border = thinBorder; + if (row.number === 1) { + // 表头:主色底色 + 白字加粗 + 居中对齐 + cell.fill = headerFill; + cell.font = { bold: true, color: { argb: 'FFFFFFFF' } }; + cell.alignment = { + wrapText: true, + vertical: 'middle', + horizontal: 'center', + }; + } else { + // 数据行:左对齐,垂直居中 + cell.alignment = { + wrapText: true, + vertical: 'middle', + horizontal: 'left', + }; + } + }); }); + // 表头行高,确保长说明换行后完整显示 + ws.getRow(1).height = 42; return wb.xlsx.writeBuffer(); }) .then(buf => {