feat(import): 优化货物类型导入失败明细及下载模板功能

- 引入 exceljs 动态加载,支持对后端失败明细 Excel 进行内容加工
- 导入失败明细取消标红错误字段,改为清晰错误原因文本说明
- 调整失败明细各列宽度,增加失败原因列换行提升可读性
- 失败明细原因列格式统一为“第N行:错误,规则”方式,便于定位
- 下载模板由后端生成改为前端本地生成,并内置示例数据
- 模板表头严格使用真实模板列名,示例数据涵盖一级及二级货物类型
- 模板编码列设置为文本格式避免前导零丢失,表头自动换行显示完整说明
This commit is contained in:
2026-07-28 00:23:15 +08:00
parent 8ff9f6bb66
commit c695d72ec8
2 changed files with 41 additions and 3 deletions

View File

@@ -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 => {