|
@@ -40,6 +40,7 @@ const props = withDefaults(
|
|
|
maxSize?: number;
|
|
|
disabled?: boolean;
|
|
|
uploadFileAlias?: string;
|
|
|
+ minSize?: number;
|
|
|
}>(),
|
|
|
{
|
|
|
uploadUrl: "",
|
|
@@ -115,7 +116,13 @@ const handleBeforeUpload: UploadProps["beforeUpload"] = async (file) => {
|
|
|
...props.uploadData,
|
|
|
filename: file.name,
|
|
|
};
|
|
|
-
|
|
|
+ if (props.minSize) {
|
|
|
+ if (file.size < props.minSize) {
|
|
|
+ handleExceededSize("图片大小不能小于3Kb");
|
|
|
+ window.$message.error("图片大小不能小于3Kb");
|
|
|
+ return Promise.reject(result.value);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (file.size > props.maxSize) {
|
|
|
handleExceededSize();
|
|
|
return Promise.reject(result.value);
|
|
@@ -205,8 +212,8 @@ function handleFormatError() {
|
|
|
loading.value = false;
|
|
|
emit("validError", result.value);
|
|
|
}
|
|
|
-function handleExceededSize() {
|
|
|
- const content = `文件大小不能超过${Math.floor(props.maxSize / 1024)}M`;
|
|
|
+function handleExceededSize(c?: string) {
|
|
|
+ const content = c || `文件大小不能超过${Math.floor(props.maxSize / 1024)}M`;
|
|
|
result.value = {
|
|
|
success: false,
|
|
|
message: content,
|