fix(oid): передаём статус СТ в поток оповещения (не читаем из SP)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -223,9 +223,9 @@ export function useStep4Approval(args: UseStep4ApprovalArgs) {
|
|||||||
comment.trim()
|
comment.trim()
|
||||||
);
|
);
|
||||||
|
|
||||||
const notify = async (spId: number): Promise<void> => {
|
const notify = async (spId: number, statusForFlow: string): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
await service.triggerApprovalNotification(spId);
|
await service.triggerApprovalNotification(spId, statusForFlow);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[Step4] notify failed for spId", spId, e);
|
console.error("[Step4] notify failed for spId", spId, e);
|
||||||
setNotifyWarning(
|
setNotifyWarning(
|
||||||
@@ -262,17 +262,17 @@ export function useStep4Approval(args: UseStep4ApprovalArgs) {
|
|||||||
await service.updateOIDStatus(oid!.id, "approved");
|
await service.updateOIDStatus(oid!.id, "approved");
|
||||||
onSave({ oid: { ...oid!, status: "approved" }, approvalChain: updatedChain });
|
onSave({ oid: { ...oid!, status: "approved" }, approvalChain: updatedChain });
|
||||||
if (currentMember.spApprovalId) {
|
if (currentMember.spApprovalId) {
|
||||||
await notify(currentMember.spApprovalId);
|
await notify(currentMember.spApprovalId, "Согласовано");
|
||||||
}
|
}
|
||||||
onStepComplete(4);
|
onStepComplete(4);
|
||||||
} else {
|
} else {
|
||||||
const nextPending = updatedChain.find((m) => m.status === "pending");
|
const nextPending = updatedChain.find((m) => m.status === "pending");
|
||||||
if (nextPending) {
|
if (nextPending) {
|
||||||
if (currentMember.spApprovalId) {
|
if (currentMember.spApprovalId) {
|
||||||
await notify(currentMember.spApprovalId);
|
await notify(currentMember.spApprovalId, "На согласовании");
|
||||||
}
|
}
|
||||||
if (nextPending.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" },
|
oid: { ...oid!, status: "rejected" },
|
||||||
});
|
});
|
||||||
const initiator = finalChain.find((m) => m.role === "Инициатор");
|
const initiator = finalChain.find((m) => m.role === "Инициатор");
|
||||||
if (initiator?.spApprovalId) await notify(initiator.spApprovalId);
|
if (initiator?.spApprovalId) await notify(initiator.spApprovalId, "Отклонено");
|
||||||
}
|
}
|
||||||
|
|
||||||
closeActionDialog();
|
closeActionDialog();
|
||||||
@@ -350,7 +350,7 @@ export function useStep4Approval(args: UseStep4ApprovalArgs) {
|
|||||||
);
|
);
|
||||||
if (firstApprover?.spApprovalId) {
|
if (firstApprover?.spApprovalId) {
|
||||||
try {
|
try {
|
||||||
await service.triggerApprovalNotification(firstApprover.spApprovalId);
|
await service.triggerApprovalNotification(firstApprover.spApprovalId, "На согласовании");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[Step4] notify (send) failed", e);
|
console.error("[Step4] notify (send) failed", e);
|
||||||
setNotifyWarning(
|
setNotifyWarning(
|
||||||
|
|||||||
@@ -1250,14 +1250,17 @@ export class OidService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async triggerApprovalNotification(spItemId: number): Promise<void> {
|
// status — финальный статус СТ («Согласовано»/«На согласовании»/«Отклонено»), который поток
|
||||||
|
// использует для выбора ветки. Передаём явно, чтобы поток НЕ перечитывал статус из SharePoint
|
||||||
|
// (коннектор может вернуть устаревшее значение сразу после записи — read-after-write lag).
|
||||||
|
async triggerApprovalNotification(spItemId: number, status?: string): Promise<void> {
|
||||||
if (!FLOW_NOTIFY) return;
|
if (!FLOW_NOTIFY) return;
|
||||||
const client = await this.context.aadHttpClientFactory.getClient(
|
const client = await this.context.aadHttpClientFactory.getClient(
|
||||||
"https://service.flow.microsoft.com/",
|
"https://service.flow.microsoft.com/",
|
||||||
);
|
);
|
||||||
const res = await client.post(FLOW_NOTIFY, AadHttpClient.configurations.v1, {
|
const res = await client.post(FLOW_NOTIFY, AadHttpClient.configurations.v1, {
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ RowID: spItemId }),
|
body: JSON.stringify({ RowID: spItemId, status: status ?? "" }),
|
||||||
});
|
});
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const text = await res.text().catch(() => "");
|
const text = await res.text().catch(() => "");
|
||||||
|
|||||||
Reference in New Issue
Block a user