From a3ffaf696ac5c60c84c0520843de4868bffefbf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B8=D0=BC=D1=83=D1=80=20=D0=93=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5=D1=86=D0=BA=D0=B8=D0=B9?= Date: Fri, 4 Sep 2026 09:49:26 +0500 Subject: [PATCH] =?UTF-8?q?fix(oid):=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B0=D1=91=D0=BC=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=20?= =?UTF-8?q?=D0=A1=D0=A2=20=D0=B2=20=D0=BF=D0=BE=D1=82=D0=BE=D0=BA=20=D0=BE?= =?UTF-8?q?=D0=BF=D0=BE=D0=B2=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20(?= =?UTF-8?q?=D0=BD=D0=B5=20=D1=87=D0=B8=D1=82=D0=B0=D0=B5=D0=BC=20=D0=B8?= =?UTF-8?q?=D0=B7=20SP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../components/Step4Approval/useStep4Approval.ts | 14 +++++++------- .../ctFormsPortal/forms/oid/services/OidService.ts | 7 +++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/webparts/ctFormsPortal/forms/oid/components/Step4Approval/useStep4Approval.ts b/src/webparts/ctFormsPortal/forms/oid/components/Step4Approval/useStep4Approval.ts index c80bbbd..7dac6c7 100644 --- a/src/webparts/ctFormsPortal/forms/oid/components/Step4Approval/useStep4Approval.ts +++ b/src/webparts/ctFormsPortal/forms/oid/components/Step4Approval/useStep4Approval.ts @@ -223,9 +223,9 @@ export function useStep4Approval(args: UseStep4ApprovalArgs) { comment.trim() ); - const notify = async (spId: number): Promise => { + const notify = async (spId: number, statusForFlow: string): Promise => { try { - await service.triggerApprovalNotification(spId); + await service.triggerApprovalNotification(spId, statusForFlow); } catch (e) { console.error("[Step4] notify failed for spId", spId, e); setNotifyWarning( @@ -262,17 +262,17 @@ export function useStep4Approval(args: UseStep4ApprovalArgs) { await service.updateOIDStatus(oid!.id, "approved"); onSave({ oid: { ...oid!, status: "approved" }, approvalChain: updatedChain }); if (currentMember.spApprovalId) { - await notify(currentMember.spApprovalId); + await notify(currentMember.spApprovalId, "Согласовано"); } onStepComplete(4); } else { const nextPending = updatedChain.find((m) => m.status === "pending"); if (nextPending) { if (currentMember.spApprovalId) { - await notify(currentMember.spApprovalId); + await notify(currentMember.spApprovalId, "На согласовании"); } if (nextPending.spApprovalId) { - await notify(nextPending.spApprovalId); + await notify(nextPending.spApprovalId, "На согласовании"); } } } @@ -305,7 +305,7 @@ export function useStep4Approval(args: UseStep4ApprovalArgs) { oid: { ...oid!, status: "rejected" }, }); const initiator = finalChain.find((m) => m.role === "Инициатор"); - if (initiator?.spApprovalId) await notify(initiator.spApprovalId); + if (initiator?.spApprovalId) await notify(initiator.spApprovalId, "Отклонено"); } closeActionDialog(); @@ -350,7 +350,7 @@ export function useStep4Approval(args: UseStep4ApprovalArgs) { ); if (firstApprover?.spApprovalId) { try { - await service.triggerApprovalNotification(firstApprover.spApprovalId); + await service.triggerApprovalNotification(firstApprover.spApprovalId, "На согласовании"); } catch (e) { console.error("[Step4] notify (send) failed", e); setNotifyWarning( diff --git a/src/webparts/ctFormsPortal/forms/oid/services/OidService.ts b/src/webparts/ctFormsPortal/forms/oid/services/OidService.ts index b3e868a..34b277e 100644 --- a/src/webparts/ctFormsPortal/forms/oid/services/OidService.ts +++ b/src/webparts/ctFormsPortal/forms/oid/services/OidService.ts @@ -1250,14 +1250,17 @@ export class OidService { ); } - async triggerApprovalNotification(spItemId: number): Promise { + // status — финальный статус СТ («Согласовано»/«На согласовании»/«Отклонено»), который поток + // использует для выбора ветки. Передаём явно, чтобы поток НЕ перечитывал статус из SharePoint + // (коннектор может вернуть устаревшее значение сразу после записи — read-after-write lag). + async triggerApprovalNotification(spItemId: number, status?: string): Promise { if (!FLOW_NOTIFY) return; const client = await this.context.aadHttpClientFactory.getClient( "https://service.flow.microsoft.com/", ); const res = await client.post(FLOW_NOTIFY, AadHttpClient.configurations.v1, { headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ RowID: spItemId }), + body: JSON.stringify({ RowID: spItemId, status: status ?? "" }), }); if (!res.ok) { const text = await res.text().catch(() => "");