1
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
:on-exceed="handleExceed"
|
||||
:on-remove="handleRemove"
|
||||
:before-upload="beforeUpload"
|
||||
:limit="upload_number"
|
||||
:limit="uploadLimitNumber"
|
||||
:accept="fileAccept"
|
||||
:multiple="true"
|
||||
>
|
||||
@@ -31,7 +31,7 @@
|
||||
:on-remove="handleRemove"
|
||||
:before-upload="beforeUpload"
|
||||
:on-exceed="handleExceed"
|
||||
:limit="upload_number"
|
||||
:limit="uploadLimitNumber"
|
||||
:accept="fileAccept"
|
||||
:multiple="true"
|
||||
list-type="picture-card"
|
||||
@@ -71,7 +71,7 @@
|
||||
:on-remove="handleRemove"
|
||||
:on-exceed="handleExceed"
|
||||
:before-upload="beforeUpload"
|
||||
:limit="upload_number"
|
||||
:limit="uploadLimitNumber"
|
||||
:accept="fileAccept"
|
||||
class="drag-upload"
|
||||
:class="{ 'drag-upload-disabled': uploadMode !== 'pc' }"
|
||||
@@ -123,7 +123,7 @@ module.exports = {
|
||||
},
|
||||
// 上传数量
|
||||
upload_number: {
|
||||
type: Number,
|
||||
type: [Number, String],
|
||||
default: 1,
|
||||
required: false
|
||||
},
|
||||
@@ -198,8 +198,12 @@ module.exports = {
|
||||
action() {
|
||||
return this.upload_result_type === "id" ? this.upload_return_id_api : this.upload_dynamic_return_url_api
|
||||
},
|
||||
uploadLimitNumber() {
|
||||
const number = Number(this.upload_number)
|
||||
return Number.isFinite(number) && number > 0 ? number : 1
|
||||
},
|
||||
upload_tips() {
|
||||
const uploadNumber = this.upload_number
|
||||
const uploadNumber = this.uploadLimitNumber
|
||||
const fileAccept = this.fileAccept
|
||||
const fileSize = this.upload_size
|
||||
|
||||
@@ -359,10 +363,12 @@ module.exports = {
|
||||
|
||||
handleRemove(file, fileList) {
|
||||
if (this.upload_result_category === "interval") {
|
||||
if (this.upload_result_type === "id") {
|
||||
}
|
||||
if (this.upload_result_type === "url") {
|
||||
}
|
||||
const resultIntervalValue = fileList
|
||||
.map((item) => item.response && item.response.data ? item.response.data : item.url || item.data)
|
||||
.filter((item) => item)
|
||||
.join(",")
|
||||
this.$emit("update:value", resultIntervalValue)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.upload_result_category === "array") {
|
||||
@@ -381,13 +387,11 @@ module.exports = {
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.$emit("update:value", fileList)
|
||||
}
|
||||
},
|
||||
|
||||
handleExceed(files, fileList) {
|
||||
this.$message.warning("最多只能上传" + this.upload_number + "个文件")
|
||||
this.$message.warning("最多只能上传" + this.uploadLimitNumber + "个文件")
|
||||
},
|
||||
|
||||
// 上传事件
|
||||
@@ -562,8 +566,8 @@ module.exports = {
|
||||
const originFileList = this.fileList || []
|
||||
console.log(data.files)
|
||||
|
||||
if (this.upload_number) {
|
||||
if (originFileList.length + data.files.length > this.upload_number) {
|
||||
if (this.uploadLimitNumber) {
|
||||
if (originFileList.length + data.files.length > this.uploadLimitNumber) {
|
||||
this.$message.error("上传文件数量超出限制")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user