czh-20260709-增加进行中逾期任务数量显示
This commit is contained in:
@@ -3,20 +3,31 @@ export interface FeedbackStatusCount {
|
||||
inProgress: number;
|
||||
completed: number;
|
||||
total: number;
|
||||
overdue: number;
|
||||
}
|
||||
|
||||
export function countFeedbackStatus(
|
||||
list: Recordable[] | undefined | null,
|
||||
statusField: string,
|
||||
dateField?: string,
|
||||
): FeedbackStatusCount {
|
||||
const result: FeedbackStatusCount = { notStarted: 0, inProgress: 0, completed: 0, total: 0 };
|
||||
const result: FeedbackStatusCount = { notStarted: 0, inProgress: 0, completed: 0, total: 0, overdue: 0 };
|
||||
if (!Array.isArray(list)) return result;
|
||||
result.total = list.length;
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
for (const item of list) {
|
||||
const v = String(item?.[statusField] ?? '');
|
||||
if (v === '1') result.notStarted++;
|
||||
else if (v === '2') result.inProgress++;
|
||||
else if (v === '3') result.completed++;
|
||||
else if (v === '2') {
|
||||
result.inProgress++;
|
||||
if (dateField) {
|
||||
const planTime = item?.[dateField];
|
||||
if (planTime && new Date(planTime) < today) {
|
||||
result.overdue++;
|
||||
}
|
||||
}
|
||||
} else if (v === '3') result.completed++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user