bug修复

This commit is contained in:
cwchen 2025-11-19 11:06:32 +08:00
parent add4c8e032
commit 7d4b929fc4
3 changed files with 52 additions and 15 deletions

View File

@ -111,7 +111,7 @@ export default {
watch: {
fileList: {
handler(newVal) {
if (this.files.length === 0 && newVal.length > 0) {
this.$nextTick(() => {
if (this.$refs.upload) {
@ -273,24 +273,55 @@ export default {
},
handleExceed(files, fileList) {
this.$message.warning(`最多只能上传 ${this.limitUploadNum} 个文件,已自动截取前 ${this.limitUploadNum} 个文件`);
// FileList
const filesArray = Array.from(files);
const remainingSlots = this.limitUploadNum - this.files.length;
//
if (this.limitUploadNum === 1) {
//
this.$emit('del-file', { ...fileList[0], response: fileList[0].res })
//
this.files = [];
if (remainingSlots > 0) {
const filesToAdd = filesArray.slice(0, remainingSlots);
filesToAdd.forEach(file => {
const newFileObj = this.createFileObject(file);
this.files.push(newFileObj);
// el-upload
this.$nextTick(() => {
if (this.$refs.upload) {
this.$refs.upload.uploadFiles = [];
}
if (this.autoUpload) {
this.$nextTick(() => {
this.uploadFile(newFileObj);
});
//
if (filesArray.length > 0) {
const newFileObj = this.createFileObject(filesArray[0]);
this.files.push(newFileObj);
if (this.autoUpload) {
this.$nextTick(() => {
this.uploadFile(newFileObj);
});
}
}
});
this.$message.success('文件已替换');
} else {
//
this.$message.warning(`最多只能上传 ${this.limitUploadNum} 个文件,已自动截取前 ${this.limitUploadNum} 个文件`);
const remainingSlots = this.limitUploadNum - this.files.length;
if (remainingSlots > 0) {
const filesToAdd = filesArray.slice(0, remainingSlots);
filesToAdd.forEach(file => {
const newFileObj = this.createFileObject(file);
this.files.push(newFileObj);
if (this.autoUpload) {
this.$nextTick(() => {
this.uploadFile(newFileObj);
});
}
});
}
}
},
@ -392,10 +423,13 @@ export default {
formattedFile.percentage = 100
}
//
if (file.response) {
formattedFile.response = file.response
formattedFile.res = file.response
}
if (file.filePath) formattedFile.filePath = file.filePath
if (file.statusText) formattedFile.statusText = file.statusText
return formattedFile
})

View File

@ -96,7 +96,7 @@ export default {
this.$refs.basicInfo.validate(),
this.$refs.fileInfo.validate()
])
//
let formData = {
...basicInfoData,

View File

@ -70,7 +70,7 @@ export default {
handler(newVal) {
if (Object.keys(newVal).length > 0) {
this.limitUploadNum = 1;
this.disabled = true;
// this.disabled = true;
this.setFormData(newVal)
}
},
@ -102,13 +102,16 @@ export default {
},
//
handleDelFile(file) {
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if (delPath) {
this.form.delFileList.push(delPath);
}
},
setFormData() {
const fileList = this.getFileList();
this.form = {
fileList: fileList,
delFileList: []