diff --git a/src/page/ProtocolCreation/Page.tsx b/src/page/ProtocolCreation/Page.tsx index 3b57a80..0a3db08 100644 --- a/src/page/ProtocolCreation/Page.tsx +++ b/src/page/ProtocolCreation/Page.tsx @@ -212,16 +212,33 @@ const ProtocolForm: FC = ({ template, onSave, onBack }) => { const a = document.createElement('a') a.href = url - // Получаем имя файла из заголовка Content-Disposition или создаем по умолчанию - const contentDisposition = resp.headers.get('content-disposition') - let filename = `protocol_${template.name}_${new Date().toISOString().split('T')[0]}.xlsx` + // Получаем значение из ячейки R!A1 для имени файла + const filenameFromCell = engineRef.current.getCellValue('R', 0, 0) // R!A1 + console.log(filenameFromCell) + let filename = 'Измените R!A1.xlsx' + if ( + filenameFromCell && + typeof filenameFromCell === 'string' && + filenameFromCell.trim() + ) { + // Очищаем имя файла от недопустимых символов + const cleanName = filenameFromCell.trim().replace(/[<>:"/\\|?*]/g, '_') + filename = `${cleanName}.xlsx` + } + + // Если сервер передал имя файла в заголовке Content-Disposition, игнорируем его + // и используем строго значение из R!A1 + const contentDisposition = resp.headers.get('content-disposition') if (contentDisposition) { - const matches = contentDisposition.match( - /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/ - ) - if (matches && matches[1]) { - filename = matches[1].replace(/['"]/g, '') + // Оставляем возможность переопределения только если R!A1 пуста + if (!filenameFromCell || !filenameFromCell.toString().trim()) { + const matches = contentDisposition.match( + /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/ + ) + if (matches && matches[1]) { + filename = matches[1].replace(/['"]/g, '') + } } } diff --git a/src/widget/template/ui/TemplateCard.tsx b/src/widget/template/ui/TemplateCard.tsx index 3ad2182..6f7854c 100644 --- a/src/widget/template/ui/TemplateCard.tsx +++ b/src/widget/template/ui/TemplateCard.tsx @@ -143,7 +143,7 @@ const TemplateCard: React.FC = ({ }} > - {isConfigured ? 'Создать протокол' : 'Требует настройки'} + {isConfigured ? 'Создать' : 'Требует настройки'}