feat(client): 部门管理与员工创建增强(F32)
- 新增部门管理页:列表/创建/归档 - 用户创建支持选择部门与直属上级 - 补齐 departments/employees API 封装与导航入口
这个提交包含在:
@@ -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({}),
|
||||
});
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户