import * as React from 'react';
import { fastMessage, FastUpload } from "components/ui";
import { verifyImage, uploadImg } from "utils/image";
import { isArray } from "utils/isType";
import { FormTypes } from "../../types";
function UploadImg(props: FormTypes.FormItem.FormAtomicUploadProps) {
const { config, values, validateTrigger } = props;
const { key, type, notModify } = config;
const handleBeforeUpload = (file: any) => {
const result = verifyImage(file);
if (result) {
fastMessage.error(result);
return false;
}
uploadImg(file).then((data: any) => {
// eslint-disable-next-line react/destructuring-assignment
props[validateTrigger](
type === "multuploadimage"
? [
...values[key],
{
url: data.url,
},
]
: data.url
);
});
return false;
};
if (type === "multuploadimage") {
return (
上传
);
}
if (notModify) {
return (
);
}
return (
{values[key] ? (
) : (
上传
)}
);
}
export default UploadImg;