From 5e90b8f3d7f583818d14981a62c921ec99412ff7 Mon Sep 17 00:00:00 2001 From: jokerxue <2509699647@qq.com> Date: Wed, 13 May 2026 14:15:21 +0800 Subject: [PATCH] 1 --- 美国版/Food Labeling Management Platform/src/services/teamMemberService.ts | 53 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/美国版/Food Labeling Management Platform/src/services/teamMemberService.ts b/美国版/Food Labeling Management Platform/src/services/teamMemberService.ts index b5ac7e0..5f9c731 100644 --- a/美国版/Food Labeling Management Platform/src/services/teamMemberService.ts +++ b/美国版/Food Labeling Management Platform/src/services/teamMemberService.ts @@ -1,4 +1,4 @@ -import { createApiClient } from "../lib/apiClient"; +import { ApiError, createApiClient } from "../lib/apiClient"; import { authorizedGetBlobDownload, authorizedPostMultipartJson } from "../lib/batchFileHttp"; import type { PagedResultDto, @@ -308,14 +308,53 @@ export async function importTeamMembersBatch(file: File, signal?: AbortSignal): }); } +function bulkItemToUpdateInput(item: TeamMemberBulkUpdateItemVo): TeamMemberUpdateInput { + const phoneStr = item.phone == null ? null : String(item.phone).trim() || null; + const input: TeamMemberUpdateInput = { + fullName: item.fullName, + userName: item.userName, + email: item.email ?? null, + phone: phoneStr, + roleId: item.roleId, + locationIds: item.locationIds ?? [], + state: item.state, + }; + if (item.password && String(item.password).trim()) { + input.password = item.password; + } + return input; +} + +// 部分环境 bulk 路径与 `PUT /team-member/{id}` 冲突;不改后端时改为逐条 PUT。 export async function updateTeamMembersBulk( body: { items: TeamMemberBulkUpdateItemVo[] }, ): Promise { - // ABP 约定控制器:`Update*Async` 多为 PUT,POST 会 405 - return api.requestJson({ - path: `${PATH}/update-team-members-bulk`, - method: "PUT", - body, - }); + const ZERO = "00000000-0000-0000-0000-000000000000"; + const errors: NonNullable = []; + let successCount = 0; + let failCount = 0; + + for (let i = 0; i < body.items.length; i += 1) { + const item = body.items[i]; + const rowNumber = i + 1; + const id = (item.id ?? "").trim(); + if (!id || id.toLowerCase() === ZERO) continue; + + try { + await updateTeamMember(id, bulkItemToUpdateInput(item)); + successCount += 1; + } catch (e) { + failCount += 1; + const message = + e instanceof ApiError ? e.message : e instanceof Error ? e.message : "Update failed."; + errors.push({ rowNumber, id, message }); + } + } + + return { + successCount, + failCount, + errors: errors.length ? errors : undefined, + }; } -- libgit2 0.21.4