feat(import): 优化货物类型导入失败明细及下载模板功能
- 引入 exceljs 动态加载,支持对后端失败明细 Excel 进行内容加工 - 导入失败明细取消标红错误字段,改为清晰错误原因文本说明 - 调整失败明细各列宽度,增加失败原因列换行提升可读性 - 失败明细原因列格式统一为“第N行:错误,规则”方式,便于定位 - 下载模板由后端生成改为前端本地生成,并内置示例数据 - 模板表头严格使用真实模板列名,示例数据涵盖一级及二级货物类型 - 模板编码列设置为文本格式避免前导零丢失,表头自动换行显示完整说明
This commit is contained in:
6
.workbuddy/memory/2026-07-28.md
Normal file
6
.workbuddy/memory/2026-07-28.md
Normal file
@@ -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 与行高正确。
|
||||||
@@ -585,10 +585,42 @@ export default {
|
|||||||
const col = ws.getColumn(idx);
|
const col = ws.getColumn(idx);
|
||||||
if (col) col.numFmt = '@';
|
if (col) col.numFmt = '@';
|
||||||
});
|
});
|
||||||
// 表头自动换行,长说明完整显示
|
// 表头与数据区样式美化:主色底色表头 + 白字加粗居中 + 细边框
|
||||||
ws.getRow(1).eachCell(cell => {
|
const headerFill = {
|
||||||
cell.alignment = { wrapText: true, vertical: 'middle' };
|
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();
|
return wb.xlsx.writeBuffer();
|
||||||
})
|
})
|
||||||
.then(buf => {
|
.then(buf => {
|
||||||
|
|||||||
Reference in New Issue
Block a user