mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-12 21:52:48 +00:00
解决文件上传 autoUpload 参数错误问题
This commit is contained in:
parent
1ab8562123
commit
43fdb3034b
@ -174,7 +174,7 @@ function onUpload(raw: File, _: any, { next }: any) {
|
|||||||
|
|
||||||
next();
|
next();
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载模版
|
// 下载模版
|
||||||
|
|||||||
@ -294,7 +294,7 @@ async function onBeforeUpload(file: any, item?: Upload.Item) {
|
|||||||
size: file.size,
|
size: file.size,
|
||||||
name: file.name,
|
name: file.name,
|
||||||
type: getType(file.name),
|
type: getType(file.name),
|
||||||
progress: 0,
|
progress: props.autoUpload ? 0 : 100, // 非自动上传时默认100%
|
||||||
url: "",
|
url: "",
|
||||||
preload: "",
|
preload: "",
|
||||||
error: ""
|
error: ""
|
||||||
@ -310,15 +310,14 @@ async function onBeforeUpload(file: any, item?: Upload.Item) {
|
|||||||
// 上传事件
|
// 上传事件
|
||||||
emit("upload", d, file);
|
emit("upload", d, file);
|
||||||
|
|
||||||
// 是否自动上传
|
|
||||||
if (props.autoUpload) {
|
|
||||||
// 赋值
|
// 赋值
|
||||||
if (item) {
|
if (item) {
|
||||||
Object.assign(item, d);
|
Object.assign(item, d);
|
||||||
} else {
|
} else {
|
||||||
if (props.multiple) {
|
if (props.multiple) {
|
||||||
if (!isAdd.value) {
|
if (!isAdd.value) {
|
||||||
ElMessage.warning(`最多只能上传${limit.value}个文件`);
|
ElMessage.warning(`最多只能上传${limit}个文件`);
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
list.value.push(d);
|
list.value.push(d);
|
||||||
}
|
}
|
||||||
@ -330,18 +329,15 @@ async function onBeforeUpload(file: any, item?: Upload.Item) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自定义上传事件
|
// 自定义上传事件
|
||||||
if (props.beforeUpload) {
|
if (props.beforeUpload) {
|
||||||
const r = props.beforeUpload(file, item, { next });
|
let r = props.beforeUpload(file, item, { next });
|
||||||
|
|
||||||
if (isPromise(r)) {
|
if (isPromise(r)) {
|
||||||
r.then(next).catch(() => null);
|
r.then(next).catch(() => null);
|
||||||
} else {
|
} else {
|
||||||
if (r) {
|
if (r) {
|
||||||
next();
|
r = next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user