feat(client): 部门管理与员工创建增强(F32)

- 新增部门管理页:列表/创建/归档
- 用户创建支持选择部门与直属上级
- 补齐 departments/employees API 封装与导航入口
这个提交包含在:
2026-02-09 18:24:07 +08:00
父节点 1a5d3b1d52
当前提交 efa4a3d3f6
共修改 7 个文件,包含 411 行新增和 3 行删除
+52
查看文件
@@ -0,0 +1,52 @@
import { apiRequestData } from "./http";
export type DepartmentItem = {
id: string;
name: string;
parentId: string | null;
archivedAt: string | null;
createdAt: string | null;
updatedAt: string | null;
};
export type DepartmentTreeNode = DepartmentItem & {
children: DepartmentTreeNode[];
};
export type DepartmentListResponse = {
includeArchived: boolean;
items: DepartmentItem[];
tree: DepartmentTreeNode[];
};
export async function fetchDepartments(params: { includeArchived?: boolean } = {}) {
const search = new URLSearchParams();
if (params.includeArchived != null) {
search.set("includeArchived", params.includeArchived ? "1" : "0");
}
const qs = search.toString();
return apiRequestData<DepartmentListResponse>(`/api/departments${qs ? `?${qs}` : ""}`);
}
export async function createDepartment(payload: { name: string; parentId?: string | null }) {
return apiRequestData<DepartmentItem>("/api/departments", {
method: "POST",
body: JSON.stringify(payload),
});
}
export async function updateDepartment(departmentId: string, payload: { name?: string; parentId?: string | null }) {
return apiRequestData<DepartmentItem>(`/api/departments/${departmentId}`, {
method: "PATCH",
body: JSON.stringify(payload),
});
}
export async function archiveDepartment(departmentId: string) {
return apiRequestData<DepartmentItem>(`/api/departments/${departmentId}/archive`, {
method: "POST",
body: JSON.stringify({}),
});
}