feat(cargo-type): 优化导入失败明细备注超长与标红逻辑

- 仅导入失败原因列显示红色字体,清除其他列红色样式
- 失败原因按 A./B./C. 编号,使用分号分隔
- 错误文本已包含规则说明则不重复添加
- 备注超长(>200字)自动追加“备注不能超过200字”提示
- Node 端验证通过,保证格式和样式正确
- 备注超长校验提醒后端改进收集式校验待确认
This commit is contained in:
2026-07-28 00:47:23 +08:00
parent 8002fe3d50
commit 38ce8fa2bc
2 changed files with 19 additions and 1 deletions

View File

@@ -222,8 +222,20 @@ export const decorateCargoTypeFailDetail = async workbook => {
const decorated = parts.map((part, index) => {
const label = `${String.fromCharCode(65 + index)}.`; // A. B. C.
const rule = CARGO_TYPE_FAIL_RULES.find(r => part.includes(r.match));
return rule ? `${label}${part}${rule.rule}` : `${label}${part}`;
if (rule) {
// 规则说明若已包含在错误文本中则不再重复拼接
return part.includes(rule.rule) ? `${label}${part}` : `${label}${part}${rule.rule}`;
}
return `${label}${part}`;
});
// 兜底:失败行的备注列超长(>200字补充备注超长提示
const remarkCol = colMap['备注'];
if (remarkCol) {
const remarkVal = String(row.getCell(remarkCol).value == null ? '' : row.getCell(remarkCol).value).trim();
if (remarkVal.length > 200 && !decorated.some(d => d.includes('备注不能超过200字'))) {
decorated.push(`${String.fromCharCode(65 + decorated.length)}.备注不能超过200字`);
}
}
reasonCell.value = `${rowNumber}行:${decorated.join('')}`;
reasonCell.font = { color: { argb: 'FFFF0000' } };
reasonCell.alignment = { wrapText: true, vertical: 'top' };