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

更新upload组件参数

parent 4b4f75fa
......@@ -103,6 +103,10 @@ export default {
onExceed: {
type: Function,
default: noop
},
needTitle: {
type: Boolean,
default: false
}
},
......@@ -306,6 +310,7 @@ export default {
listType: this.listType,
disabled: this.uploadDisabled,
limit: this.limit,
needTitle: this.needTitle,
'on-exceed': this.onExceed,
'on-start': this.handleStart,
'on-progress': this.handleProgress,
......
......@@ -9,6 +9,10 @@ export default {
},
props: {
type: String,
needTitle: {
type: Boolean,
default: false
},
action: {
type: String,
required: true
......@@ -85,21 +89,29 @@ export default {
this.$refs.input.value = null;
if (!this.beforeUpload) {
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);
}
if (!this.beforeUpload) {
if (this.needTitle) {
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);
}
return this.post(rawFile, filename, fileIndex);
}
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