|
|
|
@@ -41,6 +41,7 @@ const FileUpload = ({ |
|
|
|
}, |
|
|
|
beforeUpload: (file: UploadFile) => { |
|
|
|
setFileList((pre) => { |
|
|
|
console.log(file); |
|
|
|
return [...pre, file]; |
|
|
|
}); |
|
|
|
|
|
|
|
@@ -68,11 +69,12 @@ const FileUpload = ({ |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
interface IFileUploadModalProps extends IModalProps<boolean> { |
|
|
|
interface IFileUploadModalProps extends Omit<IModalProps<boolean>, 'onOk'> { |
|
|
|
uploadFileList: UploadFile[]; |
|
|
|
setUploadFileList: Dispatch<SetStateAction<UploadFile[]>>; |
|
|
|
uploadProgress: number; |
|
|
|
setUploadProgress: Dispatch<SetStateAction<number>>; |
|
|
|
onOk?: (fileList: UploadFile[]) => Promise<boolean | void> | boolean | void; |
|
|
|
} |
|
|
|
|
|
|
|
const FileUploadModal = ({ |
|
|
|
@@ -80,19 +82,21 @@ const FileUploadModal = ({ |
|
|
|
hideModal, |
|
|
|
loading, |
|
|
|
onOk: onFileUploadOk, |
|
|
|
uploadFileList: fileList, |
|
|
|
setUploadFileList: setFileList, |
|
|
|
uploadProgress, |
|
|
|
setUploadProgress, |
|
|
|
}: IFileUploadModalProps) => { |
|
|
|
const { t } = useTranslate('fileManager'); |
|
|
|
const [value, setValue] = useState<string | number>('local'); |
|
|
|
const [parseOnCreation, setParseOnCreation] = useState(false); |
|
|
|
const [fileList, setFileList] = useState<UploadFile[]>([]); |
|
|
|
|
|
|
|
const clearFileList = () => { |
|
|
|
setFileList([]); |
|
|
|
setUploadProgress(0); |
|
|
|
if (typeof setUploadProgress === 'function') { |
|
|
|
setUploadProgress(0); |
|
|
|
} |
|
|
|
}; |
|
|
|
console.log(fileList); |
|
|
|
|
|
|
|
const onOk = async () => { |
|
|
|
if (uploadProgress === 100) { |
|
|
|
@@ -100,7 +104,7 @@ const FileUploadModal = ({ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const ret = await onFileUploadOk?.(parseOnCreation); |
|
|
|
const ret = await onFileUploadOk?.(fileList); |
|
|
|
return ret; |
|
|
|
}; |
|
|
|
|