Commit 9bca25ba authored by 杨南鸿's avatar 杨南鸿

更新upload组件参数

parent 4b4f75fa
...@@ -103,6 +103,10 @@ export default { ...@@ -103,6 +103,10 @@ export default {
onExceed: { onExceed: {
type: Function, type: Function,
default: noop default: noop
},
needTitle: {
type: Boolean,
default: false
} }
}, },
...@@ -306,6 +310,7 @@ export default { ...@@ -306,6 +310,7 @@ export default {
listType: this.listType, listType: this.listType,
disabled: this.uploadDisabled, disabled: this.uploadDisabled,
limit: this.limit, limit: this.limit,
needTitle: this.needTitle,
'on-exceed': this.onExceed, 'on-exceed': this.onExceed,
'on-start': this.handleStart, 'on-start': this.handleStart,
'on-progress': this.handleProgress, 'on-progress': this.handleProgress,
......
...@@ -9,6 +9,10 @@ export default { ...@@ -9,6 +9,10 @@ export default {
}, },
props: { props: {
type: String, type: String,
needTitle: {
type: Boolean,
default: false
},
action: { action: {
type: String, type: String,
required: true required: true
...@@ -85,21 +89,29 @@ export default { ...@@ -85,21 +89,29 @@ export default {
this.$refs.input.value = null; this.$refs.input.value = null;
if (!this.beforeUpload) { if (!this.beforeUpload) {
let fileIndex = this.fileList.findIndex(o => o.uid === rawFile.uid); return this.post(rawFile);
let file = this.fileList[fileIndex]; }
let filename = file.name;
let orgSuffix = rawFile.name.substring(rawFile.name.lastIndexOf('.')); if (!this.beforeUpload) {
if (filename.indexOf('.') === -1) { if (this.needTitle) {
// 不存在文件类型后缀,补充原文件后缀 let fileIndex = this.fileList.findIndex(o => o.uid === rawFile.uid);
filename = file.name + orgSuffix; let file = this.fileList[fileIndex];
} else { let filename = file.name;
let suffix = filename.substring(filename.lastIndexOf('.')); let orgSuffix = rawFile.name.substring(rawFile.name.lastIndexOf('.'));
if (suffix !== orgSuffix) { if (filename.indexOf('.') === -1) {
// 文件类型后缀不相同,再补充原文件后缀 // 不存在文件类型后缀,补充原文件后缀
filename = filename + orgSuffix; 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);
} }
return this.post(rawFile, filename, fileIndex);
} }
const before = this.beforeUpload(rawFile); const before = this.beforeUpload(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