fix(cargo-type): 修复导入失败明细列宽和样式问题

- decorator 仅操作 G 列「导入失败原因」字体颜色为黑色,无背景填充
- 修正失败明细列宽映射 key,确保与后端表头完全一致
- 恢复所有列的宽度设置,避免内容拥挤
- 后端添加事务控制,确保导入数据全部正确才提交,否则整体回滚
This commit is contained in:
2026-07-28 01:22:45 +08:00
parent 38ce8fa2bc
commit 6eba9d2c2f
2 changed files with 16 additions and 11 deletions

View File

@@ -170,15 +170,15 @@ const CARGO_TYPE_FAIL_RULES = [
{ match: '备注不能超过200字', col: '备注', rule: '备注不能超过200字' },
];
// 失败明细各列目标宽度Excel 字符数),避免内容拥挤
// 失败明细各列目标宽度Excel 字符数),key 与后端 CargoTypeImportFailureExcel 表头完全一致
const CARGO_TYPE_FAIL_COL_WIDTH = {
类型: 14,
上级货物类型: 16,
上级货物类型编码: 20,
货物类型: 16,
货物类型编码: 16,
备注: 18,
导入失败原因: 60,
'*类型': 16,
'上级货物类型(如为一级则不需填写)': 22,
'上级货物类型编码(如为一级则不需填写)': 26,
'*货物类型': 18,
'*货物类型编码': 18,
'备注': 24,
'导入失败原因': 70,
};
/**
@@ -237,13 +237,15 @@ export const decorateCargoTypeFailDetail = async workbook => {
}
}
reasonCell.value = `${rowNumber}行:${decorated.join('')}`;
reasonCell.font = { color: { argb: 'FFFF0000' } };
// 仅操作 G 列:黑色字体、无背景填充,其余列保持后端原样
reasonCell.fill = { type: 'pattern', pattern: 'none' };
reasonCell.font = { color: { argb: 'FF000000' } };
reasonCell.alignment = { wrapText: true, vertical: 'top' };
});
// 加宽各列(未列在映射中的列给默认宽度
// 加宽各列,避免内容拥挤(仅改列宽,不改动单元格样式
Object.keys(colMap).forEach(name => {
const col = ws.getColumn(colMap[name]);
col.width = CARGO_TYPE_FAIL_COL_WIDTH[name] || 18;
col.width = CARGO_TYPE_FAIL_COL_WIDTH[name] || 20;
});
};