feat: refine client status and review views

This commit is contained in:
hectorzhao
2026-08-27 17:32:05 +08:00
parent d6edb88b76
commit 01cffa4758
31 changed files with 528 additions and 117 deletions
+29
View File
@@ -0,0 +1,29 @@
export type BatchTaskDisplayStatus = 'pending_review' | 'scheduled' | 'waiting' | 'sending' | 'completed' | 'rejected' | 'canceled' | 'failed' | 'unknown';
export const batchTaskStatusMeta: Record<BatchTaskDisplayStatus, { label: string; tone: 'warning' | 'info' | 'success' | 'danger' | 'neutral' }> = {
pending_review: { label: '待人工审核', tone: 'warning' },
scheduled: { label: '等待定时发送', tone: 'warning' },
waiting: { label: '等待发送', tone: 'info' },
sending: { label: '发送中', tone: 'info' },
completed: { label: '已完成', tone: 'success' },
rejected: { label: '审核驳回', tone: 'danger' },
canceled: { label: '已取消', tone: 'neutral' },
failed: { label: '发送失败', tone: 'danger' },
unknown: { label: '未知状态', tone: 'neutral' },
};
export function normalizeBatchTaskStatus(status: string): BatchTaskDisplayStatus {
if (status === 'pending_review') return 'pending_review';
if (status === 'scheduled') return 'scheduled';
if (['ready', 'queued', 'created'].includes(status)) return 'waiting';
if (['sending', 'submitted'].includes(status)) return 'sending';
if (['completed', 'finished', 'done'].includes(status)) return 'completed';
if (status === 'rejected') return 'rejected';
if (['canceled', 'cancelled', 'terminated'].includes(status)) return 'canceled';
if (status === 'failed') return 'failed';
return 'unknown';
}
export function canClientCancelBatchTask(status: string) {
return status === 'scheduled';
}
+12
View File
@@ -20,3 +20,15 @@ export function formatDateTime(value?: string | Date | null) {
);
return `${parts.year}-${parts.month}-${parts.day} ${parts.hour}:${parts.minute}:${parts.second}`;
}
const beijingDateFormatter = new Intl.DateTimeFormat('en-CA', {
day: '2-digit', month: '2-digit', timeZone: 'Asia/Shanghai', year: 'numeric',
});
export function recentBeijingDateRange(days = 7) {
const now = Date.now();
return {
start: beijingDateFormatter.format(new Date(now - (Math.max(1, days) - 1) * 86_400_000)),
end: beijingDateFormatter.format(new Date(now)),
};
}