分类图片上传和用户等级图片上传
This commit is contained in:
@@ -14,6 +14,7 @@ import { useTranslation } from 'react-i18next';
|
||||
const ImageUploader: React.FC<ImageUploaderProps> = ({
|
||||
action,
|
||||
value,
|
||||
changeType,
|
||||
onChange,
|
||||
mode = 'single',
|
||||
disabled = false,
|
||||
@@ -115,9 +116,17 @@ const ImageUploader: React.FC<ImageUploaderProps> = ({
|
||||
.filter((file) => file.status === 'done' && file.response)
|
||||
.map((file) => file.response.data as ISysFileInfo);
|
||||
if( mode === 'single' ) {
|
||||
onChange?.(uploadedFiles[0]);
|
||||
if (changeType !== 'id') {
|
||||
onChange?.(uploadedFiles[0]);
|
||||
} else {
|
||||
onChange?.(uploadedFiles[0].id);
|
||||
}
|
||||
} else {
|
||||
onChange?.(uploadedFiles);
|
||||
if (changeType !== 'id') {
|
||||
onChange?.(uploadedFiles);
|
||||
} else {
|
||||
onChange?.(uploadedFiles.map(item => item.id!));
|
||||
}
|
||||
}
|
||||
// 上传失败的文件
|
||||
const errorFiles = newFileList.filter((file) => file.status === 'error');
|
||||
|
||||
@@ -17,11 +17,17 @@ export interface ImageUploaderProps {
|
||||
*/
|
||||
value?: ISysFileInfo | ISysFileInfo[] | null;
|
||||
|
||||
/**
|
||||
* 赋值类型
|
||||
* 上传完成后赋值的类型。
|
||||
*/
|
||||
changeType?: 'id' | 'object';
|
||||
|
||||
/**
|
||||
* 上传完成回调
|
||||
* @param value ISysFileInfo | ISysFileInfo[] | null
|
||||
*/
|
||||
onChange?: (value: ISysFileInfo | ISysFileInfo[] | null) => void;
|
||||
onChange?: (value?: ISysFileInfo | ISysFileInfo[] | number | number[] | null) => void;
|
||||
|
||||
/**
|
||||
* 上传模式
|
||||
@@ -65,9 +71,9 @@ export interface ImageUploaderProps {
|
||||
*/
|
||||
croppable?: boolean;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 剪裁参数
|
||||
*/
|
||||
cropperOptions?: Omit<ImgCropProps, 'children'>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user