From e610ab2768cfa1961cc77d840c1ac6896e5d231b Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 13 Sep 2022 16:17:32 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D1=80=D0=BE=D0=BF=20multiple=20=D0=B2=20UploadF?= =?UTF-8?q?orm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UploadForm.tsx | 8 +++++--- src/pages/Documents/DocumentsTemplate.jsx | 1 + src/pages/DrillingProgram/CategoryRender.jsx | 1 + src/pages/WellOperations/ImportOperations.jsx | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/UploadForm.tsx b/src/components/UploadForm.tsx index b92e29f..8c9efae 100644 --- a/src/components/UploadForm.tsx +++ b/src/components/UploadForm.tsx @@ -10,6 +10,7 @@ import { notify, upload } from './factory' import { ErrorFetch } from './ErrorFetch' export type UploadFormProps = { + multiple?: boolean url: string disabled?: boolean accept?: string @@ -22,7 +23,7 @@ export type UploadFormProps = { onUploadError?: (error: unknown) => void } -export const UploadForm = memo(({ url, disabled, style, formData, mimeTypes, onUploadStart, onUploadSuccess, onUploadComplete, onUploadError }) => { +export const UploadForm = memo(({ url, multiple, disabled, style, formData, mimeTypes, onUploadStart, onUploadSuccess, onUploadComplete, onUploadError }) => { const [fileList, setfileList] = useState[]>([]) const checkMimeTypes = useCallback((file: RcFile) => { @@ -38,7 +39,7 @@ export const UploadForm = memo(({ url, disabled, style, formDat onUploadStart?.() try { const formDataLocal = new FormData() - fileList.forEach((val) => formDataLocal.append('files', val.originFileObj as Blob)) + fileList.forEach((val) => formDataLocal.append(multiple ? 'files' : 'file', val.originFileObj as Blob)) if(formData) for(const propName in formData) @@ -60,7 +61,7 @@ export const UploadForm = memo(({ url, disabled, style, formDat setfileList([]) onUploadComplete?.() } - }, [fileList, formData, onUploadComplete, onUploadError, onUploadStart, onUploadSuccess, url]) + }, [fileList, formData, onUploadComplete, onUploadError, onUploadStart, onUploadSuccess, url, multiple]) const isSendButtonEnabled = fileList.length > 0 return( @@ -72,6 +73,7 @@ export const UploadForm = memo(({ url, disabled, style, formDat fileList={fileList} onChange={(props) => setfileList(props.fileList)} beforeUpload={checkMimeTypes} + maxCount={multiple ? undefined : 1} > diff --git a/src/pages/Documents/DocumentsTemplate.jsx b/src/pages/Documents/DocumentsTemplate.jsx index c98e45b..dbb4576 100755 --- a/src/pages/Documents/DocumentsTemplate.jsx +++ b/src/pages/Documents/DocumentsTemplate.jsx @@ -137,6 +137,7 @@ export const DocumentsTemplate = ({ idCategory, well: givenWell, mimeTypes, head
Загрузка setShowLoader(true)} diff --git a/src/pages/DrillingProgram/CategoryRender.jsx b/src/pages/DrillingProgram/CategoryRender.jsx index a161f28..db5b2d4 100755 --- a/src/pages/DrillingProgram/CategoryRender.jsx +++ b/src/pages/DrillingProgram/CategoryRender.jsx @@ -123,6 +123,7 @@ export const CategoryRender = memo(({ partData, onUpdate, onEdit, onHistory, set
{permissionToUpload && ( { Очистить список операций перед импортом