feat(training): 新增精益培训周任务视频推送与定向提醒闭环
- 后端:新增周任务视频推送服务与定时任务,新增模型迁移 fb26bc033d27 - 配置:WECOM_NOTIFY_EVENTS 追加 training_lean_video_push 事件(dev/test/prod/shared 同步) - 管理端:培训配置页新增定向目标弹窗 LeanTargetModal - 工作台:完成看板提醒按钮按 sent/failed 实发统计如实提示(部分成功/失败/未发送),避免企微发送失败误报成功 - 文档:更新功能清单与技术架构,新增精益管理周任务规则手册;四语言 i18n 同步补齐
This commit is contained in:
1 parent
a0e4351e9a
commit
7927556ee2
34 files changed
+2039
-254
No files matched your search
@@ -17,6 +17,8 @@ import type {
|
||||
TrainingStats,
|
||||
LeanTrainingDashboard,
|
||||
LeanTrainingDashboardRow,
|
||||
LeanTrainingMyTask,
|
||||
LeanTrainingTaskStatus,
|
||||
LeanTrainingWeeklyTask,
|
||||
TrainingType,
|
||||
TrainingTypeOption,
|
||||
@@ -25,19 +27,40 @@ import type {
|
||||
type LeanTrainingTaskApi = {
|
||||
id: number; week_key: string; due_at: string; video_resource_ids: number[];
|
||||
target_roles: string[]; target_user_ids: number[];
|
||||
videos: Array<{ id: number; name: string }>; status: string; min_summary_length: number;
|
||||
videos: Array<{ id: number; name: string; file_url?: string | null }>; status: string; min_summary_length: number;
|
||||
weekly_count?: number; pushed_video_count?: number;
|
||||
week_end?: string | null; week_index?: number;
|
||||
};
|
||||
|
||||
type LeanTrainingMyTaskApi = LeanTrainingTaskApi & {
|
||||
task_status: LeanTrainingTaskStatus;
|
||||
completion: { summary_text: string; watched_at: Record<string, string>; completed_at?: string | null } | null;
|
||||
};
|
||||
|
||||
type LeanTrainingDashboardRowApi = {
|
||||
id?: number; user_id: number; employee_id?: string | null; name: string; department?: string | null;
|
||||
videos: Array<{ name: string; watched_at?: string | null }>;
|
||||
summary_text?: string | null; status: 'completed' | 'incomplete'; completed_at?: string | null;
|
||||
// 后端序列化层三态归一:completed=已提交感悟;overdue=过截止未完成;in_progress=进行中
|
||||
summary_text?: string | null; status: 'completed' | 'in_progress' | 'overdue'; completed_at?: string | null;
|
||||
};
|
||||
|
||||
const mapLeanTask = (data: LeanTrainingTaskApi): LeanTrainingWeeklyTask => ({
|
||||
id: data.id, weekKey: data.week_key, dueAt: data.due_at, videoResourceIds: data.video_resource_ids || [],
|
||||
targetRoles: data.target_roles || [], targetUserIds: data.target_user_ids || [],
|
||||
videos: data.videos || [], status: data.status, minSummaryLength: data.min_summary_length,
|
||||
videos: (data.videos || []).map((video) => ({ id: video.id, name: video.name, fileUrl: video.file_url || null })),
|
||||
status: data.status, minSummaryLength: data.min_summary_length,
|
||||
weeklyCount: data.weekly_count, pushedVideoCount: data.pushed_video_count,
|
||||
weekEnd: data.week_end ?? null, weekIndex: data.week_index,
|
||||
});
|
||||
|
||||
const mapLeanMyTask = (data: LeanTrainingMyTaskApi): LeanTrainingMyTask => ({
|
||||
...mapLeanTask(data),
|
||||
taskStatus: data.task_status,
|
||||
completion: data.completion ? {
|
||||
summaryText: data.completion.summary_text,
|
||||
watchedAt: data.completion.watched_at || {},
|
||||
completedAt: data.completion.completed_at || null,
|
||||
} : null,
|
||||
});
|
||||
|
||||
const mapLeanDashboardRow = (data: LeanTrainingDashboardRowApi): LeanTrainingDashboardRow => ({
|
||||
@@ -256,9 +279,17 @@ export async function getMyTrainingTypes(): Promise<TrainingTypeOption[]> {
|
||||
return requestJson<TrainingTypeOption[]>('/api/user/training-types', authHeaders());
|
||||
}
|
||||
|
||||
export async function getCurrentLeanTrainingTask(): Promise<LeanTrainingWeeklyTask | null> {
|
||||
const response = await requestJson<LeanTrainingTaskApi | null>('/api/user/lean-training/current-task', authHeaders());
|
||||
return response ? mapLeanTask(response) : null;
|
||||
export async function getMyLeanTrainingTasks(): Promise<LeanTrainingMyTask[]> {
|
||||
const response = await requestJson<LeanTrainingMyTaskApi[]>('/api/user/lean-training/my-tasks', authHeaders());
|
||||
return (response || []).map(mapLeanMyTask);
|
||||
}
|
||||
|
||||
export async function markMyLeanVideoWatched(weeklyTaskId: number, resourceId: number): Promise<void> {
|
||||
await requestJson<{ watched_at: Record<string, string> }>('/api/user/lean-training/my-tasks/watched', {
|
||||
method: 'POST',
|
||||
...jsonAuthHeaders(),
|
||||
body: JSON.stringify({ weekly_task_id: weeklyTaskId, resource_id: resourceId }),
|
||||
});
|
||||
}
|
||||
|
||||
export async function saveMyLeanTrainingCompletion(payload: { weeklyTaskId: number; watchedAt: Record<string, string>; summaryText: string }): Promise<LeanTrainingDashboardRow> {
|
||||
@@ -268,13 +299,21 @@ export async function saveMyLeanTrainingCompletion(payload: { weeklyTaskId: numb
|
||||
return mapLeanDashboardRow(response);
|
||||
}
|
||||
|
||||
export async function getLeanTrainingDashboard(): Promise<LeanTrainingDashboard> {
|
||||
const response = await requestJson<{ task: LeanTrainingTaskApi | null; completed: LeanTrainingDashboardRowApi[]; incomplete: LeanTrainingDashboardRowApi[] }>('/api/admin/lean-training/dashboard', authHeaders());
|
||||
return { task: response.task ? mapLeanTask(response.task) : null, completed: (response.completed || []).map(mapLeanDashboardRow), incomplete: (response.incomplete || []).map(mapLeanDashboardRow) };
|
||||
export async function getLeanTrainingDashboard(taskId?: number): Promise<LeanTrainingDashboard> {
|
||||
// task_id 为空时后端返回最新一期;periods 为全部期次摘要(期号按周次升序),供管理端下拉切换第几期。
|
||||
const query = taskId ? `?task_id=${taskId}` : '';
|
||||
const response = await requestJson<{ task: LeanTrainingTaskApi | null; completed: LeanTrainingDashboardRowApi[]; incomplete: LeanTrainingDashboardRowApi[]; periods?: Array<{ id: number; week_key: string; index: number }> }>(`/api/admin/lean-training/dashboard${query}`, authHeaders());
|
||||
return {
|
||||
task: response.task ? mapLeanTask(response.task) : null,
|
||||
completed: (response.completed || []).map(mapLeanDashboardRow),
|
||||
incomplete: (response.incomplete || []).map(mapLeanDashboardRow),
|
||||
periods: (response.periods || []).map((period) => ({ id: period.id, weekKey: period.week_key, index: period.index })),
|
||||
};
|
||||
}
|
||||
|
||||
export async function sendLeanTrainingReminders(weeklyTaskId: number, userIds: number[]): Promise<{ created: number; skipped: number; failed: number }> {
|
||||
return requestJson<{ created: number; skipped: number; failed: number }>(`/api/admin/lean-training/weekly-tasks/${weeklyTaskId}/reminders`, {
|
||||
/** HR 对指定成员发起精益培训定向提醒;返回后端实发统计(sent/failed 才是真实送达情况,created 含发送失败)。 */
|
||||
export async function sendLeanTrainingReminders(weeklyTaskId: number, userIds: number[]): Promise<{ created: number; sent: number; skipped: number; failed: number }> {
|
||||
return requestJson<{ created: number; sent: number; skipped: number; failed: number }>(`/api/admin/lean-training/weekly-tasks/${weeklyTaskId}/reminders`, {
|
||||
method: 'POST',
|
||||
...jsonAuthHeaders(),
|
||||
body: JSON.stringify({ user_ids: userIds }),
|
||||
|
||||
Reference in new issue
Block a user