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

更新upload组件参数

parent 9bca25ba
...@@ -86,17 +86,15 @@ export default { ...@@ -86,17 +86,15 @@ export default {
}); });
}, },
upload(rawFile) { upload(rawFile) {
this.$refs.input.value = null; let filename = '';
let fileIndex = '';
if (!this.beforeUpload) { this.$refs.input.value = null;
return this.post(rawFile);
}
if (!this.beforeUpload) {
if (this.needTitle) { if (this.needTitle) {
let fileIndex = this.fileList.findIndex(o => o.uid === rawFile.uid); fileIndex = this.fileList.findIndex(o => o.uid === rawFile.uid);
let file = this.fileList[fileIndex]; let file = this.fileList[fileIndex];
let filename = file.name; filename = file.name;
let orgSuffix = rawFile.name.substring(rawFile.name.lastIndexOf('.')); let orgSuffix = rawFile.name.substring(rawFile.name.lastIndexOf('.'));
if (filename.indexOf('.') === -1) { if (filename.indexOf('.') === -1) {
// 不存在文件类型后缀,补充原文件后缀 // 不存在文件类型后缀,补充原文件后缀
...@@ -108,10 +106,10 @@ export default { ...@@ -108,10 +106,10 @@ export default {
filename = filename + orgSuffix; filename = filename + orgSuffix;
} }
} }
return this.post(rawFile, filename, fileIndex);
} else {
return this.post(rawFile);
} }
if (!this.beforeUpload) {
return this.post(rawFile, filename, fileIndex);
} }
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