39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
/**
|
|
* shared/utils/schedule-run-display.utils.ts
|
|
* 用途:排程 run 列表展示辅助(失败计数、Excel 导出状态等)。
|
|
* 依赖:无。
|
|
* 逻辑:管理端 ScheduleWorkbenchPanel、工作台 ScheduleRunsPage 等复用。
|
|
*/
|
|
|
|
type ScheduleRunSummaryCarrier = {
|
|
failed_count?: number | null;
|
|
response_summary_json?: Record<string, unknown> | null;
|
|
};
|
|
|
|
/**
|
|
* 判断排程 run 是否因 Excel 汇总导出失败而标记 partial_failed(源数据可能已全部成功)。
|
|
* 核心逻辑:读取 response_summary_json.excel_failed 或 excel_export_status=failed。
|
|
*/
|
|
export function isScheduleRunExcelExportFailed(run: ScheduleRunSummaryCarrier | null | undefined): boolean {
|
|
const summary = run?.response_summary_json;
|
|
if (!summary || typeof summary !== 'object') return false;
|
|
if (summary.excel_failed === true) return true;
|
|
return summary.excel_export_status === 'failed';
|
|
}
|
|
|
|
/**
|
|
* 生成失败数列 title,含 Excel 汇总层失败说明。
|
|
* @param run - 排程 run 记录
|
|
* @param excelFailedHint - 已翻译的 Excel 失败提示文案
|
|
*/
|
|
export function getScheduleRunFailedCountTitle(
|
|
run: ScheduleRunSummaryCarrier | null | undefined,
|
|
excelFailedHint: string,
|
|
): string {
|
|
const failed = run?.failed_count ?? 0;
|
|
if (!isScheduleRunExcelExportFailed(run)) {
|
|
return String(failed);
|
|
}
|
|
return `${failed} (${excelFailedHint})`;
|
|
}
|