diff --git a/web1/src/views/pages/index.vue b/web1/src/views/pages/index.vue index 558a4e0..462c909 100644 --- a/web1/src/views/pages/index.vue +++ b/web1/src/views/pages/index.vue @@ -298,7 +298,9 @@ @@ -402,9 +404,11 @@
@@ -435,9 +439,11 @@
@@ -933,6 +939,8 @@ const steps = [ ] const loading = ref(false) const actionUrl = 'https://value.cdcee.net/api/v1/upload/file' +const uploadLimit = 10 +const uploadMaxSize = 20 * 1024 * 1024 const currentStep = ref(0) const historyList = ref([]) const modalForm = reactive({ @@ -1411,10 +1419,28 @@ const handleFinish2 = (file) => { modalForm.pattern_images.push({ url: response.data.url, id: file.file.batchId }) } const handleFinish3 = (file) => { - console.log(file) let response = JSON.parse(file.event.target.response) modalForm.inheritor_certificates.push({ url: response.data.url, id: file.file.batchId }) } +type UploadKey = 'inheritor_certificates' | 'patent_certificates' | 'pattern_images' +const handleBeforeUpload = (options: any, key: UploadKey) => { + const map: Record = { + inheritor_certificates: modalForm.inheritor_certificates, + patent_certificates: modalForm.patent_certificates, + pattern_images: modalForm.pattern_images, + } + const currentList = map[key] || [] + if (currentList.length >= uploadLimit) { + message.error(`最多上传${uploadLimit}张`) + return false + } + const size = options?.file?.file?.size || 0 + if (size > uploadMaxSize) { + message.error('单张文件大小不能超过20M') + return false + } + return true +} const delete1 = (file) => { const index = modalForm.patent_certificates.findIndex((item) => item.id === file.file.batchId) if (index !== -1) { @@ -1432,7 +1458,6 @@ const delete3 = (file) => { if (index !== -1) { modalForm.inheritor_certificates.splice(index, 1) } - console.log(modalForm.inheritor_certificates) } const previousStep = () => { console.log(modalForm)