R41: 完成员工批量导入

这个提交包含在:
2026-03-28 18:57:02 +08:00
父节点 2eff8e01a2
当前提交 3cf8b43f74
共修改 7 个文件,包含 1477 行新增和 63 行删除
+67
查看文件
@@ -23,6 +23,55 @@ export type UserListResponse = {
items: UserSummary[];
};
export type UserImportRowError = {
field: string;
message: string;
};
export type UserImportPreviewRow = {
rowNumber: number;
employeeNo: string;
name: string;
normalized: {
employeeNo: string;
name: string;
phone: string;
email: string;
departmentName: string;
title: string;
directManagerEmployeeNo: string;
roles: string[];
hireDate: string;
};
errors: UserImportRowError[];
};
export type UserImportDryRunResult = {
sourceFilename: string;
summary: {
totalRows: number;
validRows: number;
invalidRows: number;
};
rows: UserImportPreviewRow[];
};
export type UserImportApplyResult = {
sourceFilename: string;
summary: {
totalRows: number;
validRows: number;
invalidRows: number;
};
imported: Array<{
employeeId: string;
employeeNo: string;
name: string;
email: string;
oneTimePassword: string;
}>;
};
export async function fetchUsers(params: {
page: number;
pageSize: number;
@@ -82,3 +131,21 @@ export async function setUserRoles(userId: string, roles: string[]) {
body: JSON.stringify({ roles }),
});
}
export async function dryRunUserImport(file: File) {
const formData = new FormData();
formData.append("file", file);
return apiRequestData<UserImportDryRunResult>("/api/users/import/dry-run", {
method: "POST",
body: formData,
});
}
export async function applyUserImport(file: File) {
const formData = new FormData();
formData.append("file", file);
return apiRequestData<UserImportApplyResult>("/api/users/import/apply", {
method: "POST",
body: formData,
});
}