From 7341774e50dbabaa426f6305ad88356913d32ffb 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: Tue, 27 Oct 2026 15:59:25 +0500 Subject: [PATCH] =?UTF-8?q?fix(ct):=20=D1=81=D0=BD=D1=8F=D1=82=D1=8B=D0=B9?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=20=D0=BF=D0=BE=D0=B1=D0=B5?= =?UTF-8?q?=D0=B4=D0=B8=D1=82=D0=B5=D0=BB=D1=8F=20=D0=BD=D0=B5=20=D0=B2?= =?UTF-8?q?=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89=D0=B0=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20F5=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Выбор победителя жил только в состоянии таблицы и попадал в данные формы лишь по «Сохранить». После F5 сессия не знала, что выбор сняли, и форма подставляла победителя из шапки СТ. Теперь выбор и снятие сразу пишутся в данные формы, как статус и исключение поставщика, а победитель из шапки СТ берётся только когда сессии нет (СТ открыта в другом браузере). Co-Authored-By: Claude Opus 5.5 (1M context) --- .../ctFormsPortal/forms/ct/components/CtCreateForm.tsx | 5 +++-- .../components/Step3ComparisonTable/useStep3Matrix.ts | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/webparts/ctFormsPortal/forms/ct/components/CtCreateForm.tsx b/src/webparts/ctFormsPortal/forms/ct/components/CtCreateForm.tsx index d33f566..7a9173e 100644 --- a/src/webparts/ctFormsPortal/forms/ct/components/CtCreateForm.tsx +++ b/src/webparts/ctFormsPortal/forms/ct/components/CtCreateForm.tsx @@ -191,8 +191,9 @@ const CtCreateForm: React.FC = ({ context, userDisplayName, noOfferFromSp, ); // Победитель обязателен для «Сохранить» на Шаге 3: без сессии берём его из шапки СТ, иначе - // в другом браузере пришлось бы выбирать заново. - const winnerColumnId = formData.recommendedSupplierId === undefined + // в другом браузере пришлось бы выбирать заново. Только когда сессии нет (колонки из SP): + // в сессии «не выбран» может быть осознанно снятым выбором — его SP не перебивает. + const winnerColumnId = formData.suppliers.length === 0 ? findWinnerColumnId(suppliers, ct.winSupplierSpId) : undefined; diff --git a/src/webparts/ctFormsPortal/forms/ct/components/Step3ComparisonTable/useStep3Matrix.ts b/src/webparts/ctFormsPortal/forms/ct/components/Step3ComparisonTable/useStep3Matrix.ts index 0a21519..ee080a8 100644 --- a/src/webparts/ctFormsPortal/forms/ct/components/Step3ComparisonTable/useStep3Matrix.ts +++ b/src/webparts/ctFormsPortal/forms/ct/components/Step3ComparisonTable/useStep3Matrix.ts @@ -95,9 +95,15 @@ export function useStep3Matrix(args: UseStep3MatrixArgs) { return map; }); - const [selectedSupplierId, setSelectedSupplierId] = useState( + const [selectedSupplierId, setSelectedSupplierIdState] = useState( formData.recommendedSupplierId ); + // Выбор победителя сразу пишем в formData, как статус и исключение поставщика: иначе снятый + // выбор жил только на экране, а после F5 возвращался из сессии или из шапки СТ. + const setSelectedSupplierId = useCallback((id: string | undefined): void => { + setSelectedSupplierIdState(id); + onSave({ recommendedSupplierId: id }); + }, [onSave]); const [isSaving, setIsSaving] = useState(false); const [saveError, setSaveError] = useState(undefined); // Тумблер «Перевести в ед. изм. заявки»: переводит кол-во и цену поставщика в ед. заявки. @@ -488,7 +494,7 @@ export function useStep3Matrix(args: UseStep3MatrixArgs) { } // Исключённый не может остаться выбранным — иначе он уйдёт победителем в шапку СТ. if (exclusion && selectedSupplierId === supplierId) setSelectedSupplierId(undefined); - }, [isReadOnly, suppliers, extraSuppliers, selectedSupplierId, onSave]); + }, [isReadOnly, suppliers, extraSuppliers, selectedSupplierId, setSelectedSupplierId, onSave]); const handleExcludeSupplier = useCallback((supplierId: string, reason: string): void => { if (!reason.trim()) return;