feat: 完成 R13/R14/R15/R16 小团队管理核心能力
这个提交包含在:
@@ -0,0 +1,79 @@
|
||||
import { apiRequestData } from "./http";
|
||||
|
||||
export type TodoPriority = "low" | "normal" | "high";
|
||||
export type TodoStatus = "todo" | "doing" | "done" | "cancelled";
|
||||
export type TodoSource = "manual" | "weekly_report";
|
||||
|
||||
export type TodoItem = {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string | null;
|
||||
assigneeEmployeeId: string;
|
||||
createdBy: string;
|
||||
dueDate: string | null;
|
||||
priority: TodoPriority;
|
||||
status: TodoStatus;
|
||||
source: TodoSource;
|
||||
createdAt: string | null;
|
||||
updatedAt: string | null;
|
||||
completedAt: string | null;
|
||||
assignee: { id: string; employeeNo: string; name: string } | null;
|
||||
creator: { id: string; employeeNo: string; name: string } | null;
|
||||
};
|
||||
|
||||
export async function fetchTodos(params: {
|
||||
status?: TodoStatus;
|
||||
scope?: "mine" | "team";
|
||||
assigneeId?: string;
|
||||
q?: string;
|
||||
} = {}) {
|
||||
const search = new URLSearchParams();
|
||||
if (params.status) search.set("status", params.status);
|
||||
if (params.scope) search.set("scope", params.scope);
|
||||
if (params.assigneeId) search.set("assigneeId", params.assigneeId);
|
||||
if (params.q) search.set("q", params.q);
|
||||
const suffix = search.toString() ? `?${search.toString()}` : "";
|
||||
return apiRequestData<{ items: TodoItem[] }>(`/api/todos${suffix}`);
|
||||
}
|
||||
|
||||
export async function createTodo(payload: {
|
||||
title: string;
|
||||
description?: string | null;
|
||||
assigneeEmployeeId?: string;
|
||||
dueDate?: string | null;
|
||||
priority?: TodoPriority;
|
||||
source?: TodoSource;
|
||||
}) {
|
||||
return apiRequestData<{ item: TodoItem }>("/api/todos", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function patchTodo(id: string, payload: Partial<{
|
||||
title: string;
|
||||
description: string | null;
|
||||
assigneeEmployeeId: string;
|
||||
dueDate: string | null;
|
||||
priority: TodoPriority;
|
||||
status: TodoStatus;
|
||||
}>) {
|
||||
return apiRequestData<{ item: TodoItem }>(`/api/todos/${id}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function completeTodo(id: string) {
|
||||
return apiRequestData<{ item: TodoItem }>(`/api/todos/${id}/complete`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function cancelTodo(id: string) {
|
||||
return apiRequestData<{ item: TodoItem }>(`/api/todos/${id}/cancel`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户