文件上传优化

This commit is contained in:
cwchen 2025-10-28 16:25:47 +08:00
parent 841475250c
commit d20331fbf0
9 changed files with 410 additions and 318 deletions

View File

@ -1,8 +1,9 @@
<template>
<div class="upload-container">
<el-upload class="upload-demo" drag action="#" multiple :show-file-list="true" :before-upload="beforeUpload"
:on-change="handleFileChange" :on-remove="handleRemove" :on-exceed="handleExceed" :file-list="files"
:accept="accept" :limit="limitUploadNum" :auto-upload="autoUpload">
<el-upload ref="upload" class="upload-demo" drag action="#" multiple :show-file-list="true"
:before-upload="beforeUpload" :on-remove="handleRemove" :on-change="handleFileChange"
:on-exceed="handleExceed" :file-list="files" :accept="accept" :limit="limitUploadNum"
:auto-upload="autoUpload" :http-request="customUpload">
<div class="upload-content">
<!-- 当只有一张图片时显示缩略图 -->
<div v-if="showImagePreview" class="image-preview">
@ -43,161 +44,236 @@
</template>
<script>
import { uploadSmallFileByOcr, uploadLargeFileByOcr, uploadSmallFile, uploadLargeFile } from '@/api/common/uploadFile.js'
import {
uploadSmallFileByOcr,
uploadLargeFileByOcr,
uploadSmallFile,
uploadLargeFile,
} from '@/api/common/uploadFile.js'
export default {
name: 'UploadFile',
props: {
fileList: {
type: Array,
default: () => []
default: () => [],
},
maxFileTips: {
type: String,
default: '20MB'
default: '20MB',
},
uploadType: {
type: String,
default: 'png、jpg、jpeg'
default: 'png、jpg、jpeg',
},
limitUploadNum: {
type: Number,
default: 1
default: 1,
},
fileUploadRule: {
type: Object,
default: () => ({})
default: () => ({}),
},
autoUpload: {
type: Boolean,
default: true
default: true,
},
type: {
type: String,
default: ''
default: '',
},
},
data() {
return {
files: [...this.fileList], // 使
files: [],
previewImageUrl: '',
previewImageName: '',
previewFileName: '',
previewFileType: '',
isUploading: false, //
defaultFileSize: 1024 * 1024 * 5, // 5MB 5MB
skipNextChange: false,
}
},
computed: {
//
showImagePreview() {
return this.previewImageUrl && this.files.length === 1
},
//
showFilePreview() {
return (
this.previewFileName &&
this.previewFileType &&
this.files.length === 1
)
},
accept() {
return this.uploadType
.split('、')
.map((type) => `.${type}`)
.join(',')
},
//
allowedTypes() {
return this.uploadType.split('、')
},
// MB
maxSizeMB() {
const sizeStr = this.maxFileTips.toLowerCase()
if (sizeStr.includes('mb')) {
return parseFloat(sizeStr)
} else if (sizeStr.includes('kb')) {
return parseFloat(sizeStr) / 1024
} else if (sizeStr.includes('gb')) {
return parseFloat(sizeStr) * 1024
}
return 20
},
// MIME
mimeTypes() {
const typeMap = {
png: 'image/png',
jpg: 'image/jpeg',
jpeg: 'image/jpeg',
pdf: 'application/pdf',
doc: 'application/msword',
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
xls: 'application/vnd.ms-excel',
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
}
return this.allowedTypes.map((type) => typeMap[type] || '')
},
},
watch: {
fileList: {
handler(newVal) {
if (this.files.length === 0 && newVal.length > 0) {
// 使 $nextTick DOM
this.$nextTick(() => {
//
if (this.$refs.upload) {
this.$refs.upload.uploadFiles = this.formatFileList(newVal)
}
this.files = this.formatFileList(newVal)
//
this.handlePreviewFromExternal(newVal)
})
}
},
immediate: true,
deep: true
},
},
methods: {
beforeUpload(file) {
//
if (this.isUploading) {
return false;
this.$message.warning('当前有文件正在上传,请稍后再试')
return false
}
//
const fileExtension = file.name.split('.').pop().toLowerCase();
const isAllowedType = this.allowedTypes.includes(fileExtension);
const fileExtension = file.name.split('.').pop().toLowerCase()
const isAllowedType = this.allowedTypes.includes(fileExtension)
// MIME
const isAllowedMimeType = this.mimeTypes.includes(file.type);
const isAllowedMimeType = this.mimeTypes.includes(file.type)
//
const isLtMaxSize = file.size / 1024 / 1024 < this.maxSizeMB;
const isLtMaxSize = file.size / 1024 / 1024 < this.maxSizeMB
if (!isAllowedType || !isAllowedMimeType) {
this.$message.error(`只能上传 ${this.uploadType} 格式的文件!`);
return false;
this.$message.error(`只能上传 ${this.uploadType} 格式的文件!`)
return false
}
if (!isLtMaxSize) {
this.$message.error(`文件大小不能超过 ${this.maxFileTips}!`);
return false;
this.$message.error(`文件大小不能超过 ${this.maxFileTips}!`)
return false
}
return false;
return true
},
//
handleFileChange(file, fileList) {
//
if (file.status === 'removed' || file.status === 'fail') {
return;
//
if (file.status === 'removed' || file.status === 'fail' || file.status === 'success') {
console.log('现在的文件:', this.files);
return
}
// 使使 fileList files
this.files = this.formatFileList(fileList);
//
this.files = this.formatFileList(fileList)
//
if (file.raw && fileList.length === 1) {
if (this.isImageFile(file.raw)) {
//
this.generateImagePreview(file.raw);
this.generateImagePreview(file.raw)
} else if (this.isDocumentFile(file.raw)) {
//
this.generateDocumentPreview(file.raw);
this.generateDocumentPreview(file.raw)
}
} else {
//
this.clearPreview();
}
//
if (this.autoUpload && file.status === 'ready' && !this.isUploading) {
if (this.fileUploadRule.fields_json) {
// ocr
this.uploadFile(file, '识别中');
} else {
// ocr
this.uploadFile(file, '上传中');
}
this.clearPreview()
}
},
//
formatFileList(fileList) {
return fileList.map(file => {
//
const formattedFile = {
uid: file.uid,
name: file.name,
size: file.size,
type: file.type,
status: file.status,
raw: file.raw
};
// percentage
if (file.percentage !== undefined && file.percentage !== null) {
formattedFile.percentage = Math.max(0, Math.min(100, file.percentage));
} else if (file.status === 'uploading') {
formattedFile.percentage = 0;
} else if (file.status === 'success') {
formattedFile.percentage = 100;
}
//
if (file.response) {
formattedFile.response = file.response;
formattedFile.url = file.url;
}
if (file.statusText) {
formattedFile.statusText = file.statusText;
}
return formattedFile;
});
//
handleSuccess(response, file) {
this.$bus.$emit('endUpload')
//
this.updateFileStatus(file.uid, 'success', '', response.data, 100)
//
this.$emit('file-change', this.getCurrentFiles(), this.type)
//
this.isUploading = false
},
//
async uploadFile(file, text) {
//
handleError(error, file) {
console.error('上传失败:', error)
this.$bus.$emit('endUpload')
//
this.removeFailedFile(file.uid)
//
this.isUploading = false
},
//
async customUpload(options) {
console.log(options);
const { file } = options;
//
this.isUploading = true;
const formData = new FormData();
formData.append('file', file.raw);
formData.append('file', file);
formData.append('params', JSON.stringify(this.fileUploadRule));
// el-upload
const uploadFileObj = this.findFileByRawFile(file);
if (!uploadFileObj) {
console.error('未找到对应的文件对象');
this.handleError(new Error('文件对象不存在'), file);
return;
}
const fileUid = uploadFileObj.uid;
// 0
this.updateFileStatus(file.uid, 'uploading', text, null, 0);
this.updateFileStatus(
fileUid,
'uploading',
this.fileUploadRule.fields_json ? '识别中' : '上传中',
null,
0,
);
try {
this.$bus.$emit('startUpload', text);
this.$bus.$emit(
'startUpload',
this.fileUploadRule.fields_json ? '识别中' : '上传中',
);
let res = null;
if (this.defaultFileSize < file.size) {
if (this.fileUploadRule.fields_json) {
@ -212,131 +288,108 @@ export default {
res = await uploadSmallFile(formData);
}
}
console.log('上传成功:', res);
this.$bus.$emit('endUpload');
// 100
this.updateFileStatus(file.uid, 'success', '', res.data, 100);
console.log('上传成功后的文件列表:', this.files);
//
this.$emit('file-change', this.getCurrentFiles(), this.type);
if (res.code === 200) {
this.handleSuccess(res, uploadFileObj);
} else {
this.handleError(new Error(res.message || '上传失败'), uploadFileObj);
}
} catch (err) {
this.$bus.$emit('endUpload');
//
this.removeFailedFile(file.uid);
this.handleError(err, uploadFileObj);
} finally {
//
this.isUploading = false;
}
},
//
findFileByRawFile(rawFile) {
return this.files.find(item =>
item.raw === rawFile ||
(item.name === rawFile.name && item.size === rawFile.size)
);
},
//
removeFailedFile(fileUid) {
console.log('移除上传失败的文件:', fileUid);
const fileIndex = this.files.findIndex(item => item.uid === fileUid);
console.log('移除上传失败的文件:', fileUid)
const fileIndex = this.files.findIndex(
(item) => item.uid === fileUid,
)
if (fileIndex !== -1) {
//
this.files.splice(fileIndex, 1);
console.log('移除失败文件后的文件列表:', this.files);
this.files.splice(fileIndex, 1)
console.log('移除失败文件后的文件列表:', this.files)
//
this.clearPreview();
this.clearPreview()
//
this.$emit('file-change', this.getCurrentFiles(), this.type);
this.$emit('file-change', this.getCurrentFiles(), this.type)
}
},
//
updateFileStatus(fileUid, status, statusText, responseData = null, percentage = null) {
console.log('更新文件状态:', fileUid, status, statusText, '进度:', percentage);
console.log('更新前的文件列表:', this.files);
const fileIndex = this.files.findIndex(item => item.uid === fileUid);
updateFileStatus(
fileUid,
status,
statusText,
responseData = null,
percentage = null,
) {
const fileIndex = this.files.findIndex(
(item) => item.uid === fileUid,
)
if (fileIndex !== -1) {
const updatedFile = {
...this.files[fileIndex],
status: status
};
status: status,
}
if (statusText) {
updatedFile.statusText = statusText;
updatedFile.statusText = statusText
}
// percentage 0-100
if (percentage !== null && percentage >= 0 && percentage <= 100) {
updatedFile.percentage = percentage;
if (
percentage !== null &&
percentage >= 0 &&
percentage <= 100
) {
updatedFile.percentage = percentage
} else if (status === 'uploading') {
// 0
updatedFile.percentage = 0;
updatedFile.percentage = 0
} else if (status === 'success') {
// 100
updatedFile.percentage = 100;
updatedFile.percentage = 100
}
if (responseData) {
//
updatedFile.response = responseData;
updatedFile.response.businessType = this.fileUploadRule?.fileUploadType;
updatedFile.response.businessType =
this.fileUploadRule?.fileUploadType;
updatedFile.res = updatedFile.response;
}
// 使 Vue.set
this.$set(this.files, fileIndex, updatedFile);
console.log('更新后的文件列表:', this.files);
this.$set(this.files, fileIndex, updatedFile)
console.log('更新后的文件列表:', this.files)
} else {
console.warn('未找到要更新的文件:', fileUid);
console.warn('未找到要更新的文件:', fileUid)
}
},
//
getCurrentFiles() {
const currentFiles = this.files.map(file => {
const fileObj = {
uid: file.uid,
name: file.name,
size: file.size,
type: file.type,
status: file.status
};
// percentage
if (file.percentage !== undefined) {
fileObj.percentage = file.percentage;
}
//
if (file.raw) {
fileObj.raw = file.raw;
}
//
if (file.response) {
fileObj.response = file.response;
fileObj.response.businessType = this.fileUploadRule?.fileUploadType;
}
return fileObj;
});
console.log('getCurrentFiles 返回:', currentFiles);
return currentFiles;
},
//
handleExceed(files, fileList) {
console.log('文件超出限制处理', files, fileList);
console.log('文件超出限制处理', files, fileList)
//
if (files.length > 0) {
//
this.$emit('del-file', fileList[0]);
this.$emit('del-file', fileList[0])
//
this.files = [];
this.files = []
//
const newFile = files[0];
this.beforeUpload(newFile); //
const newFile = files[0]
// percentage
const newFileObj = {
name: newFile.name,
@ -345,50 +398,35 @@ export default {
raw: newFile,
uid: Date.now(), // uid
status: 'ready',
percentage: 0 //
};
percentage: 0, //
}
//
this.files = [newFileObj];
this.files = [newFileObj]
//
if (this.isImageFile(newFile)) {
this.generateImagePreview(newFile);
this.generateImagePreview(newFile)
} else if (this.isDocumentFile(newFile)) {
this.generateDocumentPreview(newFile);
this.generateDocumentPreview(newFile)
}
console.log('handleExceed 后的文件列表:', this.files);
//
this.$emit('file-change', this.getCurrentFiles());
console.log('handleExceed 后的文件列表:', this.files)
//
if (this.autoUpload && !this.isUploading) {
if (this.fileUploadRule.fields_json) {
this.uploadFile(newFileObj, '识别中');
} else {
this.uploadFile(newFileObj, '上传中');
}
this.$nextTick(() => {
this.$refs.upload.submit();
});
}
}
},
//
handleRemove(file, fileList) {
console.log('移除文件:', file);
console.log('移除前的文件列表:', this.files);
//
if (this.isUploading) {
return false;
if (this.isUploading && file.status === 'uploading') {
this.$message.warning('文件正在上传中,请稍后再删除');
return false; //
}
// 使
this.files = this.formatFileList(fileList);
console.log('移除后的文件列表:', this.files);
//
if (fileList.length === 0) {
this.clearPreview();
@ -401,158 +439,189 @@ export default {
} else {
this.clearPreview();
}
//
this.$emit('del-file', file);
const delFileObj = this.findFileByRawFile(file.raw);
delFileObj.response = delFileObj.res;
//
this.files = this.formatFileList(fileList);
//
this.$emit('del-file', delFileObj);
//
this.$emit('file-change', this.getCurrentFiles());
this.$emit('file-change', this.getCurrentFiles(), this.type);
// true false
return true;
},
//
formatFileList(fileList) {
return fileList.map((file) => {
//
const formattedFile = {
uid: file.uid,
name: file.name,
size: file.size,
type: file.type,
status: file.status,
raw: file.raw,
}
// percentage
if (file.percentage !== undefined && file.percentage !== null) {
formattedFile.percentage = Math.max(
0,
Math.min(100, file.percentage),
)
} else if (file.status === 'uploading') {
formattedFile.percentage = 0
} else if (file.status === 'success') {
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
})
},
//
getCurrentFiles() {
const currentFiles = this.files.map((file) => {
const fileObj = {
uid: file.uid,
name: file.name,
size: file.size,
type: file.type,
status: file.status,
}
// percentage
if (file.percentage !== undefined) {
fileObj.percentage = file.percentage
}
//
if (file.raw) {
fileObj.raw = file.raw
}
//
if (file.response) {
fileObj.response = file.response
fileObj.response.businessType =
this.fileUploadRule?.fileUploadType
}
return fileObj
})
return currentFiles
},
//
isImageFile(file) {
return (file && file.type && file.type.startsWith('image/')) || (file && file.fileType === '1');
return (
(file && file.type && file.type.startsWith('image/')) ||
(file && file.fileType === '1')
)
},
//
isDocumentFile(file) {
if (!file || !file.name) return false;
const fileExtension = file.name.split('.').pop().toLowerCase();
return ['pdf', 'doc', 'docx', 'xls', 'xlsx'].includes(fileExtension) || (file && file.fileType === '2');
if (!file || !file.name) return false
const fileExtension = file.name.split('.').pop().toLowerCase()
return (
['pdf', 'doc', 'docx', 'xls', 'xlsx'].includes(fileExtension) ||
(file && file.fileType === '2')
)
},
//
generateImagePreview(file) {
const reader = new FileReader();
const reader = new FileReader()
reader.onload = (e) => {
this.previewImageUrl = e.target.result;
this.previewImageName = file.name;
this.previewImageUrl = e.target.result
this.previewImageName = file.name
//
this.previewFileName = '';
this.previewFileType = '';
};
reader.readAsDataURL(file);
this.previewFileName = ''
this.previewFileType = ''
}
reader.readAsDataURL(file)
},
//
generateImagePreviewFromPath(file) {
this.previewImageUrl = file.lsFilePath;
this.previewImageName = file.name;
this.previewImageUrl = file.lsFilePath
this.previewImageName = file.name
//
this.previewFileName = '';
this.previewFileType = '';
this.previewFileName = ''
this.previewFileType = ''
},
//
generateDocumentPreview(file) {
const fileExtension = file.name.split('.').pop().toLowerCase();
this.previewFileName = file.name;
this.previewFileType = fileExtension;
const fileExtension = file.name.split('.').pop().toLowerCase()
this.previewFileName = file.name
this.previewFileType = fileExtension
//
this.previewImageUrl = '';
this.previewImageName = '';
this.previewImageUrl = ''
this.previewImageName = ''
},
//
clearPreview() {
this.previewImageUrl = '';
this.previewImageName = '';
this.previewFileName = '';
this.previewFileType = '';
this.previewImageUrl = ''
this.previewImageName = ''
this.previewFileName = ''
this.previewFileType = ''
},
//
getFileIconClass() {
const iconMap = {
'pdf': 'el-icon-document',
'doc': 'el-icon-document',
'docx': 'el-icon-document',
'xls': 'el-icon-document',
'xlsx': 'el-icon-document'
};
return iconMap[this.previewFileType] || 'el-icon-document';
pdf: 'el-icon-document',
doc: 'el-icon-document',
docx: 'el-icon-document',
xls: 'el-icon-document',
xlsx: 'el-icon-document',
}
return iconMap[this.previewFileType] || 'el-icon-document'
},
//
clearFiles() {
this.files = [];
this.clearPreview();
this.$emit('file-change', []);
}
},
computed: {
//
showImagePreview() {
return this.previewImageUrl &&
this.files.length === 1 ;
this.files = []
this.clearPreview()
this.$emit('file-change', [])
},
//
showFilePreview() {
return this.previewFileName &&
this.previewFileType &&
this.files.length === 1;
},
accept() {
return this.uploadType.split('、').map(type => `.${type}`).join(',');
},
//
allowedTypes() {
return this.uploadType.split('、');
},
// MB
maxSizeMB() {
const sizeStr = this.maxFileTips.toLowerCase();
if (sizeStr.includes('mb')) {
return parseFloat(sizeStr);
} else if (sizeStr.includes('kb')) {
return parseFloat(sizeStr) / 1024;
} else if (sizeStr.includes('gb')) {
return parseFloat(sizeStr) * 1024;
}
return 20;
},
// MIME
mimeTypes() {
const typeMap = {
'png': 'image/png',
'jpg': 'image/jpeg',
'jpeg': 'image/jpeg',
'pdf': 'application/pdf',
'doc': 'application/msword',
'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xls': 'application/vnd.ms-excel',
'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
};
return this.allowedTypes.map(type => typeMap[type] || '');
}
},
watch: {
fileList: {
handler(newVal) {
this.files = this.formatFileList(newVal);
// lsFilePath
if (newVal.length > 0) {
const firstFile = newVal[0];
if (firstFile && firstFile.lsFilePath) {
//
if (this.isImageFile(firstFile)) {
this.generateImagePreviewFromPath(firstFile);
} else if (this.isDocumentFile(firstFile)) {
this.generateDocumentPreview(firstFile);
}
} else {
// lsFilePath退
if (firstFile && firstFile.raw) {
if (this.isImageFile(firstFile.raw)) {
this.generateImagePreview(firstFile.raw);
} else if (this.isDocumentFile(firstFile.raw)) {
this.generateDocumentPreview(firstFile.raw);
}
} else {
this.clearPreview();
}
//
handlePreviewFromExternal(fileList) {
if (fileList.length > 0) {
const firstFile = fileList[0]
if (firstFile && firstFile.lsFilePath) {
if (this.isImageFile(firstFile)) {
this.generateImagePreviewFromPath(firstFile)
} else if (this.isDocumentFile(firstFile)) {
this.generateDocumentPreview(firstFile)
}
} else if (firstFile && firstFile.raw) {
if (this.isImageFile(firstFile.raw)) {
this.generateImagePreview(firstFile.raw)
} else if (this.isDocumentFile(firstFile.raw)) {
this.generateDocumentPreview(firstFile.raw)
}
} else {
this.clearPreview();
this.clearPreview()
}
},
immediate: true,
deep: true
}
} else {
this.clearPreview()
}
},
},
}
</script>
@ -569,9 +638,9 @@ export default {
.el-upload-dragger {
width: 100%;
height: 240px;
border: 2px dashed #DCDFE6;
border: 2px dashed #dcdfe6;
border-radius: 8px;
background-color: #FAFAFA;
background-color: #fafafa;
display: flex;
align-items: center;
justify-content: center;
@ -580,8 +649,8 @@ export default {
overflow: hidden;
&:hover {
border-color: #409EFF;
background-color: #F5F7FA;
border-color: #409eff;
background-color: #f5f7fa;
}
}
}
@ -672,7 +741,7 @@ export default {
.file-icon {
font-size: 64px;
color: #1F72EA;
color: #1f72ea;
margin-bottom: 16px;
}
@ -735,7 +804,7 @@ export default {
.main-text {
font-size: 18px;
color: #1F72EA;
color: #1f72ea;
margin-bottom: 12px;
font-weight: 500;
}
@ -752,4 +821,4 @@ export default {
}
}
}
</style>
</style>

View File

@ -119,7 +119,10 @@ export default {
//
handleDelFile(file) {
console.log(file);
this.form.delFileList.push(file.response.fileRes.uploadPath || file.filePath);
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if(delPath){
this.form.delFileList.push(delPath);
}
},
setFormData(){
const fileList = this.getFileList('account_opening_license');

View File

@ -174,7 +174,10 @@ export default {
//
handleDelFile(file) {
console.log(file);
this.form.delFileList.push(file.response.fileRes.uploadPath || file.filePath);
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if(delPath){
this.form.delFileList.push(delPath);
}
},
setFormData(){
const fileList = this.getFileList('business_license');

View File

@ -172,7 +172,10 @@ export default {
//
handleDelFile(file) {
console.log(file);
this.form.delFileList.push(file.response.fileRes.uploadPath || file.filePath);
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if(delPath){
this.form.delFileList.push(delPath);
}
},
setFormData(){
const fileList = this.getFileList('face_id_card_portrait')

View File

@ -295,6 +295,9 @@ export default {
//
assembleFormData(basicInfoData, qualificationData = EMPTY_OBJECT, otherData = EMPTY_OBJECT) {
console.log(qualificationData);
console.log(otherData);
//
const allFiles = [
...this.safeGetArray(basicInfoData.fileList),

View File

@ -261,7 +261,10 @@ export default {
//
handleDelFile(file) {
console.log(file);
this.form.delFileList.push(file.response.fileRes.uploadPath || file.filePath);
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if(delPath){
this.form.delFileList.push(delPath);
}
},
setFormData() {
const fileList = this.getFileList('face_id_card_portrait');

View File

@ -145,7 +145,10 @@ export default {
//
handleDelFile(file) {
console.log(file);
this.form.delFileList.push(file.response.fileRes.uploadPath || file.filePath);
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if(delPath){
this.form.delFileList.push(delPath);
}
},
setFormData() {

View File

@ -302,7 +302,10 @@ export default {
//
handleDelFile(file) {
console.log(file);
this.form.delFileList.push(file.response.fileRes.uploadPath || file.filePath);
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if(delPath){
this.form.delFileList.push(delPath);
}
},
setFormData() {
const { fileUploadType } = CONSTRUCTOR_CERTIFICATE;

View File

@ -19,14 +19,14 @@
//
const defaultParams = {
fileType: 'technical_solution',
uploadType: 'pdf、doc、docx',
uploadType: 'pdf、doc、docx、jpe、png、jpeg',
maxFileTips: '1MB',
fileUploadRule: {
fileUploadType: 'technical_solution',
fields_json: '',
suffix: 'technical_solution_database'
},
limitUploadNum: 10
limitUploadNum: 1
};
import UploadFile from '@/views/common/UploadFile.vue'
export default {
@ -83,8 +83,10 @@ export default {
},
//
handleDelFile(file) {
console.log(file);
this.form.delFileList.push(file.response.fileRes.uploadPath || file.filePath);
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
if(delPath){
this.form.delFileList.push(delPath);
}
},
setFormData() {
},