Commit e1b2149a authored by 杨南鸿's avatar 杨南鸿

更新upload组件参数

parent 9bca25ba
...@@ -86,32 +86,30 @@ export default { ...@@ -86,32 +86,30 @@ export default {
}); });
}, },
upload(rawFile) { upload(rawFile) {
let filename = '';
let fileIndex = '';
this.$refs.input.value = null; this.$refs.input.value = null;
if (!this.beforeUpload) { if (this.needTitle) {
return this.post(rawFile); fileIndex = this.fileList.findIndex(o => o.uid === rawFile.uid);
let file = this.fileList[fileIndex];
filename = file.name;
let orgSuffix = rawFile.name.substring(rawFile.name.lastIndexOf('.'));
if (filename.indexOf('.') === -1) {
// 不存在文件类型后缀,补充原文件后缀
filename = file.name + orgSuffix;
} else {
let suffix = filename.substring(filename.lastIndexOf('.'));
if (suffix !== orgSuffix) {
// 文件类型后缀不相同,再补充原文件后缀
filename = filename + orgSuffix;
}
}
} }
if (!this.beforeUpload) { if (!this.beforeUpload) {
if (this.needTitle) { return this.post(rawFile, filename, fileIndex);
let fileIndex = this.fileList.findIndex(o => o.uid === rawFile.uid);
let file = this.fileList[fileIndex];
let filename = file.name;
let orgSuffix = rawFile.name.substring(rawFile.name.lastIndexOf('.'));
if (filename.indexOf('.') === -1) {
// 不存在文件类型后缀,补充原文件后缀
filename = file.name + orgSuffix;
} else {
let suffix = filename.substring(filename.lastIndexOf('.'));
if (suffix !== orgSuffix) {
// 文件类型后缀不相同,再补充原文件后缀
filename = filename + orgSuffix;
}
}
return this.post(rawFile, filename, fileIndex);
} else {
return this.post(rawFile);
}
} }
const before = this.beforeUpload(rawFile); const before = this.beforeUpload(rawFile);
...@@ -130,15 +128,15 @@ export default { ...@@ -130,15 +128,15 @@ export default {
processedFile[p] = rawFile[p]; processedFile[p] = rawFile[p];
} }
} }
this.post(processedFile); this.post(processedFile, filename, fileIndex);
} else { } else {
this.post(rawFile); this.post(rawFile, filename, fileIndex);
} }
}, () => { }, () => {
this.onRemove(null, rawFile); this.onRemove(null, rawFile);
}); });
} else if (before !== false) { } else if (before !== false) {
this.post(rawFile); this.post(rawFile, filename, fileIndex);
} else { } else {
this.onRemove(null, rawFile); this.onRemove(null, rawFile);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment