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;